Attention Meets Reachability: Structural Equivalence and Efficiency in Grammar-Constrained LLM Decoding
Not on the map. Why?
Abstract (arXiv)
We study grammar-constrained decoding (GCD) as a coupling between an autoregressive next-token distribution and a reachability oracle over a pushdown system compiled from a context-free grammar (CFG). We prove an oracle invariance theorem: language-equivalent grammars induce identical admissible next-token sets for every prefix, hence identical logit masks, yet can yield provably different compiled state spaces and online ambiguity costs. We give exact control-state blowup counts for the canonical an bn language under redundant nonterminal delegation, and introduce a left-to-right structural ambiguity cost (SAC) measuring incremental packed-parse-forest growth per token. For two equivalent grammars over all finite strings, SAC is O(1) per token under right-recursion but Theta(t2) per token and Theta(n3) cumulatively under concatenation. We establish engine-independent lower bounds: any sound, retrieval-efficient, parse-preserving online masking engine must incur Omega(t2) work per token on a specific constant-size CFG family, unconditionally within this model. We define decoding-cost equivalence classes of grammars and prove existence of minimal-SAC representatives within bounded rewrite families. Finally, we characterize the true conditional sampler via a Doob h-transform and derive sharp one-step KL and total-variation distortion bounds for hard-masked decoding in terms of survival-probability spread among admissible next tokens. We integrate these results with Transformer and Mixture-of-Experts architectures, derive latency envelopes in terms of vocabulary size, active state sets, and beam width, and connect SAC to instrumentation-based predictive performance models and automated grammar optimization.
Key facts. Cited by 1 paper in the map (data through 7 Oct 2026). Builds on 12 of its 37 references that are in the map. First posted on arXiv 4 Mar 2026.
Builds on
12 of 37 references.
References · 12
- 2017Attention Is All You Needcited by 59,932
- 2017Outrageously Large Neural Networks: The Sparsely-Gated Mixture-of-Experts Layercited by 3,413
- 2021Switch Transformers: Scaling to Trillion Parameter Models with Simple and Efficient Sparsitycited by 3,014
- 2021PICARD: Parsing Incrementally for Constrained Auto-Regressive Decoding from Language Modelscited by 402
- 2023Efficient Guided Generation for Large Language Modelscited by 192
- 2021Constrained Language Models Yield Few-Shot Semantic Parserscited by 162
- 2022Prompting Is Programming: A Query Language for Large Language Modelscited by 110
- 2024Guiding LLMs The Right Way: Fast, Non-Invasive Constrained Generationcited by 99
- 2024XGrammar: Flexible and Efficient Structured Generation Engine for Large Language Modelscited by 73
- 2024SynCode: LLM Generation with Grammar Augmentationcited by 66
- 2025JSONSchemaBench: A Rigorous Benchmark of Structured Outputs for Language Modelscited by 66
- 2025Pre3: Enabling Deterministic Pushdown Automata for Faster Structured LLM Generationcited by 11
Built on by
Citing papers per year: 2026: 1.
1 paper.
Similar, not cited
Close in wording, no citation either way
- 2024Grammar-Aligned Decoding
- 2025Constrained Decoding of Diffusion LLMs with Context-Free Grammars
- 2026Constrained Decoding Eliminates Structural Failures in Small LLMs but Reveals a Scale-Dependent Semantic Gap
- 2025textttSEM-CTRL: Semantically Controlled Decoding
- 2026Constrained Decoding for Diffusion Language Models via Efficient Inference over Finite Automata
- 2026Constraints Are Graphs, Not Chains: Exact Decoding for Diffusion Language Models
- 2026Gated Tree Cross-Attention for Checkpoint-Compatible Syntax Injection in Decoder-Only LLMs
- 2025When Grammar Guides the Attack: Uncovering Control-Plane Vulnerabilities in LLMs with Structured Output