Breaking the Space Barrier and its Application to Language Model Inference
Organizations: MBZUAI
Abstract
Language models are more and more often asked for structured output: JSON that follows a schema, or a tool call with typed arguments. A small machine, an automaton, enforces the format by forbidding the tokens that would break it. We observe that this machine has a rare property: from any of its states, each token leads along exactly one path. Graphs in which only a few paths join any two points are a classical object of complexity theory, and our theoretical result settles an open question about them: one can decide whether such a graph connects two points while verifying that it really has few paths, with very little memory. Precisely, the problem lies in the classes ReachUL, LOGDCFL, C=L and SC2, and needs only O(log2 n/ log log n) space, below the classical O(log2 n) of Savitch's theorem. The constructions behind the proofs become an inference engine: text the format forces is written without running the model, the mask is recomputed on the GPU without any table, recursive formats use a small stack, every output stays valid under a token limit, and independent fields are decoded in parallel and verified. On one 16 GB Apple M2 Pro with Qwen3.5-2B and 4B, against MLX with llguidance, the standard setup for this hardware, schema-constrained extraction finishes 1.2- 1.3x sooner with the same answers, a grammar costs 3 MB instead of up to 1.5 GB, one server holds sixteen grammars where tables run out of memory, and sixteen tool-calling agents finish 2.5x sooner.
Figures & tables
| Setting | MLX + llguidance | stcon (ours) |
|---|---|---|
| six JSON extractions, decode time (2B / 4B) | 2.41 / 4.59 s | 1.89 / 3.89 s |
| memory of a 1,106-state tool-call grammar | does not compile (token table: 824 MB) | 3.4 MB |
| sixteen tool-calling agents, wall time (2B) | 74.6 s | 29.3 s |
| eight concurrent tool-call requests (2B) | 134 tok/s | 410 tok/s |
| eighteen JSON jobs, 8 parallel slots, keys-only prompt (2B) | 6.12 s | 3.83 s |
| Class | What the machine may do |
|---|---|
| L | compute deterministically |
| NL | guess, and accept if some sequence of guesses succeeds (directed reachability is the typical problem) |
| ReachUL | guess, but every state of the machine is reachable by at most one sequence of guesses: no ambiguity anywhere |
| LOGDCFL | compute deterministically with an extra stack of unlimited size, in polynomial time |
| SC 2 | one deterministic algorithm that is fast (polynomial time) and uses memory simultaneously |
| C = L | decide whether a signed count of computation paths is exactly zero |
| Mechanism | Idea from the theory | Guarantee |
|---|---|---|
| mask without a table | recompute along the unique path | same mask as a full table; memory = automaton |
| forced text in the same run | forced chains | same output; fewest model runs possible without speculation |
| tokenizer’s split | paths split at crossing points | committed tokens are the tokenizer’s own split |
| budget rule | stop at a budget; shortest paths | valid under every feasible limit; least restrictive |
| GPU stack for recursion | capped stack machine | exact up to nesting depth 64 |
| certified parallel fields | split at crossing points; certify, then use | identical to sequential greedy decoding |
| workload | mlx-lm + llguidance | stcon | gain |
|---|---|---|---|
| 16 coding agents with tool calls, wall time | 74.6 s | 29.3 s | |
| 8 concurrent tool-call requests through the server | 134 tok/s | 410 tok/s | |
| 18 JSON jobs, 8 slots, schema in the prompt | 6.12 s | 4.66 s | |
| 18 JSON jobs, 8 slots, keys-only prompt for stcon | 6.12 s | 3.83 s | |
| 8 streams, no constraint, 2B / 4B (stock mlx-lm) | 188 / 87 tok/s | 576 / 271 tok/s | |
| 40 LiveCodeBench problems, 8 streams, 4B (stock mlx-lm) | 1,181 s | 476 s |
Appendix figures & tables27 assets
Supplementary material from the paper’s appendix.
Appendix
| Target | Result | Construction |
|---|---|---|
| ReachUL ReachFewL | membership | certified finite-field lift (Theorem 9 ) |
| LOGDCFL | membership | capped deterministic auxiliary pushdown (Theorem 8 ) |
| SC 2 | membership | Cook’s simulation of the same pushdown |
| DSPACE | membership | the ReachUL machine, simulated as in [ 1 ] |
| C = L | membership | one GapL zero test of squared vanishing products (Theorem 10 ) |
| NL | membership | collision-averaged fingerprints (Theorem 6 ) |
| Validation task | Classification |
|---|---|
| one pair, fixed cap | NL-complete |
| one rooted row, fixed | ReachUL-complete (also on DAGs) |
| one rooted row or all pairs, polynomial total budget | in |
| all pairs, unary ( ) | in ; StrongFewL-hard |
| all pairs, binary threshold | PL-complete |
| Mechanism | Result | Guarantee |
|---|---|---|
| one-pass token table | Thm. 18 (i), Lemma 2 | exact table in gathers, work within of the output size |
| walk kernel | Thm. 18 (ii), Thm. 9 | the table’s row recomputed each step; memory = automaton + shared vocabulary |
| forced spans | Thm. 19 , Cor. 1 | same outputs, minimum passes among non-speculative decoders |
| canonical policy | Thm. 20 + Assumption 1 | committed tokens are the tokenizer’s split under every continuation |
| budget mask | Thm. 21 | valid under every feasible limit; least restrictive such mask |
| pushdown constraint | Thm. 22 ; the machine of Thm. 8 | exact up to nesting depth 64; table indexed by top two stack symbols |
| Qwen3.5-2B | Qwen3.5-4B | |||||||
|---|---|---|---|---|---|---|---|---|
| mode | tok/s | passes/tok | forced | ms/sampled | tok/s | passes/tok | forced | ms/sampled |
| free decoding | 138 | 1.01 | 0% | 7.2 | 63.2 | 1.01 | 0% | 15.7 |
| JSON schema, stcon | 180 | 0.69 | 31% | 8.0 | 82.3 | 0.69 | 31% | 17.6 |
| JSON schema, llguidance ff | 136 | 0.72 | 28% | 10.2 | 68.6 | 0.73 | 27% | 20.0 |
| recursive, stcon | 170 | 0.72 | 28% | 8.2 | 78.6 | 0.70 | 30% | 18.2 |
| recursive, llguidance ff | 143 | 0.71 | 29% | 9.9 | 67.4 | 0.72 | 28% | 20.6 |
| path | engine | tok/s | passes/tok | forced | output tokens | decode time | ms/sampled |
|---|---|---|---|---|---|---|---|
| regular | free decoding | 137 / 66 | 1.01 / 1.01 | 0 / 0% | 570 / 597 | 4.15 / 9.02 s | 7.2 / 15.0 |
| (6 schemas) | stcon | 173 / 85 | 0.69 / 0.69 | 31 / 31% | 327 / 329 | 1.89 / 3.89 s | 8.3 / 17.1 |
| llguidance, mask only | 103 / 55 | 1.00 / 1.00 | 0 / 0% | 343 / 333 | 3.34 / 6.08 s | 9.7 / 18.3 | |
| llguidance, fast-forward | 143 / 73 | 0.72 / 0.73 | 28 / 27% | 343 / 333 | 2.41 / 4.59 s | 9.8 / 18.8 | |
| recursive | free decoding | 135 / 67 | 1.01 / 1.00 | 0 / 0% | 592 / 845 | 4.39 / 12.57 s | 7.4 / 14.8 |
| (4 schemas) | stcon (pushdown) | 161 / 84 | 0.72 / 0.70 | 28 / 30% | 469 / 382 | 2.92 / 4.54 s | 8.7 / 17.0 |
| mode | valid | passes | forced tokens | ms / token |
|---|---|---|---|---|
| stcon pushdown, canonical policy | 11/15 | 1,452 | 921 | 5.9 |
| stcon pushdown, commit-all | 12/15 | 1,304 | 875 | 5.8 |
| llguidance | 12/15 | 2,204 | 0 | 9.4 |
| llguidance fast-forward | 12/15 | 1,309 | 895 | 7.0 |
| Qwen3.5-2B | Qwen3.5-4B | |||||
| schema | sequential | blocks | exact | sequential | blocks (waves + cert.) | exact |
| person | 84 | 33 | 3/3 | 84 | 33 (30 + 3) | 3/3 |
| tool_call | 35 | 17 | 3/3 | 35 | 20 (14 + 6) | 3/3 |
| product | 112 | 53 | 3/3 | 112 | 46 (40 + 6) | 3/3 |
| event | 169 | 96 | 3/3 | 167 | 109 (94 + 10) | 3/3 |
| classification | 126 | 112 | 3/3 | 142 | 159 (148 + 7) | 3/3 |
| Qwen3.5-2B | Qwen3.5-4B | ||||||
|---|---|---|---|---|---|---|---|
| streams | stock | mlx-lm on ours | stcon | vs stock | stock | stcon | vs stock |
| 1 | 127 | 140 | 142 | 61 | 64 | ||
| 2 | 172 | 251 | 259 | 82 | 116 | ||
| 4 | 186 | 341 | 339 | 87 | 160 | ||
| 8 | 188 | 575 | 576 | 87 | 271 | ||
| 16 | 342 | 751 | 758 | 157 | 341 | ||
| 16 agents | 8 agents | |||
|---|---|---|---|---|
| stock | stcon | stock | stcon | |
| wall time | 74.6 s | 29.3 s ( ) | 19.4 s | 22.1 s ( ) |
| throughput | 125.5 tok/s | 271.1 tok/s ( ) | 108.6 tok/s | 170.6 tok/s ( ) |
| agents finished | 9/16 | 12/16 | 5/8 | 6/8 |
| checks passed | 11/16 | 10/16 | 5/8 | 4/8 |
| cap | engine | pass@1 | tokens | tokens/s | wall | cut |
| 1,024, greedy | stcon , one stream | 8/40 | 28.2k | 63.4 | 481 s | 23 |
| mlx-lm, one stream | 11/40 | 27.6k | 62.3 | 499 s | 22 | |
| stcon , batch 8 | 9/40 | 27.4k | 160.4 | 171 s | 22 | |
| mlx-lm, batch 8 | 10/40 | 28.3k | 74.5 | 379 s | 23 | |
| 4,096, greedy | stcon , one stream | 9/40 | 96.0k | 59.1 | 1,667 s | 22 |
| mlx-lm, one stream | 14/40 | 87.2k | 61.1 | 1,482 s | 17 |
| cap | engine | divergent | median gap | max gap | float32: mlx-lm | float32: other |
|---|---|---|---|---|---|---|
| 4,096 | stcon , one stream, fp16 | 35 | 0.056 | 0.52 | 3 | 32 |
| stcon , batch 8, fp16 | 34 | 0.062 | 0.52 | 2 | 32 | |
| mlx-lm, batch 8 | 36 | 0.145 | 1.83 | 22 | 14 | |
| 1,024 | stcon , one stream, bf16 | 38 | 0.097 | 0.33 | 23 | 15 |
| model | dtype | top-1 agreement | mean KL | p99 KL | max KL | max |
|---|---|---|---|---|---|---|
| 4B | bfloat16 (mlx-lm) | 0.9965 | 5.60 | |||
| 4B | float16 ( stcon ) | 1.0000 | 0.31 | |||
| 2B | bfloat16 | 0.9965 | 0.71 | |||
| 2B | float16 | 1.0000 | 0.09 |
| tok/s, 2B | tok/s, 4B | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| grammar | states | table | table build | walk | kernel | table | walk | table | walk |
| person | 104 | 77 MB | 0.7 s | 2.9 MB | 12–14 s | 156 | 153 | 75 | 75 |
| tool_call | 164 | 122 MB | 1.0 s | 2.9 MB | 7–9 s | 263 | 256 | 124 | 121 |
| product | 192 | 143 MB | 1.3 s | 2.9 MB | 8–9 s | 191 | 189 | 90 | 89 |
| event | 178 | 133 MB | 1.3 s | 2.9 MB | 7–9 s | 168 | 161 | 80 | 78 |
| classification | 158 | 118 MB | 1.0 s | 2.9 MB | 7–9 s | 159 | 169 | 82 | 83 |
| grammar | states | full table | rows | row memory | tok/s full / warm / cold |
|---|---|---|---|---|---|
| person | 104 | 77 MB | 11 | 8 MB | 129 / 124 / 95 |
| tool_call | 164 | 122 MB | 9 | 7 MB | 224 / 210 / 159 |
| product | 192 | 143 MB | 21 | 16 MB | 154 / 158 / 133 |
| event | 178 | 133 MB | 17 | 13 MB | 138 / 136 / 106 |
| classification | 158 | 118 MB | 13 | 10 MB | 135 / 139 / 123 |
| contact_card | 246 | 183 MB | 16 | 12 MB | 147 / 150 / 114 |
| stcon token table | stcon walk kernel | llguidance | |
|---|---|---|---|
| person schema (104 states) | 77 MB | 0.05 MB | 0.5 MB |
| 96 fields (1,970 states) | 1.5 GB | 1.0 MB | 0.5 MB |
| typed tool calls (1,106 states) | 824 MB | 0.57 MB | does not compile |
| recursive schema (solar) | 38 MB (pushdown tables) | — | 0.5 MB |
| 16-grammar server, grammars | 7.2 GB (dies at the 15th) | 4.9 MB | 4.7 MB |
| shared, once per process | — | 2.9 MB | 153 MB |
| model, prompt cache | constraints | served | above the model | longest first request |
|---|---|---|---|---|
| 2B, 50 MB | token tables | 15/16, then out of memory | 8.2 GB | 26 s |
| 2B, 50 MB | walk kernel | 16/16 | 0.6 GB | 2.8 s |
| 2B, 1.5 GB | token tables | 14/16, then out of memory | 7.6 GB | 20 s |
| 2B, 1.5 GB | walk kernel | 16/16 | 2.2 GB | 3.1 s |
| 4B, 50 MB | token tables | 14/16, then out of memory | 6.9 GB | 26 s |
| 4B, 50 MB | walk kernel | 16/16 | 1.1 GB | 6.6 s |
| stcon | stock mlx-lm | |||
|---|---|---|---|---|
| streams tokens | above the model | tok/s | above the model | tok/s |
| 1.0 GB | 65 | 0.8 GB | 60 | |
| (prefill only) | 6.4 GB | 3.8 GB | ||
| 6.4 GB | 175 | 3.7 GB | 82 | |
| 6.4 GB | 212 | 5.2 GB | 84 | |
| 4.9 GB | 93 | 5.9 GB | 64 | |
| 2048 | 1024 | 512 | 256 | 128 | |
|---|---|---|---|---|---|
| one stream, 1,360 tokens | 1.41 GB | 1.46 GB | 1.23 GB | 1.09 GB | 1.19 GB |
| batch of 2 | 2.12 GB | 1.36 GB | |||
| batch of 4 | 3.50 GB | 1.59 GB | |||
| batch of 8 | 6.48 GB | 2.43 GB |
| schema | full answer | first valid | feasible | valid, mask | valid, no mask | |
|---|---|---|---|---|---|---|
| person | 34 | 16 | 16 | 10 | 10 | 1 |
| tool_call | 29 | 25 | 26 | 2 | 2 | 0 |
| product | 57 | 37 | 38 | 10 | 10 | 0 |
| event | 75 | 18 | 18 | 29 | 29 | 0 |
| classification | 58 | 22 | 22 | 19 | 19 | 1 |
| contact_card | 74 | 35 | 36 | 20 | 20 | 1 |
| budget | output (Qwen3.5-2B, the event schema) |
|---|---|
| 320 (75 used) | {"title":"The Applied AI Summit","date":"2026-11-12","location":{"venue":"Congress Center","city":"Berlin","country":"Germany"},"attendees":[{"name":"Dr. Aiko Tanaka","role":"speaker"},{"name":"Lars Petersen","role":"speaker"},{"name":"Nina Weber","role":"organizer"}]} |
| 48 | {"title":"The Applied AI Summit","date":"2026-11-12","location":{"venue":"Congress Center","city":"Berlin","country":"Germany"},"attendees":[{"name":"Dr.","role":"speaker"}]} |
| 32 | {"title":"The Applied AI Summit","date":"2026-11-","location":{"venue":"","city":"","country":""},"attendees":[]} |
| 24 | {"title":"The Applied AI Summit","date":"","location":{"venue":"","city":"","country":""},"attendees":[]} |
| 40, no mask | {"title":"The Applied AI Summit","date":"2026-11-12","location":{"venue":"Congress Center","city":"Berlin","country":"Germany"},"attendees":[{"name":" (cut mid-value, invalid) |
| engine (2B / 4B) | person | tool_call | product | event | contact_card | all |
|---|---|---|---|---|---|---|
| free, stcon , llguidance (all modes) | 8 / 8 | 5 / 5 | 11 / 11 | 12 / 12 | 9 / 9 | 45 / 45 |
| idea | measurement |
|---|---|
| defer the recurrent-state writes (a log of updates) | removing the state store saves 2.3% of a step at batch 1, 6.7% at 16–32; not built |
| a certified low-rank vocabulary head | the head’s spectrum is flat: rank 1,024 of 2,048 rules out under 2% of rows; not built |
| fuse the norms, residual adds and SwiGLU | 2–10% of a pipelined step; each costs 1–2 s |
| score few-choice regions as a tree in one pass | forced spans already absorb them: 0–4% fewer passes, no wall-time change |
| finite regions (sequence-level decision of a label among 16) | 2.0 passes against 2.9, but the intended label on 7 of 24 tickets against 15 for token-level greedy: the most probable complete string is the short generic label |
| decode sibling subtrees of a recursive array in parallel | slower on every task (Table 35 ); branches invent what their siblings decide |
| task | sequential pushdown | sibling-parallel |
|---|---|---|
| solar | 0.84 s, 109 tok/s, 11 nodes | 2.02 s, 66 tok/s, 13 nodes (Venus given Earth’s subtree) |
| thread | 2.67 s, 143 tok/s | 2.67 s, 71 tok/s (a reply duplicated) |
| fs | 0.85 s, 122 tok/s | 4.03 s, 82 tok/s |
| cats | 0.55 s, 76 tok/s | 2.00 s, 55 tok/s |
| org | 0.32 s, 79 tok/s | 2.09 s, 89 tok/s |
| menu | 0.39 s, 104 tok/s | 35 s, 1,168 invented nodes |