alphaFeedback

WorksComputer Science

DConstrain: Compiling Context-Parameterized Transitions for Diffusion Language Model Constrained Decoding

AI contributions
Not recorded for this paper
View details

Abstract

Diffusion language models (DLMs) decode multiple tokens in parallel, so individually valid tokens can be incompatible together under a schema. Exact joint inference over a grammar graph enforces compatibility, but it requires token-labeled successors across many hypothetical parser configurations. Encoding stacks and field histories in compiled states can cause exponential growth, which forces prior exact decoders to fix property orders and exclude valid outputs. We present DConstrain, which compiles schemas into context-parameterized transition programs. Cold compilation specializes token consumption to local grammar states while retaining context-dependent stack operations, environment guards, and caller-dependent deferred parsing symbolically. Tracking field histories as runtime values supports arbitrary property order without enumerating field subsets offline. At runtime, warm compilation binds reached configurations to these programs to construct exact successors, overlapping with the model forward pass because graph construction requires no model scores. Furthermore, token-effect grouping merges tokens with identical compiled effects before runtime contexts are bound, so groups are reused across stacks and environments even when concrete successors differ. Objective-specific score aggregation and token restoration provably preserve both the Viterbi optimum and the token-labeled path distribution of ungrouped inference. Across three benchmarks and two DLM families, DConstrain compiles 100% of BFCL schemas under arbitrary property orders, whereas an optimized finite-state baseline compiles only 71.30-85.81%. Under arbitrary property order, it reduces BFCL end-to-end decoding latency by 6.65-46.26 times with 100% schema validity and raises DiffusionGemma's BFCL accuracy from 37.27% under fixed order to 81.56%.

Introduction

Diffusion language models (DLMs) generate text by iteratively denoising multiple tokens in parallel ([2, 19, 27, 22, 36]). Parallel decoding reduces latency and makes DLMs attractive for agentic tasks such as tool calling ([28 Qin et al.] 2024), API interaction, and structured data extraction. These tasks require outputs that strictly follow a schema ([24, 11]), yet unconstrained DLMs often violate schema rules ([30, 5]). In autoregressive (AR) models, schema compliance is enforced by masking invalid next tokens for a fixed left-to-right prefix ([33, 20, 7]). This mechanism does not carry over directly to DLMs. Because a DLM fills several masked positions at once, two tokens that are each valid on their own can be invalid together.

Existing DLM constrained decoders follow two main paradigms. Verification-based methods sample masked positions independently and then check whether the proposed output can still be completed ([21, 37, 14]). Because independent proposals ignore dependencies among positions, decoding many tokens at once causes frequent conflicts and requires repeated resampling or heuristic fallbacks under finite budgets ([21, 14]). Conversely, automata-based methods enforce compatibility through joint inference ([30, 5, 31]). For the active denoising window (the canvas), they propagate the grammar position by position into a canvas-specific grammar graph whose paths represent sequences of mutually compatible tokens. The decoder then identifies the highest-scoring path or samples according to the graph’s path weights. However, these inference algorithms assume a finite automaton with readily accessible token transitions, leaving the cost of constructing this representation for complex schemas largely unaddressed.

This bottleneck arises because DLM joint inference requires a richer successor-construction interface than AR decoding. An AR decoder only needs a boolean mask of valid next tokens for a single realized prefix ([7]). In contrast, joint inference must compute the exact successor parser configurations for candidate tokens across many hypothetical configurations before any token is committed. Each configuration consists of a local grammar state (a position inside one grammar rule) and a runtime context (a stack of return points and a parsing environment, such as the set of fields already written). Finite-state methods encode runtime contexts as separate automaton states, and DINGO additionally precomputes transitions across the full vocabulary ([30]). In real schemas, nested objects multiply possible stack contexts, while unordered properties introduce exponentially many field histories. Even context-free grammars (CFGs) can require exponential size to represent all permutations of distinct fields ([9]). To keep compiled automata tractable, prior exact decoders restrict schemas to a fixed property order ([30, 5, 31]), excluding valid JSON outputs that the model may prefer.

Our key observation is that context-specific successors need not be compiled as context-specific transitions. Consider a token containing two closing braces, }}, in a nested JSON object. After the first brace closes the inner object, parsing the remaining brace requires returning to the caller. If the parent still lacks a required field, the token is rejected; otherwise, it may close the parent. The return point depends on the stack, and field completion depends on the parsing environment. These contexts can share one compiled procedure: check field completion, return to the caller, and resume parsing the remaining bytes. Rather than precomputing successors for every combination of stack and field history, we compile how to compute them with the runtime context left as a parameter. This separation allows exact successors to be constructed at runtime without enumerating all possible contexts during compilation.

Building on this insight, we propose DConstrain, which compiles schemas into context-parameterized transition programs (Figure 1). Cold compilation specializes token consumption to local grammar states: it precomputes byte-level parsing and local transitions wherever inputs are known, and retains context-dependent stack operations, environment guards, and deferred parsing symbolically. Tracking field histories as runtime values supports arbitrary property order without enumerating field subsets offline. At runtime, warm compilation instantiates these programs for configurations reachable in the current canvas, resolves context-dependent operations, and constructs the exact successor relations required for joint inference. Since warm graph construction does not require model scores, it overlaps with the model forward pass. Finally, token-effect grouping identifies equivalent compiled token effects during cold compilation, before runtime contexts are bound. The resulting groups can be reused across different stacks and environments, sharing successor computation even when the concrete successors differ across contexts. Objective-specific score aggregation and token restoration preserve the exact Viterbi optimum and token-labeled path distribution.

Overview of DConstrain on a nested-object schema

Figure 1. Overview of DConstrain on a nested-object schema with required properties aa and bb sharing the same Pet rule. Top: A finite-state pipeline such as DINGO encodes the grammar position and runtime context together in each state and precomputes transitions across the full vocabulary. States c1c_1 and c2c_2 share the local position qoq_o but carry their own stacks and field histories. The token }} is rejected from c1c_1, whose parent still requires bb, but closes both objects from c2c_2. Bottom: Cold compilation takes a local grammar position qq and token vv, leaving (s,e)(s,e) unbound, and produces context-parameterized program sets. The local-position legend identifies qtq_t as the string body and qoq_o as the child-object close. Tokens with identical canonical effects at each position form compile-time groups. For }}, the shared program set E2\mathcal{E}_2 defers parsing the second brace until the caller is known. Warm compilation binds the concrete stack and environment, returning an empty successor set for c1c_1 and an accepting configuration for c2c_2. Right: Joint inference uses group-level edges with sum or max score aggregation before restoring concrete tokens. Timeline: Cold compilation runs once offline. Warm compilation overlaps with the first forward pass of each canvas, and grammar propagation overlaps with every forward pass before the inference solve. DINGO runs grammar propagation and solve sequentially after each forward pass. Graphs and block lengths are schematic.

Our contributions are summarized as follows:

  • Successor-Construction Bottleneck. We identify token-labeled successor construction as the primary scalability bottleneck in automata-based DLM decoding. Materializing context-specific transitions incurs combinatorial growth with nesting and field histories. Even CFGs can require exponential size for arbitrary permutations of distinct fields, motivating fixed property orders in prior exact decoders.

  • Context-Parameterized Compilation. We introduce context-parameterized transition programs paired with a two-stage compiler and compile-time token-effect grouping. We prove that program execution preserves the reference successor relation and that grouping preserves both the Viterbi optimum and the full token-labeled path distribution of ungrouped inference. The compiled programs can be reused by any constrained-decoding algorithm that consumes token-labeled grammar successors.

  • Exact Unordered Decoding. Across three structured-output benchmarks and multiple DLM tokenizers, DConstrain substantially improves compilation coverage and latency under arbitrary property order. On BFCL, exact unordered constraints also improve task accuracy over both fixed-order constraints and unconstrained decoding.

Related Work

Autoregressive Constrained Decoding. Grammar-constrained decoding is widely used to guarantee structured outputs in autoregressive LLMs. At each step, the decoder masks invalid tokens for the realized prefix and advances the parser with the selected token. Early methods introduced incremental parsing and semantic constraints for structured NLP tasks ([29, 25, 10]). Subsequent work corrected the distributional distortion of token-level masking through adaptive sampling ([23]). Later systems focused on efficient tokenizer-aware mask generation ([33, 3, 15, 20, 7]), and XGrammar 2 added JIT compilation with cross-grammar cache reuse ([17]). Our compiler design is closest to two of these systems. XGrammar ([7]) precomputes stack-independent valid tokens at each grammar position and checks only the remaining tokens at runtime. Koo et al. [15] compose a detokenizing transducer with a pushdown automaton so that each token transition carries explicit stack operations. DConstrain also compiles context-independent work once, but it targets a different successor-construction interface. A validity mask only identifies admissible next tokens for a single prefix. In contrast, DLM joint inference requires the full transition map (c,v)↦TG(c,v)(c,v) \mapsto T_G(c,v) across many hypothetical configurations before any token is committed. DConstrain further keeps the written-field history as a runtime parameter, which no compact grammar can encode (Proposition 3.2).

DLM Constrained Decoding. Early diffusion language models supported soft control by steering continuous latents with classifier gradients ([18]), but soft guidance cannot guarantee valid syntax. Decoders for hard constraints fall into two families. The first family consists of verification-based decoders, which sample candidate tokens independently and resample or recover when a grammar check fails. Constrained Diffusion ([21]) checks whether the partial output can still be completed. LAVE ([37]) validates each proposed token against sampled lookahead completions. EPIC ([14]) accelerates completion checks with memoized lexing and Earley-style parsing ([8]) to commit verified token batches in parallel. Although these decoders avoid finite-state materialization, a feasibility check only ensures that some valid continuation exists. At each step, it recovers neither the highest-scoring joint assignment nor an exact sample from the constrained distribution. In our BFCL experiments, LAVE-Opt and EPIC-Opt have lower completion rates and throughput than DConstrain (Table 2 and Table 3).

Schema-order
Method\multicolumn{7}{c}{DiffusionGemma}\multicolumn{7}{c}{LLaDA2.2}
NNCold (%)Run (%)Valid. (%)TPFAcc. (%)TPSOverhead (%) ↓NNCold (%)Run (%)Valid. (%)TPFAcc. (%)TPSOverhead (%) ↓
Native-Opt2495—100.0089.508.0476.39165.140.02495—100.0094.877.4080.80752.250.0
Verification-based
LAVE-Opt2272100.0091.0691.066.0536.71 ↓39.686.002652.32480100.0099.4099.404.6772.55 ↓8.25221.51239.6
EPIC-Opt2024100.0081.1280.922.9436.63 ↓39.763.434714.6246398.8898.7298.725.6263.41 ↓17.3924.802933.3
Automata-based
DINGO-Opt2495100.00100.00100.008.1137.19 ↓39.2023.13614.02495100.00100.00100.006.8672.63 ↓8.17101.32642.4
DConstrain2495100.00100.00100.008.1337.27 ↓39.12130.47 5.64×26.6 23.10×2495100.00100.00100.006.8972.71 ↓8.09437.94 4.32×71.8 8.95×
Any-order
Method\multicolumn{7}{c}{DiffusionGemma}\multicolumn{7}{c}{LLaDA2.2}
NNCold (%)Run (%)Valid. (%)TPFAcc. (%)TPSOverhead (%) ↓NNCold (%)Run (%)Valid. (%)TPFAcc. (%)TPSOverhead (%) ↓
Native-Opt2495—100.0090.348.1476.55167.900.02495—100.0094.957.2180.68736.380.0
Verification-based
LAVE-Opt240897.0796.5196.477.7179.20 ↑2.659.501667.4242097.0796.9996.995.7479.24 ↓1.44313.71134.7
EPIC-Opt221292.3888.6688.187.4474.71 ↓1.846.282573.6215186.4186.2186.216.0965.05 ↓15.6337.351871.6
Automata-based
DINGO-Opt214185.8185.8185.818.1369.85 ↓6.702.965572.3177971.3071.3071.308.1159.30 ↓21.3842.391637.2
DConstrain2495100.00100.00100.008.1581.56 ↑5.01103.82 35.07×61.7 90.28×2495100.00100.00100.008.1081.60 ↑0.92386.70 9.12×90.4 18.10×

Table 2. BFCL outcomes over all 2,495 cases, reported separately for Schema-order and Any-order. NN counts each method’s runtime completions. Cold admission, runtime completion (Run), strict-schema validity (Valid.), and official semantic accuracy (Acc.) use 2,495 as the denominator; TPS and TPF use each row’s NN completed cases. Bold marks the best values within each model and order panel, including ties, and highlights DConstrain overhead. Acc. subscripts show percentage-point changes from Native-Opt: ↑ indicates an increase and ↓ a decrease. Overhead is (TPSNative-Opt/TPS−1)×100%(\mathrm{TPS}_{\mathrm{Native\text{-}Opt}}/\mathrm{TPS}-1)\times100\%. DConstrain TPS and Overhead subscripts give throughput speedups and overhead-reduction factors over DINGO-Opt in the same panel, respectively. Table 6 reports the paired latency comparison. Schema-order fixes property order; Any-order permits arbitrary order. For Native-Opt, these identify prompt conditions. TPS is model tokens/s; TPF counts non-stop model token IDs per generation forward, excluding CPU completion text. TPS timing excludes prefill for LLaDA2.2 and includes it for DiffusionGemma. The -Opt suffix denotes our implementation optimizations and decoding adaptations for the baselines.

DiffusionGemma (N=1,874N = 1{,}874)LLaDA2.2 (N=2,448N = 2{,}448)
MethodValid. (%)TPFAcc. (%)TPSOverhead (%) ↓Valid. (%)TPFAcc. (%)TPSOverhead (%) ↓
Native-Opt89.707.0778.50145.710.094.977.4281.04754.400.0
Verification-based
LAVE-Opt100.005.8948.19 ↓30.316.762055.5100.004.6772.74 ↓8.30221.32240.9
EPIC-Opt99.733.1948.72 ↓29.783.813724.4100.005.6364.65 ↓16.3925.002917.6
Automata-based
DINGO-Opt100.007.1348.88 ↓29.6221.48578.4100.006.9572.99 ↓8.0593.03710.9
DConstrain100.007.1348.88 ↓29.62115.10 5.36×26.6 21.75×100.006.9572.99 ↓8.05443.47 4.77×70.1 10.14×
Any-order
DiffusionGemma (N=2,201N = 2{,}201)LLaDA2.2 (N=2,149N = 2{,}149)
MethodValid. (%)TPFAcc. (%)TPSOverhead (%) ↓Valid. (%)TPFAcc. (%)TPSOverhead (%) ↓
Native-Opt91.467.8179.46165.630.095.537.4182.78756.590.0
Verification-based
LAVE-Opt100.007.4383.55 ↑4.099.921569.7100.005.7582.60 ↓0.18315.63139.7
EPIC-Opt99.457.5184.55 ↑5.096.302529.0100.006.0975.48 ↓7.3037.341926.2
Automata-based
DConstrain100.007.8184.87 ↑5.41110.5049.9100.008.2283.15 ↑0.37490.9854.1

Table 3. BFCL quality and throughput on common runtime-success cohorts, defined separately for each model and property-order condition. Within each panel, we intersect the successful-run sets of Native-Opt, LAVE-Opt, EPIC-Opt, and DConstrain. Schema-invalid completions are retained. Bold marks the best values within each model and order panel, including ties, and highlights DConstrain overhead. Acc. subscripts show percentage-point changes from Native-Opt: ↑ indicates an increase and ↓ a decrease. Overhead is (TPSNative-Opt_{\mathrm{Native\text{-}Opt}}/TPS − 1) × 100%. Under Schema-order, DConstrain TPS and Overhead subscripts give throughput speedups and overhead-reduction factors over DINGO-Opt, respectively. The Any-order comparison with DINGO-Opt appears in Table 6. TPS/TPF accounting follows Table 2. The -Opt suffix denotes our implementation optimizations and decoding adaptations for the baselines.

The second family consists of automata-based methods, which couple token choices through joint inference over finite automata ([30, 5, 31]). DINGO ([30]) builds a DFA and precomputes vocabulary-level token transitions. Dang & Ermon [5] perform chain and tree inference over a finite automaton whose edges group tokens and sum their probabilities. Building on such step-exact samplers, Thimmaiah et al. [31] use twisted sequential Monte Carlo to correct trajectory bias across denoising steps. However, all three methods compile JSON schemas under a fixed property order to keep the automaton finite and small. Interpreting a pushdown automaton directly at runtime would avoid materializing context-specific states, but it would repeatedly execute token-consumption logic for every reached configuration. DConstrain resolves this tension by compiling reusable local grammar–token programs while leaving the runtime context unbound. Within this framework, our token-effect grouping generalizes the edge-level aggregation of Dang & Ermon [5] to parameterized transitions. As a result, a single token partition per local grammar state serves every runtime context.

Preliminaries

A JSON schema G\mathcal{G} (Wright et al., [35]) defines a grammar whose rules can nest. For example, an object property can itself hold an object. We therefore parse G\mathcal{G} with a pushdown parser (Hopcroft et al., [13]), where each grammar rule is represented as a small automaton and entering a nested rule pushes a return point onto a stack. At any point, the parser state is captured by a configuration c=(q,s,e)c=(q,s,e). Here qq is the local grammar state, which marks a node inside the current rule’s automaton. The stack ss holds pending return points, and the parsing environment ee records earlier parsing choices, such as which object fields have already been written. Together, (s,e)(s,e) form the runtime context of cc. Given a configuration cc and a vocabulary token v∈Vv\in\mathcal{V}, the token-transition relation TG(c,v)T_{\mathcal{G}}(c,v) returns the set of valid successor configurations c′c' after consuming vv. This set omits statically certified dead configurations that can never lead to a complete valid output (see Appendix § 7.§ 1 for formal parser semantics).

Automata-Based DLM Constrained Decoding. Automata-based methods apply TGT_{\mathcal{G}} across an active decoding window to coordinate token choices at multiple unresolved positions (Suresh et al., [30]; Dang & Ermon, [5]). Consider a denoising iteration tt and its canvas of HH token positions. Let Vit⊆V\mathcal{V}_i^t\subseteq\mathcal{V} denote the candidate tokens at position ii; a position that is already fixed has a singleton candidate set. Starting from the parser configurations C0\mathcal{C}_0 compatible with the fixed prefix uu, the token-labeled transitions and reachable configurations at each position are defined recursively as

Ei={(c,v,c′)∣c∈Ci−1, v∈Vit, c′∈TG(c,v)},E_i=\left\{(c,v,c')\mid c\in\mathcal{C}_{i-1},\ v\in\mathcal{V}_i^t,\ c'\in T_{\mathcal{G}}(c,v)\right\},
Ci={c′∣∃c,v:(c,v,c′)∈Ei},i=1,…,H.(1)\mathcal{C}_i=\left\{c'\mid\exists c,v:(c,v,c')\in E_i\right\},\qquad i=1,\ldots,H. \tag*{(1)}

The position-indexed layers {Ci}i=0H\{\mathcal{C}_i\}_{i=0}^{H} and transitions {Ei}i=1H\{E_i\}_{i=1}^{H} form a layered canvas-specific grammar graph Ft\mathcal{F}_t. A full-window path through Ft\mathcal{F}_t is admissible if its terminal configuration satisfies the required acceptance or continuation condition.

Each denoising iteration constructs and resolves Ft\mathcal{F}_t in two stages. First, grammar propagation builds the graph layers from left to right: starting from C0\mathcal{C}_0, it advances every reached configuration with every candidate token to collect its successors. Notably, propagation depends only on parser configurations and candidate sets, not on model scores. Second, joint inference weights each edge (c,v,c′)∈Ei(c,v,c')\in E_i using the token probability pi(v)p_i(v) from the DLM predictions PtP_t (defined in Appendix § 7.§ 2). Max-product dynamic programming then extracts a highest-weight admissible path via the Viterbi algorithm (Viterbi, [32]), while sum-product computes path-weight sums for exact probabilistic sampling (Goodman, [12]; Dang & Ermon, [5]).

Problem Formulation. All automata-based decoders share this two-stage pipeline, and their efficiency hinges on how grammar propagation answers each successor query TG(c,v)T_{\mathcal{G}}(c,v). In AR constrained decoding, each forward pass predicts a single position for a fixed prefix. The decoder only needs a boolean mask of valid next tokens, after which it samples one token vv and advances the parser once (Dong et al., [7]). In contrast, a DLM leaves many positions unresolved at once, and each position can be reached by many hypothetical parser configurations. Before committing any token, grammar propagation must return exact successor sets rather than boolean masks, and it must evaluate every candidate token at every reached configuration. Without query reuse or token grouping, exhaustive propagation requires

Nquerynaive=∑i=1H∣Ci−1∣∣Vit∣(2)N_{\mathrm{query}}^{\mathrm{naive}}=\sum_{i=1}^{H}|C_{i-1}||V_i^t| \tag*{(2)}

configuration–token queries per canvas.

To avoid expensive online parsing during propagation, finite-state pipelines such as DINGO ([30]) precompute token-level transitions offline during cold compilation. Given a materialized finite state space QGQ_{\mathcal{G}}, a dense transition table stores an entry for each of the ∣QG∣∣V∣|Q_{\mathcal{G}}||V| state–token pairs, turning each online query into a table lookup. However, flattening runtime contexts into explicit finite states duplicates shared grammar logic and precomputes transitions for contexts that a canvas may never reach. The following propositions quantify this state explosion.

Proposition 3.1 (Context expansion; Appendix § 7.§ 5). Let QlocQ_{\mathrm{loc}} be the set of local grammar states, g>1g>1 the number of continuation-frame symbols, dmax⁡d_{\max} the stack-depth bound, and BB the maximum number of environment values per local-state–stack pair. A context-expanded state space contains

Sdmax⁡≤∣Qloc∣B∑ℓ=0dmax⁡gℓ=O(∣Qloc∣Bgdmax⁡)(3)S_{d_{\max}}\leq|Q_{\mathrm{loc}}|B\sum_{\ell=0}^{d_{\max}}g^\ell=O\left(|Q_{\mathrm{loc}}|Bg^{d_{\max}}\right) \tag*{(3)}

states. In particular, for bounded-depth brackets of gg types, a minimal complete DFA requires 1+∑ℓ=0dmax⁡gℓ=Θ(gdmax⁡)1+\sum_{\ell=0}^{d_{\max}}g^\ell=\Theta(g^{d_{\max}}) states. A dense context-expanded transition table therefore stores Sdmax⁡∣V∣S_{d_{\max}}|V| entries, whereas a factorized compiler stores at most ∣Qloc∣∣V∣|Q_{\mathrm{loc}}||V| local-state–token entries.

Proof sketch. Each context-expanded state pairs a local state with a stack of depth at most dmax⁡d_{\max} over gg frame symbols and one environment value; counting these triples yields Eq. (3). For bounded-depth brackets, any two distinct stacks of open brackets require distinct closing sequences. By the Myhill–Nerode theorem ([13]), a minimal complete DFA must assign a separate state to every valid stack plus one sink state, which bounds the number of table entries required.

Proposition 3.1 leaves the environment factor BB abstract. When a schema includes unordered object properties, BB itself grows exponentially, and replacing finite automata with context-free grammars does not avoid this blow-up.

Proposition 3.2 (Unordered properties; Appendix § 7.§ 5). For every k≥1k\geq1, there exists an object schema with kk required unordered properties such that every DFA accepting its valid serializations has at least 2k2^k states, and every context-free grammar generating them has size 2Ω(k)2^{\Omega(k)}. A factorized compiler instead requires only O(k)O(k) local grammar states for this object and tracks its field history in a kk-bit runtime environment value.

Proof sketch. Any two prefixes that have written different subsets of required fields admit different sets of valid completions, so the Myhill–Nerode theorem separates all 2k2^k subsets. For the CFG bound, intersecting the schema language with a regular language that fixes field values and counts, and then projecting onto property names, yields the language of all permutations of kk distinct symbols. Every CFG generating this permutation language has size 2Ω(k)2^{\Omega(k)} ([9]). Because regular intersection and homomorphic projection increase CFG size by at most a polynomial factor, the original grammar must also have size 2Ω(k)2^{\Omega(k)}.

Propositions 3.1 and 3.2 bound the size of static finite-state and CFG representations rather than the runtime cost of parsing a single string. For offline finite-state compilers, however, representation size directly dictates compilation cost, which explains the sharp growth with nesting depth and property count observed in § 5.3.

To overcome this bottleneck, we seek a compiled artifact AGA_{\mathcal{G}} containing executable successor-construction procedures, with the runtime context supplied at query time. These procedures must implement the exact successor-construction interface

Succ⁡(AG,c,v)=TG(c,v)(4)\operatorname{Succ}(A_{\mathcal{G}},c,v)=T_{\mathcal{G}}(c,v) \tag*{(4)}

for every configuration–token pair queried during grammar propagation. Our goal is to minimize cold-compilation cost, compiled storage, and online query latency without materializing the exponentially large context-expanded state space.

DConstrain

DConstrain compiles schemas into context-parameterized transition programs (Figure 1). These programs implement the successor interface in Eq. (4), independently of the downstream constrained-decoding algorithm. Cold compilation specializes token consumption to local grammar states while leaving the runtime context unbound and retaining context-dependent operations symbolically (§ 4.1). Warm compilation executes these programs for reached configurations to construct exact successors (§ 4.2). Token-effect grouping partitions tokens by their canonical compiled effects during cold compilation and reuses these partitions during warm compilation (§ 4.3). Appendices § 7.§ 3 and A.5 provide correctness and complexity analyses.

Context-Parameterized Transition Compilation

Given a target schema G\mathcal{G}, DConstrain represents local grammar rules as a recursive transition network (RTN) ([34]), keeping the call stack ss and parsing environment ee outside the RTN as runtime context. Specifically, we decompose the environment as e=(d,η)e=(d,\eta), where dd tracks the active container depth and η\eta tracks the choice environment (such as the written-field history), giving the full configuration c=(q,s,d,η)c=(q,s,d,\eta). Cold compilation specializes token consumption to each local grammar state and token pair (q,v)(q,v) while leaving (s,d,η)(s,d,\eta) unbound:

(q,v)→ColdCompile⁡E(q,v)={Pk}k=1Kq,v.(5)(q,v) \xrightarrow{\operatorname{ColdCompile}} \mathcal{E}(q,v)=\{P_k\}_{k=1}^{K_{q,v}}. \tag*{(5)}

Each program Pk=(Ik,1;…;Ik,ℓk)P_k=(I_{k,1};\ldots;I_{k,\ell_k}) is an ordered symbolic execution alternative for consuming vv from qq. Its guards may reject a concrete runtime context, and its continuation may depend on a caller selected by the incoming stack. Cold compilation evaluates byte matching and local grammar operations wherever their inputs are known, retaining context-dependent operations and the input and execution state needed to resume deferred parsing. The resulting programs take two forms: residual programs with a deferred caller-dependent continuation, and compact summaries with a statically determined target state.

When token consumption or token-boundary processing must pop a return frame from the incoming stack, the caller needed to continue parsing is unknown during cold compilation. The compiler resolves pushes and pops whose return destinations can be determined locally. At the first return that requires the incoming stack, it records a residual program with the remaining token input and the current symbolic execution state. Warm compilation uses the concrete stack to resume the caller-dependent continuation. A shared program can therefore compute exact successors even when its final local state cannot be determined offline.

When a program does not require a caller from the incoming stack ss, symbolic execution reduces it to a compact summary P=(q′,ρ,Δ,m,Ω)P=(q',\rho,\Delta,m,\Omega). Here q′q' is the resulting local grammar state, and ρ\rho is the sequence of new return frames pushed (and not yet popped) while consuming vv. The integers Δ\Delta and mm record the net change and minimum intermediate change in container depth dd. Finally, Ω\Omega is an ordered sequence of environment guards and updates on η\eta, such as verifying that field a has not yet appeared and recording its presence. During warm compilation, binding a summary PP to a concrete runtime context (s,d,η)(s,d,\eta) evaluates directly to

Bind⁡(P;s,d,η)={{(q′,s∥ρ,d+Δ,Ω(η))},d+m≥0, Ω(η)≠⊥,∅,otherwise.(6)\operatorname{Bind}(P;s,d,\eta)= \begin{cases} \{(q',s\mathbin{\|}\rho,d+\Delta,\Omega(\eta))\}, & d+m\ge0,\ \Omega(\eta)\ne\perp,\\ \varnothing, & \text{otherwise}. \end{cases} \tag*{(6)}

where ∥\mathbin{\|} appends frames to the stack and ⊥\perp indicates a violated guard (see Appendix § 7.§ 3 for the full specification with auxiliary metadata). For these summaries, binding evaluates the remaining guards and updates under (s,d,η)(s,d,\eta) and constructs the successor without recompiling grammar logic for that context. Together, summaries and residuals allow configurations with the same local state qq to reuse E(q,v)\mathcal{E}(q,v) even when their successors differ.

The choice environment is likewise handled through guarded runtime operations. For an object with kk fields under arbitrary property order, η\eta stores the set of written fields as a runtime bitmask, while the compiled operator Ω\Omega encodes the guards for field uniqueness and required-field completion. A single program set E(q,v)\mathcal{E}(q,v) is shared across the 2k2^k possible field histories, so cold compilation does not enumerate those subsets as local grammar states. Concrete histories remain runtime values, and program execution preserves the order and scope of their guards and updates.

Warm Compilation

Warm compilation executes the remaining operations of a compiled program under a concrete runtime context. We first specify its token-level successor interface: for a reached configuration c=(q,s,e)∈Ci−1c=(q,s,e)\in C_{i-1} and a candidate token v∈Viv\in\mathcal{V}_i at position ii, it returns

T^G(c,v)=⋃P∈E(q,v)Exec⁡(P,c).(7)\widehat{T}_{\mathcal{G}}(c,v)=\bigcup_{P\in\mathcal{E}(q,v)}\operatorname{Exec}(P,c). \tag*{(7)}

Here Exec⁡(P,c)\operatorname{Exec}(P,c) applies Eq. (6) to ordinary summaries, resumes residual programs under the concrete caller, and completes token-boundary processing. Failed guards contribute no successor. The resulting context-specific successors drive the layer-by-layer propagation in Eq. (1). The implementation evaluates this interface through the compile-time partitions introduced in § 4.3, using one representative token per reached configuration and active group. Transitions for unreachable contexts are never instantiated.

The following theorem establishes that the two-stage compiler and program execution preserve the reference successor relation, including caller-dependent continuations.

Theorem 4.1 (Exact successor construction; Appendix § 7.§ 3). For every reached configuration cc and candidate token vv, warm compilation returns

T^G(c,v)=TG(c,v)(8)\widehat{T}_{G}(c,v)=T_{G}(c,v) \tag*{(8)}

under the reference parser semantics. Consequently, running grammar propagation with T^G\widehat{T}_{G} reproduces the exact layers {Ci}\{C_i\} and transitions {Ei}\{E_i\} of Eq. (1) from the same initial set C0C_0 and candidate sets {Vit}\{V_i^t\}. Under the same acceptance or continuation condition, both graphs admit the exact same token-labeled window language.

Token-Effect Grouping

Parameterized programs share transition logic across runtime contexts, but evaluating candidate tokens separately at each reached configuration retains the vocabulary factor in Eq. (2). We extend token aggregation in finite-state inference ([5]) to context-parameterized programs: during cold compilation, tokens are grouped by their canonical compiled effects at each local state, before any concrete stack or environment is bound. For an unconstrained string rule, for example, many text tokens compile to the same continuation program (Figure 1). We define the grouping relation at local state qq by

v1∼qv2⟺Canon⁡(E(q,v1))=Canon⁡(E(q,v2)).(9)v_1 \sim_q v_2 \Longleftrightarrow\operatorname{Canon}(\mathcal{E}(q,v_1))=\operatorname{Canon}(\mathcal{E}(q,v_2)). \tag*{(9)}

Cold compilation records the partition Πq=V/∼q\Pi_q=\mathcal{V}/\sim_q. Canonicalization retains instruction order, operands, stack and environment operations, and execution-relevant boundary and residual metadata. Canonical equality is a sufficient, not necessary, condition for identical successor sets under every admissible runtime context (Appendix § 7.§ 3). The same partition can therefore be reused across different stacks and environments, even though their concrete successor sets may differ.

The offline partition Πq\Pi_q is shared by all configurations with local state qq. At position ii, the candidate set selects its active groups, Πq,it={G∈Πq:G∩Vit≠∅}\Pi_{q,i}^t=\{G\in\Pi_q:G\cap V_i^t\ne\varnothing\}. For each reached configuration c=(q,s,e)c=(q,s,e) and active group G∈Πq,itG\in\Pi_{q,i}^t, warm compilation evaluates the successor relation once using any representative token vG∈G∩Vitv_G\in G\cap V_i^t:

T^G(c,G)=T^G(c,vG),vG∈G∩Vit.(10)\widehat{T}_G(c,G)=\widehat{T}_G(c,v_G),\qquad v_G\in G\cap V_i^t. \tag*{(10)}

Using these representative successor sets, warm compilation directly constructs one group-level edge (c,G,c′)(c,G,c') for each returned successor c′∈T^G(c,G)c'\in\widehat{T}_G(c,G), without first materializing the corresponding token-level edges. This yields the grouped transition layer

EiΠ={(c,G,c′)∣c∈Ci−1, G∈Πq(c),it, c′∈T^G(c,G)}.(11)E_i^\Pi=\{(c,G,c')\mid c\in C_{i-1},\ G\in\Pi_{q(c),i}^t,\ c'\in\widehat{T}_G(c,G)\}. \tag*{(11)}

As analyzed in Appendix § 7.§ 5, the number of successor evaluations now scales with active groups rather than individual tokens:

Ninst=∑i=1H∑c∈Ci−1∣Πq(c),it∣≤min⁡{Nquerynaive,Rtmax⁡q∣Πq∣},Rt=∑i=1H∣Ci−1∣.(12)N_{\mathrm{inst}}=\sum_{i=1}^{H}\sum_{c\in C_{i-1}}\lvert\Pi_{q(c),i}^t\rvert\le\min\left\{N_{\mathrm{query}}^{\mathrm{naive}},R_t\max_q\lvert\Pi_q\rvert\right\},\qquad R_t=\sum_{i=1}^{H}\lvert C_{i-1}\rvert. \tag*{(12)}

Grouping reduces successor evaluations and the number of edges traversed during joint inference. The bound above concerns successor evaluations; objective-specific score aggregation still uses the individual probabilities of active group members, whose identities remain available for token restoration.

The compile-time partition is independent of model scores and of the inference objective. Joint inference assigns weights to its group-level edges using the current predictions PtP_t. For nonnegative token weights pi(v)p_i(v), define the objective-specific aggregates

Mi(G)=∑v∈G∩Vitpi(v),mi(G)=max⁡v∈G∩Vitpi(v).(13)M_i(G) = \sum_{v\in G\cap V_i^t} p_i(v), \qquad m_i(G) = \max_{v\in G\cap V_i^t} p_i(v). \tag*{(13)}

Sum-product inference weights each group-level edge by Mi(G)M_i(G), whereas max-product inference uses mi(G)m_i(G). For any fixed source configuration cc, the active groups are disjoint and all tokens within each group have the same successor set. These objective-specific reductions therefore preserve the weighted transition operator between cc and every successor configuration c′c' for ⊕∈{+,max⁡}\oplus\in\{+, \max\}:

Ai⊕(c,c′)=⨁v∈Vit:c′∈TG(c,v)pi(v)=⨁G∈Πq(c),i:c′∈T^G(c,G)ri⊕(G),ri+=Mi,rimax⁡=mi.(14)A_i^\oplus(c,c') = \bigoplus_{v\in V_i^t:c'\in T_G(c,v)} p_i(v) = \bigoplus_{G\in\Pi_{q(c),i}:c'\in\widehat{T}_G(c,G)} r_i^\oplus(G), \qquad r_i^+ = M_i,\quad r_i^{\max}=m_i. \tag*{(14)}

After selecting a group-level edge, DConstrain restores a token v∈G∩Vitv\in G\cap V_i^t according to the same inference objective. Sum-product restoration is applied to selected groups with positive mass Mi(G)>0M_i(G)>0. The restoration rules are

Pr⁡(v∣G)=pi(v)Mi(G)(sum-product),v∈arg⁡max⁡v′∈G∩Vit pi(v′)(max-product).(15)\Pr(v\mid G) = \frac{p_i(v)}{M_i(G)} \quad\text{(sum-product)}, \qquad v\in\underset{v'\in G\cap V_i^t}{\arg\max}\ p_i(v') \quad\text{(max-product)}. \tag*{(15)}

The following theorem shows that grouping preserves weighted inference.

Theorem 4.2 (Grouping preserves inference; Appendix § 7.§ 4). Let Πq\Pi_q be the token-effect partitions of Eq. (9), and assume a positive partition function and exact arithmetic. Under both chain and tree inference, grouped sum-product inference with the restoration rule in Eq. (15) preserves both the partition function and the exact token-labeled path distribution of ungrouped inference. Furthermore, grouped max-product inference attains the exact Viterbi optimum and recovers every optimal token sequence when all ties are retained.

Solver-agnostic inference interface. Because DConstrain preserves the exact successor relation TG(c,v)T_G(c,v) and both weighted transition operators, the same grouped graph representation supports different automata-based solvers. Appendix § 10.§ 2 evaluates both Viterbi decoding and the tree-based sampling algorithm of Dang & Ermon [5].

Runtime integration. Because neither warm compilation nor grammar propagation depends on model logits, CPU workers execute both stages concurrently while the GPU computes the DLM forward pass. Warm compilation runs only during the first forward pass of each canvas. Subsequent denoising iterations on the same canvas only shrink the candidate sets VitV_i^t as positions are resolved, so their required successor queries are a subset of those already computed. In every iteration, grammar propagation builds Ft\mathcal{F}_t from these cached successors during the forward pass, and joint inference begins as soon as both Ft\mathcal{F}_t and PtP_t are ready. Compact compressed sparse row (CSR) layouts and specialized GPU kernels further accelerate the joint inference solve. Appendix § 8.§ 3 details the full compiler–runtime pipeline and the optimizations enabled in each experimental setting.

Experiments

Workloads and models. We evaluate on BFCL (Patil et al. [24]), JSONSchemaBench (Geng et al. [11]), and ComplexFuncBench (Zhong et al. [39]). BFCL and ComplexFuncBench provide tool declarations for both compilation and task-level evaluation, while JSONSchemaBench stress-tests compilation with diverse and complex schemas. For end-to-end evaluation, we select two recent DLM families with different decoding granularities: LLaDA2.2 (Bie et al. [4]) with a block size of 32 and DiffusionGemma (DiffusionGemma Team et al. [6]) with a block size of 256. Both decode a long output block by block, as in block diffusion [1]. To reflect realistic serving conditions, we run LLaDA2.2 in SGLang [38] and DiffusionGemma in vLLM [16] rather than in standalone research inference loops. Cold-compilation experiments need only the corresponding tokenizers.

Comparisons. For cold compilation, we compare with DINGO’s DFA compiler [30], an NFA adaptation, and DINGO-Opt, our engineering-optimized version of DINGO, under matched schemas and tokenizers. The main BFCL runtime tables compare unconstrained Native-Opt decoding, the verification-based methods LAVE-Opt [37] and EPIC-Opt [14], DINGO-Opt, and DConstrain. Table 6 compares DConstrain and DINGO-Opt on their common successful cases, including Any-order. The -Opt suffix identifies baseline implementations with our optimizations and adaptations to the decoding setup. Appendix § 10 adds alternative solvers and further baselines.

MethodLLaDA2.2 Valid. (%) ↑LLaDA2.2 E2E (ms) ↓LLaDA2.2 Solve/forward (ms) ↓DiffusionGemma Valid. (%) ↑DiffusionGemma E2E (ms) ↓DiffusionGemma Solve/forward (ms) ↓
BFCL — fixed order
Native-Opt94.8785.42—89.501948.23—
DINGO-Opt100.0264.2332.45100.012874.32216.72
DConstrain100.0115.21 2.29×3.16 10.27×100.02521.42 5.11×9.95 21.78×
BFCL — any order
DINGO-Opt100.0813.2074.18100.0145529.003195.39
DConstrain100.0122.35 6.65×2.81 26.40×100.03145.64 46.26×29.44 108.54×
JSB — fixed order
Native-Opt73.7169.42—55.31894.82—
DINGO-Opt100.02282.87172.57100.054323.33853.25
DConstrain100.0327.61 6.97×11.78 14.65×100.05388.21 10.08×34.17 24.97×

Table 6. Paired runtime comparison on BFCL and JSONSchemaBench (JSB). Each setting uses the common successful cases of DINGO-Opt and DConstrain. Native-Opt is unconstrained decoding. E2E is the mean request latency; Solve/forward is the mean joint-inference latency per generation forward. Subscripts give DConstrain’s speedup over DINGO-Opt.

Cold-compilation targets. Table 1 compares compilers that prepare token-labeled successor construction for joint solving. Verification-based methods prepare a different object: a parser and auxiliary structures for deciding whether a proposed partial output admits a legal completion [21, 37, 14]. A Boolean verifier can return after finding one witness. A joint solver needs the compatible successor alternatives so that max- or sum-product inference can combine their model weights. DConstrain compiles the programs that construct these alternatives, leaving the inference algorithm downstream. Verifier preparation and successor compilation thus have different output contracts; Table 2 and Table 3 compare their resulting decoding pipelines in completion, accuracy, and throughput.

MethodLLaDA2.2 Success (%)LLaDA2.2 P50 (s)LLaDA2.2 P95 (s)LLaDA2.2 Speedup{sup}†DiffusionGemma Success (%)DiffusionGemma P50 (s)DiffusionGemma P95 (s)DiffusionGemma Speedup{sup}†
BFCL — fixed order
DINGO90.354.30132.9092.9×91.738.45115.41140.4×
NFA82.561.30148.50113.4×86.045.52122.17167.4×
DINGO-Opt*100.02.215.643.92×100.01.203.293.88×
DConstrain100.00.581.48—100.00.310.82—
BFCL — any order
DINGO-Opt*71.305.8512.259.43×85.813.7614.1610.39×
DConstrain100.00.661.23—100.00.410.90—
JSB — fixed order
DINGO67.738.00129.1185.0×67.731.9796.34122.9×
NFA63.745.26128.40102.8×71.330.71113.85114.0×
DINGO-Opt*74.82.5170.504.83×77.61.6537.664.53×
DConstrain81.40.6014.14—83.30.378.27—
CFB — fixed order
DINGO34.8115.18159.24121.9×44.784.73124.04174.6×
NFA32.5131.29175.14132.0×74.0116.63171.69221.9×
DINGO-Opt*100.04.667.344.02×100.02.213.023.96×
DConstrain100.01.171.78—100.00.560.76—
CFB — any order
DINGO-Opt*9.97.6316.698.12×13.72.909.403.54×
DConstrain100.00.991.41—100.00.801.16—

Table 1. Cold-compilation performance on BFCL, JSONSchemaBench (JSB), and ComplexFuncBench (CFB). Success@180s is the fraction of all attempted schemas compiled successfully within 180 s; P50/P95 use each method’s successful cases. DINGO-Opt{sup}∗ retains DINGO’s finite-state strategy with the same engineering optimizations as DConstrain (Appendix § 8.§ 3). Speedup{sup}† is the row method’s mean latency divided by DConstrain’s on paired successful cases; timeouts count only toward Success@180s.

Main Results

Table 1 evaluates cold compilation under fixed and arbitrary property order, with nesting depth limited to four for comparability with the finite-state baselines. The BFCL runtime evaluation uses two complementary cohorts. Table 2 counts cold admission, runtime completion, strict-schema validity, and official semantic accuracy over all 2,495 cases; TPS and TPF use each row’s completed cases. Table 3 defines a common runtime-success cohort independently for each model and property-order condition by intersecting the four reported methods within that condition. Schema-invalid completions remain in each cohort. DINGO-Opt compiles 71.30% of BFCL schemas with LLaDA2.2 and 85.81% with DiffusionGemma under Any-order. Table 2 reports its Any-order outcomes on the full pool. Including it in the intersection would substantially shrink the common-success cohorts in Table 3; Table 6 compares DINGO-Opt and DConstrain on their paired successful cases. Each order condition has its own common-success cohort. Appendix § 8.§ 2 specifies the accounting rules.

Cold-compilation efficiency. DConstrain reduces compilation cost across both tokenizers and all datasets. Under fixed order and depth four, it is 3.883.88–4.83×4.83\times faster than DINGO-Opt on paired cases, even though DINGO-Opt already shares our C++ pipeline and CSR representation (Appendix § 8.§ 3). The gap widens under arbitrary property order: DConstrain keeps 100% compilation coverage on BFCL and CFB, whereas DINGO-Opt loses substantial coverage. On the cases that both methods compile, DConstrain remains 3.543.54–10.39×10.39\times faster. On JSB, most remaining DConstrain failures with the LLaDA2.2 tokenizer come from JSON Schema features outside the supported fragment, such as oneOf exclusivity and general allOf intersection (13.7% of all schemas); 4.8% exceed compilation resource or construction budgets (Appendix § 10.§ 5). Mature engines also support only part of this benchmark: on its GitHub-Hard split, XGrammar and Guidance declare support for 69% and 60% of the schemas [11].

Runtime completion and throughput. DConstrain completes all 2,495 cases with 100% strict-schema validity under both models and both property-order settings (Table 2). On the common cohorts in Table 3, it has the highest TPS among the constrained methods in all four settings. Its TPS is 1.561.56–17.03×17.03\times that of LAVE-Opt and 13.1513.15–30.21×30.21\times that of EPIC-Opt. Under Schema-order, it reduces overhead above Native-Opt by 10.14×10.14\times for LLaDA2.2 and 21.75×21.75\times for DiffusionGemma relative to DINGO-Opt. On the paired Any-order cohorts in Table 6, DConstrain reduces end-to-end latency by 6.65×6.65\times and 46.26×46.26\times, and solve latency per forward by 26.40×26.40\times and 108.54×108.54\times, respectively.

Table 6 reports end-to-end and per-forward solver latency on the DConstrain/DINGO-Opt common-success cohorts. Warm compilation overlaps the model forward pass. In every plotted setting of Figure 2, at least 94% of warm-compilation calls finish within the mean forward time. Appendix § 10.§ 2 reports additional solver experiments.

Warm-compilation latency under asynchronous execution

Figure 2. Warm-compilation latency under asynchronous execution. CPU warm compilation overlaps with GPU model execution. Dashed lines indicate mean model-forward durations.

Tokens per forward and GPU computation. TPF measures how many model-generated tokens are produced per generation forward, making it an important measure of GPU computation per output token in a DLM. Raising the token-acceptance threshold commits fewer tokens per step and can improve accuracy through additional refinement, reducing TPF. LAVE also uses additional model forwards for lookahead to reduce uncertainty [37]. Both approaches spend more GPU computation per generated token. DConstrain combines the highest Any-order semantic accuracy with higher TPF than the verification-based methods on both models: 81.60% accuracy at 8.10 TPF for LLaDA2.2 and 81.56% at 8.15 TPF for DiffusionGemma on the full pool. The common-success results show the same combination of high accuracy and high TPF. TPF counts non-stop model token IDs over all generation forwards for the selected cases; CPU-generated completion text is excluded.

Ablation Study

Table 4 isolates three mechanisms on BFCL with the LLaDA2.2 tokenizer and arbitrary property order. w/o Two-Stage Env binds parsing-environment values during cold compilation instead of deferring them to runtime. w/o Local-State Reuse disables memoization of transition programs for repeated occurrences of the same local grammar state but still keeps the factorized runtime environment and continuation stack. w/o Token Grouping processes tokens with equivalent effects independently. All variants share the same grammar semantics and decoding setup.

VariantCold (s) ↓Solve (ms) ↓Memory (MiB) ↓
Full (any order)0.723.725.94
w/o Two-Stage Env10.52 (14.61×)3.83 (1.03×)20.97 (3.53×)
w/o Local-State Reuse1.87 (2.60×)3.75 (1.01×)12.98 (2.19×)
w/o Token Grouping0.96 (1.33×)25.32 (6.81×)24.42 (4.11×)
DatasetMethodStatesEdges (10310^3)Recorded payload (MB)
MeanP50P95P50P95
BFCLDINGO228.74524.771 226.2754.20114.91
NFA233.74352.711 052.0831.9593.55
DConstrain184.003.4514.634.746.31
JSONSchemaBenchDINGO182.42350.971 224.9436.86118.83
NFA214.94353.621 054.2836.99130.63
DConstrain163.093.60264.385.0331.35
ComplexFuncBenchDINGO404.391 053.461 405.1890.61107.51
NFA409.391 053.281 405.17121.60139.51
DConstrain309.1313.0820.625.115.94

Table 4. Compiler ablations on BFCL with arbitrary property order. Values are means; gray numbers are ratios to the full system.

The three mechanisms remove different forms of redundancy. Deferring environment specialization gives the largest cold-compilation benefit: eager binding raises mean compilation latency to 14.61×14.61\times that of the full system. Local-state reuse avoids recompiling identical local transition logic. Token-effect grouping mainly reduces vocabulary-level work in downstream joint inference, and removing it raises mean solve latency to 6.81×6.81\times that of the full system. A pushdown interpreter also avoids finite-state expansion, so Appendix § 10.§ 1 further compares DConstrain with Direct-PDA-Opt, which interprets the parser at every reached configuration. Even with token grouping before interpretation, it is 6.43×6.43\times slower end to end on 300 BFCL cases, because it re-executes the shared transition logic for every configuration.

Analysis

Property order changes task accuracy. Schema-order is a substantive decoding restriction for DLMs. On the full 2,495-case BFCL pool in Table 2, allowing arbitrary property order raises DConstrain’s semantic accuracy from 72.71% to 81.60% for LLaDA2.2 and from 37.27% to 81.56% for DiffusionGemma: gains of 8.89 and 44.29 percentage points, respectively, with 100% schema validity throughout. Native-Opt accuracy changes by only −0.12 and +0.16 points under the corresponding prompt conditions. The much larger constrained-decoding gains indicate that fixing the field order excludes schema-valid outputs that the models prefer. These comparisons use the same full pool; the separately selected cohorts in Table 3 support within-order comparisons. The higher LLaDA2.2 TPS in the Any-order common panel reflects its easier case composition: the shared cohort contains 2,149 cases, compared with 2,448 under Schema-order.

Verification, sampling bias, and recovery. A verifier answers whether a proposed update leaves some legal completion. Weighted joint inference additionally accounts for the model probability mass of compatible continuations. For a fixed canvas graph, the sampling objective assigns each accepting token-labeled path π\pi probability proportional to ∏ipi(vi)\prod_i p_i(v_i). An existential completion test supplies the support of this objective, but not the continuation masses needed to sample from it. Exact rejection of complete assignments from a fixed proposal samples that proposal conditioned on validity; local token acceptance, batch selection, and recovery introduce different update rules.

Consider an unambiguous two-position grammar accepting only aaaa and bbbb, with p1(a)=p2(a)=0.9p_1(a)=p_2(a)=0.9 and p1(b)=p2(b)=0.1p_1(b)=p_2(b)=0.1. Weighted joint sampling selects aaaa with probability 0.81/(0.81+0.01)=98.78%0.81/(0.81+0.01)=98.78\%. A policy that samples the first token and commits any feasible choice selects aaaa with probability 90%, because the second token is then forced. Every completed output is valid, yet the distributions differ. The missing factor is the probability mass of legal continuations, which a Boolean verifier replaces by an existence decision. The same distinction affects MAP decoding: selecting high-confidence feasible proposals does not jointly maximize the product of token probabilities.

Finite witness search adds another source of selection bias. LAVE tests model-sampled lookahead completions and uses cached-prefix recovery (Zhang et al., [37]). If a proposal uu has proposal probability q(u)q(u) and witness-search success probability a(u)a(u), its probability among accepted proposals is proportional to q(u)a(u)q(u)a(u). Thus a feasible proposal can be rejected when its valid witnesses are missed, and acceptance depends on the lookahead distribution and search budget. EPIC uses confidence-based subset selection and shrinking before exact verification; on exhausting the rejection budget, it completes the output using a witness that is not sampled from the model distribution (Jin & Han, [14]). These policies favor different proposals and continuations from those selected by weighted joint inference.

Verification also pays for rejected work. Independent proposals can conflict across positions, so an unsuccessful check triggers resampling, a smaller batch, or recovery. Parallel batch verification reduces the number of sequential checks, but a failed batch still requires additional selection and validation. This cost depends on how often proposals are accepted, whereas automata-based inference resolves compatibility within the weighted graph. Native DLM refinement can revise temporarily incompatible assignments. Maintaining feasibility of committed updates restricts these denoising trajectories, and proposal filtering

and recovery further change which trajectories are followed. On LLaDA2.2’s Any-order common cohort, Native-Opt reaches 82.78% semantic accuracy, LAVE-Opt and EPIC-Opt reach 82.60% and 75.48%, and DConstrain reaches 83.15%. The verification-based methods obtain 100% schema validity on this cohort while losing semantic accuracy relative to Native-Opt.

Property order has opposite runtime effects. DINGO-Opt’s solve latency per forward rises from 32.45 to 74.18 ms for LLaDA2.2 and from 216.72 to 3195.39 ms for DiffusionGemma when arbitrary order is allowed (Table 6). Enumerating field histories enlarges the finite-state graph, increasing the transitions processed by Viterbi inference; Figure 3 and Appendix § 10.§ 2 show the associated state-space and solver costs. LAVE-Opt and EPIC-Opt show the opposite trend: LLaDA2.2 overhead falls from 240.9% to 139.7% and from 2917.6% to 1926.2%, respectively; DiffusionGemma shows the same direction. In our integrations, reusable schema-specific verification structures are prepared during cold compilation, and both orders use the same online verification pipeline. A broader accepted language admits more proposals and reduces repeated resampling and verification per committed token. TPF increases reflect this change: LAVE-Opt rises from 4.67 to 5.75 on LLaDA2.2, and EPIC-Opt from 3.19 to 7.51 on DiffusionGemma.

Scaling with runtime-context complexity

Figure 3. Scaling with runtime-context complexity on a fixed 300-case BFCL subset. (a,b) Arbitrary-order objects are ranked by maximum parameter-object field count; (c,d) nesting depth varies from 4 to 8.

Efficient joint inference under arbitrary order. DConstrain makes arbitrary-order joint inference practical. Under Any-order, its overhead is 54.1% for LLaDA2.2 and 49.9% for DiffusionGemma on the common cohorts. It achieves the highest TPS among the evaluated constrained methods in every model–order setting and the highest Any-order semantic accuracy on the common cohorts, at 83.15% and 84.87%. On the full pool, it reaches 81.60% and 81.56% with complete coverage and 100% schema validity. The paired comparison in Table 6 shows 6.65× and 46.26× lower end-to-end latency than DINGO-Opt under Any-order. The following analyses connect these results to the compiled representation and its scaling with runtime context.

Factorized representation. Table 5 compares the stored representations. Finite-state compilation materializes context-expanded states and token-level transitions, whereas DConstrain stores the local RTN structure and symbolic transition programs. Its median recorded payload is 4.74–5.11 MB across the three datasets, compared with 36.86–90.61 MB for DINGO. The runtime experiments measure the cost of deferring work to warm compilation.

Scaling with property order and nesting depth. Figure 3 varies the two runtime-context dimensions: property order enlarges the parsing environment, and nesting enlarges the continuation stack. As either grows, DINGO-Opt increasingly hits the time or memory limit and fails all evaluated cases at depths 5–8, while DConstrain still compiles them, consistent with Table 1.

Conclusion

We presented DConstrain, a compiler for constrained decoding in diffusion language models. Finite-state compilers expand runtime contexts into states. For unordered properties, this blow-up is exponential even for context-free grammars, so existing exact decoders fix the property order. DConstrain instead compiles reusable context-parameterized transition programs, which keep the stack and the field history as runtime parameters and still give joint inference exact successors. Warm compilation and grammar propagation overlap the model forward pass, and token-effect grouping shrinks the graph while preserving the ungrouped graph’s Viterbi optimum and token-labeled path distribution. Together, these choices substantially improve compilation coverage and latency and reduce constrained-decoding overhead while preserving schema validity and task accuracy. They also make arbitrary property order practical, which further improves task accuracy over fixed-order constraints.

Additional Background and Theoretical Analysis

This appendix formalizes the parser interface used in § 3, establishes correctness of the compiler in § 4, establishes weighted inference preservation under token-effect grouping, and analyzes compilation and graph-construction costs.

Grammar Automata and Parser Configurations

Let G\mathcal{G} define an output language LG\mathcal{L}_{\mathcal{G}}. Finite-state constraints admit an automaton MG=(Q,Σ,δFA,q0,F)\mathcal{M}_{\mathcal{G}} = (Q, \Sigma, \delta_{\mathrm{FA}}, q_0, F), with transitions δFA:Q×Σ→2Q\delta_{\mathrm{FA}} : Q \times\Sigma\to2^Q; a DFA has at most one successor per state–symbol pair, whereas an NFA may have several. For nested grammars, a pushdown representation augments local control with a runtime stack [7]. Its logical configuration is

c=(q,s,e),(16)c = (q, s, e), \tag*{(16)}

where ss stores continuations and ee contains parsing variables. Guards, stack operations, and environment updates allow the same local transition logic to operate across different contexts.

Token-level transitions consume tokenizer tokens rather than individual grammar symbols [33, 7]. Let TGraw(c,v)T_{\mathcal{G}}^{\mathrm{raw}}(c, v) contain all successors after consuming vv, including required stack, environment, and token-boundary operations. We use the normalized relation

TG(c,v):=TGN(c,v)=N(TGraw(c,v)),(17)T_{\mathcal{G}}(c, v) := T_{\mathcal{G}}^{N}(c, v) = N\left(T_{\mathcal{G}}^{\mathrm{raw}}(c, v)\right), \tag*{(17)}

where NN removes statically certified dead configurations, as defined below. Relations extend to frontiers by union over their configurations. For finite automata, cc reduces to a state qq.

Diffusion Language Models

A partially resolved window xt∈(V∪{[MASK]})Hx^t \in(V \cup\{[\mathrm{MASK}]\})^H follows a fixed prefix uu. At denoising iteration tt, the model predicts distributions at all positions [27, 22]:

Pt=Model⁡θ(u,xt),Pt[i,v]=pθ(yi=v∣u,xt).(18)\begin{aligned} P_t &= \operatorname{Model}_{\theta}(u, x^t), \\ P_t[i, v] &= p_{\theta}(y_i = v \mid u, x^t). \tag*{(18)} \end{aligned}

A decoding policy selects updates for the next iteration. Multiple unresolved positions permit joint grammar-constrained token selection [30, 5]. Let VitV_i^t be the admitted tokens at position ii; fixed positions can use singleton sets. All comparisons below use identical candidate sets, prefixes, protocols, and boundary conditions.

Correctness of Factorized Compilation

We expose e=(d,η)e = (d, \eta), where dd is container depth and η\eta is the choice environment, and write c=(q,s,d,η)c = (q, s, d, \eta). Execution states also retain input, cursor, and protocol phase. A token-complete state has finished all required boundary processing; an exhausted cursor alone is insufficient. We assume agreement only between corresponding primitive parser operations. All results use set semantics and concern completed computations; resource exhaustion is an error, not an empty result. Byte execution, compilation, and assembly are defined for every finite w∈B∗w \in\mathbb{B}^* over the byte alphabet B\mathbb{B}. Token compilation specializes w=bytes⁡(v)w = \operatorname{bytes}(v) with its initialization/finalization. Suffixes need not encode vocabulary tokens and retain the enclosing metadata and phase without fresh token initialization.

Static normalization. The abstract RTN soundly overapproximates concrete execution by relaxing environment guards while preserving call/return structure. For the set Ret⁡(q)\operatorname{Ret}(q) of finite abstract derivations returning from qq’s current rule, define

D(q)=min⁡π∈Ret⁡(q)∣π∣bytes,min⁡∅=∞.(19)D(q) = \min_{\pi\in\operatorname{Ret}(q)} |\pi|_{\mathrm{bytes}}, \qquad\min\varnothing= \infty. \tag*{(19)}

Rule exits, including complete acceptance as a distinguished root exit, are productive terminals of distance zero. Consequently,

D(q)≤D(q′)for zero-byte edges,D(q)≤1+D(q′)for byte edges,D(q)≤D(a)+D(r)for calls to a returning to r,D(q)=0at rule exits.(20)\begin{aligned} D(q) &\le D(q') && \text{for zero-byte edges},\\ D(q) &\le1 + D(q') && \text{for byte edges},\\ D(q) &\le D(a) + D(r) && \text{for calls to }a\text{ returning to }r,\\ D(q) &= 0 && \text{at rule exits.} \tag*{(20)} \end{aligned}

Min-plus relaxation starts with zero at terminals and infinity elsewhere. Each finite value has a derivation witness, and saturation covers every finite return, computing Eq. (19). Thus D(q)=∞D(q) = \infty excludes any concrete return; finite distance need not imply concrete feasibility. Define

P(c)=[D(q)<∞]∧⋀r∈S[D(r)<∞],N(X)={c∈X:P(c)},(21)P(c) = [D(q) < \infty] \land\bigwedge_{r \in S}[D(r) < \infty], \qquad N(X) = \{c \in X : P(c)\}, \tag*{(21)}

Complete-output accepting configurations satisfy PP by their terminal distance and empty stack. Protocol steps obey the same abstract control rules and do not bypass required returns. Infinity is used only after the distance computation completes.

Lemma A.1 (Normalization safety). For raw byte execution δraw\delta_{\mathrm{raw}} with its prescribed zero-byte closures,

N(δraw(N(X),w))=N(δraw(X,w)).(22)N(\delta_{\mathrm{raw}}(N(X),w)) = N(\delta_{\mathrm{raw}}(X,w)). \tag*{(22)}

The same property holds for closures and complete token execution, including normalization at intermediate stages.

Proof. Every primitive step satisfies c→c′∧P(c′)⇒P(c)c \to c' \land P(c') \Rightarrow P(c). For local and byte edges this follows from the distance inequalities. For calls, productivity of the successor implies finite distances for the callee and pushed return address. For returns, the source is an exit, and the popped address and remaining stack have finite distances. Consequently, every finite execution ending in a retained configuration contains only retained configurations. Such a path survives initial and intermediate normalization; the opposite inclusion follows from N(X)⊆XN(X) \subseteq X.

Write δN(X,w)=N(δraw(X,w))\delta_N(X,w) = N(\delta_{\mathrm{raw}}(X,w)). Unlike the raw relation, this semantics excludes token endpoints that are statically known never to complete the output.

Representations and admissibility. A parameterized bundle B=(a,R,η0)B = (\mathbf{a},\mathbf{R},\eta_0) contains atoms ai=(qi,di,Ωi)a_i = (q_i,d_i,\Omega_i) and their own stack relations RiR_i. Its logical interpretation is

D(B)=⋃i{(qi,s,di,Ωi(η0)):s∈Ri, Ωi(η0)≠⊥}.(23)D(B) = \bigcup_i \{(q_i,s,d_i,\Omega_i(\eta_0)) : s \in R_i,\ \Omega_i(\eta_0) \ne\bot\}. \tag*{(23)}

Here Ωi\Omega_i is an ordered program of partial choice operations. A public representation is admissible when its atom–stack–program associations are preserved; control, frames, operands, and cursor/protocol metadata are well formed in their binding scope; and its decoded frontier is normalized and in entry-closure form. Initialization creates aligned atoms and applies closure and NN. The transfers below preserve these invariants; internal seeds carry their specified suspended phases.

Updates modify the current environment; a non-committing guard obeys

check⁡{Uj}(η)={η,∃j:Uj(η)≠⊥,⊥,otherwise.(24)\operatorname{check}_{\{U_j\}}(\eta) = \begin{cases} \eta, & \exists j: U_j(\eta) \ne\bot,\\ \bot, & \text{otherwise.} \end{cases} \tag*{(24)}

Each trial starts from the same current environment. Ordered composition satisfies (U;V)(η)=V(U(η))(U;V)(\eta) = V(U(\eta)), including failure.

Source-indexed decoding. At each token query’s entry, label every source cc by its immutable origin o=co=c. Source selectors and stack transformations denote a relation R(Y^)\mathcal{R}(\widehat{Y}) between origins and current configurations. Define

Do(Y^)={c′:(o,c′)∈R(Y^)},D(Y^)=⋃oDo(Y^).(25)D_o(\widehat{Y}) = \{c' : (o,c') \in\mathcal{R}(\widehat{Y})\}, \qquad D(\widehat{Y}) = \bigcup_o D_o(\widehat{Y}). \tag*{(25)}

Initially R={(c,c):c∈D(X^)}\mathcal{R}=\{(c,c):c\in D(\widehat{X})\}. Transfers keep the origin while changing the current configuration. Stack operations act pointwise on the selected atom’s input stack, not just its index. Merging unions these relations; shared suffixes compose them through the same intermediate configuration, never through a Cartesian product. Origins are proof annotations on existing selectors and stack maps, fixed within a query and reset at the next query.

Independent byte execution. The byte executor matches source atoms, appends call frames, partitions returns by their actual top frame, and appends choice operations in order. Its closure explores all prescribed zero-byte alternatives, deduplicates full current states with their source associations, and applies NN to each atom’s own stack relation. It does not invoke local-effect assembly.

Lemma A.2 (Source-indexed byte simulation). For every origin oo and byte string ww, the specified byte executor with matching closure conventions satisfies

Do(δ^bytes(Y^,w))=δN(Do(Y^),w).(26)D_o\left(\widehat{\delta}_{\mathrm{bytes}}(\widehat{Y},w)\right)=\delta_N\left(D_o(\widehat{Y}),w\right). \tag*{(26)}

Closure and token-finalization satisfy the analogous equations, and full public operations return admissible representations.

Proof. Fix oo. Primitive agreement gives the same byte, stack, and choice successors for each of its configurations, retaining oo. Extracting an identical, equally bound prefix UU preserves Vi(U(η0))=(U;Vi)(η0)V_i(U(\eta_0))=(U;V_i)(\eta_0) and the origin associations. Merging identical current states unions their origins and shares their future relation. Newly attached origins receive those successors by propagation or reuse of that relation; saturation therefore covers every origin’s finite closure paths. Normalization acts per endpoint, so Lemma A.1 applies to each origin. Induction over bytes, followed by the same finalization argument, proves the equation. Transfers preserve scopes and phases; public exit closure and NN restore admissibility. □\square

Local summaries and worklist propagation. For arbitrary w∈B∗w\in\mathbb{B}^*, cold compilation scans bytes and expands local closures using items h=(a,ρ,Δ,m,Ω,ν)h=(a,\rho,\Delta,m,\Omega,\nu). Here aa includes control and execution phase, ρ\rho is the unmatched local return stack, Δ\Delta is net depth change, mm is its minimum prefix change including zero, and ν\nu retains additional used metadata. Known calls and local returns modify ρ\rho; choice operations append to Ω\Omega. Initially ρ=Ω=ϵ\rho=\Omega=\epsilon and Δ=m=0\Delta=m=0. A depth change ζ\zeta updates

(Δ,m)⟵(Δ+ζ,min⁡{m,Δ+ζ}).(27)(\Delta,m)\longleftarrow(\Delta+\zeta,\min\{m,\Delta+\zeta\}). \tag*{(27)}

Every explicit alternative is explored. A return with empty ρ\rho emits a residual before accessing the unknown incoming stack. An ordinary summary P=(q′,ρ,Δ,m,Ω,ν)P=(q',\rho,\Delta,m,\Omega,\nu) binds as

Bind⁡(P;s,d,η)={{(q′,s∥ρ,d+Δ,Ω(η))},d+m≥0, Ω(η)≠⊥,∅,otherwise.(28)\operatorname{Bind}(P;s,d,\eta)= \begin{cases} \{(q',s\mathbin{\|}\rho,d+\Delta,\Omega(\eta))\}, & d+m\ge0,\ \Omega(\eta)\ne\perp,\\ \varnothing, & \text{otherwise}. \end{cases} \tag*{(28)}

Frames are appended bottom-to-top. Additional checks retain their primitive tests and operands; a depth-dependent check other than underflow also records its relative evaluation offset, or sufficient trace statistics, in keyed metadata ν\nu. Binding evaluates these tests and preserves the source selector and input-stack argument. Structural steps have no unrecorded choice effects; execution phase determines remaining closure.

The worklist keys by (a,ρ,Δ,Ω,ν)(a,\rho,\Delta,\Omega,\nu), excluding only mm. Each new key or strict increase of its best mm is enqueued. A popped item is skipped only when its mm is stale; otherwise all successors are explored. Ordinary and residual output tables also retain the largest mm.

Lemma A.3 (Summary and worklist preservation). For every concrete input binding, saturation preserves its local reference endpoints, cut before the first unknown-input-stack return, and attributes them to that same source.

Proof. Along a local trace the stack is s∥ρs \mathbin{\|} \rho. If hjh_j denotes its cumulative depth change, then Δ=hk\Delta= h_k and m=min⁡jhjm = \min_j h_j; the underflow checks succeed exactly when d+m≥0d + m \ge0. Ordered interpretation gives precisely Ω(η)\Omega(\eta); other retained tests use their recorded operands and offsets. Each summary therefore has the same endpoint and failure domain as its witnessing trace, for that fixed input binding.

For equal keys and m1≤m2m_1 \le m_2, the first success domain is contained in the second, and outputs agree. A common suffix with summary (ΔU,mU)(\Delta_U,m_U) yields

(Δ,m);(ΔU,mU)=(Δ+ΔU,min⁡{m,Δ+mU}),(29)(\Delta,m);(\Delta_U,m_U) = (\Delta+ \Delta_U,\min\{m,\Delta+ m_U\}), \tag*{(29)}

which is monotone in mm. Dominance therefore persists through successors. Every retained item has a trace witness, giving soundness. Conversely, each prefix of any finite trace is retained or dominated by a retained item. Re-enqueuing improvements propagates this coverage to outputs at saturation, giving completeness. The inclusion and propagation argument holds for each input separately, and binding never changes its origin. Applying NN preserves this sourcewise equality. □\square

Residual resolution. Whole-token replay consumes the original token from its original source, without first applying the compiled prefix. Source-indexed byte simulation gives that source’s full normalized successor set; union with ordinary results already contained in that set does not change it or its origin.

Suffix restoration instead applies the prefix once, pops the actual source-stack return frame once, and continues in that caller with its retained environment, input, and protocol phase. The compiler’s initial residual set is empty; new records appear only after a byte is consumed, with cursor equal to its zero-based index plus one. Propagation preserves that cursor, and empty input generates only the identity effect. Hence compiler-generated residuals satisfy

1≤j≤∣w∣,∣w[j:]∣<∣w∣.(30)1 \le j \le|w|,\qquad|w[j:]| < |w|. \tag*{(30)}

Entry and caller closures handle zero-byte returns independently.

Lemma A.4 (Suffix assembly preservation). For every finite byte string ww, compiler-generated effects, and origin oo, assembly with its required closures satisfies

Do(Acl(Y^,w))=δN(Do(Y^),w).(31)D_o\left(\mathcal{A}^{\mathrm{cl}}(\widehat{Y},w)\right)=\delta_N\left(D_o(\widehat{Y}),w\right). \tag*{(31)}

Proof. Fix oo and induct strongly on ∣w∣|w| over all finite byte strings, with compatible input and protocol phases. Empty input uses the identity effect and source-indexed closure simulation. Otherwise, summary and worklist preservation cover every ordinary endpoint and first residual cut from this origin. At a cut, prefix binding, the actual return, and caller closure recover its reference continuation without changing oo. The suffix is shorter by Eq. (30), so induction applies whether or not it is a tokenizer token. Its results are composed with the prefix through the same caller configuration. An empty suffix can return an intermediate seed; the enclosing closure still processes its pending returns and checks. Union over alternatives and normalization commutation prove the claim for oo. □\square

Token effects and transition preservation. Let E(q,v)\mathcal{E}(q,v) be the token specialization of the byte-string compiler, including its prescribed initialization/finalization and residual modes. Define

Canon⁡(E)=Ser⁡(Red⁡(E)),(32)\operatorname{Canon}(\mathcal{E})=\operatorname{Ser}(\operatorname{Red}(\mathcal{E})), \tag*{(32)}

where Red⁡\operatorname{Red} applies the proved duplicate and dominance reductions, and Ser⁡\operatorname{Ser} completely encodes the resulting alternatives. It retains ordered operations, bindings, and all ordinary and residual token-boundary, initialization/finalization, and protocol information used by execution. Residuals additionally retain input, cursor, source bindings, and replay mode. Whole-token selectors retain token identity. Interned operands are compared within the same immutable registry and binding scope; hashing must resolve full key equality. Let Πq\Pi_q partition tokens by these keys.

Lemma A.5 (Token-effect preservation). For fixed qq and scope, equal canonical effects imply identical normalized successor sets for each admissible concrete source, with the same source attribution.

Proof. The reductions preserve unions by the summary and worklist lemma. Structural equality identifies the same ordinary bindings, residual computations, and finalization for a fixed source. Their completed outcomes agree and retain that source. This is a sufficient equivalence test, not a complete semantic-equivalence procedure.

Theorem A.6 (Sourcewise normalized token-transition preservation). For an admissible public source X^\widehat{X} and compiler-generated effects, completed factorized token execution returns an admissible representation and, for every c∈D(X^)c \in\mathcal{D}(\widehat{X}), satisfies

Dc(T^(X^,v))=Tg(c,v).(33)\mathcal{D}_c\left(\widehat{T}(\widehat{X},v)\right)=T_g(c,v). \tag*{(33)}

Consequently,

D(T^(X^,v))=Tg(D(X^),v).(34)\mathcal{D}\left(\widehat{T}(\widehat{X},v)\right)=T_g\left(\mathcal{D}(\widehat{X}),v\right). \tag*{(34)}

Proof. Fix the entry origin cc. Source-indexed byte simulation proves replay; pointwise summary binding, worklist propagation, and suffix induction prove local-effect execution. Both preserve cc through closure, normalization, and finalization. Grouping reuses the same per-source relation. Public exit closure restores the established representation invariants. Union over sources gives the aggregate equation.

Window and complete-output languages

For normalized C0C_0, allowed sets A=(A0,…,AH−1)\mathbf{A}=(A_0,\ldots,A_{H-1}), and Y∈{N,fac}Y \in\{N,\mathrm{fac}\}, define

C0Y=C0,C_0^Y=C_0,
Ci+1Y=⋃c∈CiY ⋃v∈AiTY(c,v),C_{i+1}^Y=\bigcup_{c\in C_i^Y}\ \bigcup_{v\in A_i}T^Y(c,v),
EiY={(c,v,c′):c∈CiY, v∈Ai, c′∈TY(c,v)}.(35)E_i^Y=\{(c,v,c') : c\in C_i^Y,\ v\in A_i,\ c'\in T^Y(c,v)\}. \tag*{(35)}

Here TN=TgT^N=T_g and Tfac(c,v)=Dc(T^(X^i,v))T^{\mathrm{fac}}(c,v)=\mathcal{D}_c(\widehat{T}(\widehat{X}_i,v)) for a representation of CifacC_i^{\mathrm{fac}}. Stored edges use these source–successor pairs, not Cartesian products of frontiers; graph nodes retain their position. Let LH,BHY\mathcal{L}_{H,B_H}^Y contain the token sequences labeling paths from C0C_0 to a configuration satisfying the common normalized boundary predicate BHB_H.

Theorem A.7 (Normalized window-language preservation). Complete on-demand construction preserves Cifac=CiNC_i^{\mathrm{fac}}=C_i^N, Eifac=EiNE_i^{\mathrm{fac}}=E_i^N, and

LH,BHfac(C0;A)=LH,BHN(C0;A).(36)\mathcal{L}_{H,B_H}^{\mathrm{fac}}(C_0;\mathbf{A})=\mathcal{L}_{H,B_H}^{N}(C_0;\mathbf{A}). \tag*{(36)}

Proof. Induct on position. Equal frontiers and Eq. (33) give the same successors for each pair (c,v)(c,v), hence identical triples (c,v,c′)(c,v,c') and next frontiers. Output admissibility permits the next query. Effect groups reconstruct these same edges when every admitted token label is retained. Equal labeled paths and the same boundary predicate give equal window languages.

For a fixed token sequence, normalization commutation also gives XHN=N(XHraw)X_H^N=N(X_H^{\mathrm{raw}}). Thus raw-to-normalized boundary agreement holds whenever BHraw(X)=B‾H(N(X))B_H^{\mathrm{raw}}(X)=\overline{B}_H(N(X)). This extra condition is unnecessary when comparing factorized execution directly with the normalized reference.

Let LcompleteY\mathcal{L}_{\mathrm{complete}}^Y contain finite token sequences reaching complete-output acceptance under semantics YY.

Theorem A.8 (Complete-output language preservation). LcompleteN=LcompleterawL_{\mathrm{complete}}^{N}=L_{\mathrm{complete}}^{\mathrm{raw}}. Factorized acceptance agrees with both on completed queries.

Proof. Every complete accepting configuration satisfies PP, so backward closure ensures that every raw accepting path survives normalization. Normalization only deletes alternatives, proving the reverse inclusion. The token theorem then establishes factorized agreement. The same argument preserves the existence of a finite legal completion, but not observations of dead threads.

These statements preserve logical transitions and token languages, not derivation multiplicities, arbitrary path weights, or resource-truncated results.

Weighted Inference under Token-Effect Grouping

Fix one denoising iteration and a finite layered window graph with initial configuration c0c_0, horizon HH, terminal predicate BHB_H, and fixed nonnegative token weights pi(v)p_i(v). Forbidden tokens have zero weight. All comparisons use the same normalized, sourcewise transition relation TGT_{\mathcal{G}} and count each logical edge (i,c,v,c′)(i,c,v,c') once. Let Πq\Pi_q partition V\mathcal{V} and assume effect equivalence:

TG(c,v)=TG(c,G),v∈G∈Πq(c).(37)T_{\mathcal{G}}(c,v)=T_{\mathcal{G}}(c,G),\qquad v\in G\in\Pi_q(c). \tag*{(37)}

Positions, endpoints, and group membership are retained. An accepting path π\pi has weight W(π)=∏i=1Hpi(vi)W(\pi)=\prod_{i=1}^{H}p_i(v_i); assume Z=∑π acceptingW(π)>0Z=\sum_{\pi\ \mathrm{accepting}}W(\pi)>0. The following equalities use exact arithmetic.

Define

Mi(G)=∑v∈Gpi(v),mi(G)=max⁡v∈Gpi(v).(38)M_i(G)=\sum_{v\in G}p_i(v),\qquad m_i(G)=\max_{v\in G}p_i(v). \tag*{(38)}

For ⊕∈{+,max⁡}\oplus\in\{+,\max\}, let ri+=Mir_i^{+}=M_i and rimax⁡=mir_i^{\max}=m_i. Disjoint group membership and Eq. (37) give

Ai⊕(c,c′):=⨁v:c′∈TG(c,v)pi(v)=⨁G:c′∈TG(c,G)ri⊕(G).(39)\begin{aligned} A_i^{\oplus}(c,c'):=\bigoplus_{v:c'\in T_{\mathcal{G}}(c,v)}p_i(v) \\ &=\bigoplus_{G:c'\in T_{\mathcal{G}}(c,G)}r_i^{\oplus}(G). \tag*{(39)} \end{aligned}

Both cases use multiplication to compose edge weights, with empty reductions equal to zero. Thus grouping preserves the entire sum-product or max-product transition operator, not only its support.

Lemma A.9 (Sum-product inference preservation). Group-sum reduction with conditional token restoration preserves ZZ, the full token-labeled path distribution, and all token marginals under chain or tree inference using the conditionals below.

Proof. Equation (39) preserves every forward, backward, and interval message. Set βH=BH\beta_H=B_H and βi−1=Ai+βi\beta_{i-1}=A_i^{+}\beta_i. Chain sampling selects a valid group edge and then a token using

Pr⁡(G,c′∣c)=Mi(G)βi(c′)βi−1(c),Pr⁡(v∣G,c,c′)=pi(v)Mi(G).(40)\Pr(G,c'\mid c)=\frac{M_i(G)\beta_i(c')}{\beta_{i-1}(c)},\qquad \Pr(v\mid G,c,c')=\frac{p_i(v)}{M_i(G)}. \tag*{(40)}

Their product is pi(v)βi(c′)/βi−1(c)p_i(v)\beta_i(c')/\beta_{i-1}(c), exactly the expanded edge conditional. Multiplication along a path cancels the messages and gives W(π)/ZW(\pi)/Z.

For tree inference, write Kℓ:r=Aℓ+1+⋯Ar+K_{\ell:r}=A_{\ell+1}^{+}\cdots A_r^{+}. Sample the terminal state with probability K0:H(c0,b)BH(b)/ZK_{0:H}(c_0,b)B_H(b)/Z and an interval midpoint by

Pr⁡(Ck=z∣Cℓ=a,Cr=b)=Kℓ:k(a,z)Kk:r(z,b)Kℓ:r(a,b).(41)\Pr(C_k=z\mid C_\ell=a,C_r=b)=\frac{K_{\ell:k}(a,z)K_{k:r}(z,b)}{K_{\ell:r}(a,b)}. \tag*{(41)}

At leaf ii with endpoints a,ba,b, choose GG with probability Mi(G)1[b∈TG(a,G)]Ai+(a,b)\frac{M_i(G)\mathbf{1}[b \in T_G(a,G)]}{A_i^+(a,b)}, then restore vv with probability pi(v)Mi(G)\frac{p_i(v)}{M_i(G)}. Associativity preserves the interval operators; cancellation of the interval and leaf normalizers again gives W(π)/ZW(\pi)/Z. Only positive-mass events are sampled. Equality of full path distributions implies equality of all token marginals.

Theorem A.10 (Equivalence to Dang–Ermon sampling). Consider Algorithm 1 of Dang & Ermon [5], expressed in the equivalent state-space formulation of their Appendix A.2. Use the same finite token-labeled graph, initial and terminal factors, and logical edge-counting convention as above, with per-token factors

gi(c,v,c′)=pi(v)1[c′∈TG(c,v)].(42)g_i(c,v,c') = p_i(v)\mathbf{1}[c' \in T_G(c,v)]. \tag*{(42)}

Under Lemma A.9, the grouped tree sampler has the same partition function and output-token distribution as this instance of Algorithm 1.

Proof. Their state-space transition matrix is

Mi(c,c′)=∑vgi(c,v,c′)=Ai+(c,c′).(43)M_i(c,c') = \sum_v g_i(c,v,c') = A_i^+(c,c'). \tag*{(43)}

Equation (39) preserves this matrix under group-sum reduction. Thus all bottom-up interval messages, the root boundary distribution, and the conditional midpoint distributions are unchanged.

At a leaf with endpoints c,c′c,c', selecting a group and restoring v∈Gv \in G gives

Mi(G)1[c′∈TG(c,G)]Ai+(c,c′)pi(v)Mi(G)=gi(c,v,c′)Ai+(c,c′).(44)\frac{M_i(G)\mathbf{1}[c' \in T_G(c,G)]}{A_i^+(c,c')} \frac{p_i(v)}{M_i(G)} = \frac{g_i(c,v,c')}{A_i^+(c,c')}. \tag*{(44)}

which is the same leaf token conditional. Only positive-mass events are sampled. Induction over the sampling tree therefore gives the same state-space joint distribution and hence the same output-token distribution. The identical interval operators and boundary factors also give the same partition function.

Lemma A.11 (Max-product inference preservation). Group-max reduction preserves the Viterbi optimum under chain or tree composition. All maximizing token sequences can be recovered when all tied token and state-path choices are retained.

Proof. Equation (39) preserves every max-product message. For a fixed grouped state path,

max⁡vi∈Gi∏i=1Hpi(vi)=∏i=1Hmi(Gi).(45)\max_{v_i \in G_i} \prod_{i=1}^{H} p_i(v_i) = \prod_{i=1}^{H} m_i(G_i). \tag*{(45)}

Every token replacement is feasible by effect equivalence. Hence each optimal grouped path lifts to an optimal token path by choosing group maximizers, and every positive-weight expanded optimum is recovered this way. Retaining all ties preserves the full maximizing sequence set. A single argmax and backpointer return one optimum; identical selected outputs additionally require the same tie-breaking rule.

Parsing ambiguity and the probability measure. Let n(y)n(y) be the number of accepting paths labeled by token sequence yy in the chosen token-level graph, and let w(y)=∏ipi(yi)w(y)=\prod_i p_i(y_i). Summing path weights gives

Qpath(y)=n(y)w(y)∑zn(z)w(z),Qseq(y)=1[n(y)>0]w(y)∑z:n(z)>0w(z).(46)Q_{\mathrm{path}}(y) = \frac{n(y)w(y)}{\sum_z n(z)w(z)}, \qquad Q_{\mathrm{seq}}(y) = \frac{\mathbf{1}[n(y)>0]w(y)}{\sum_{z:n(z)>0} w(z)}. \tag*{(46)}

The second distribution counts each legal sequence once. Cancelling positive w(y)w(y) shows that the two distributions coincide if and only if n(y)n(y) is constant on the positive-weight legal support; unambiguity is sufficient. A constant n(y)=kn(y)=k gives the same normalized distribution but scales its partition function by kk. For example, equal-weight sequences with path counts two and one have path probabilities 2/32/3 and $1/3, rather than 1/2 each. Thus language equivalence alone does not establish sum-product equivalence across different parser representations. Grouping preserves the chosen graph’s measure, not an assumed absence of parsing ambiguity.

These results require the stated weighted conditionals; greedy selection by group mass is generally not equivalent. Extra token-dependent scores require corresponding weighted reductions and token-restoration rules. Distributional equality does not imply identical outputs under the same random seed or floating-point reduction order.

Complexity Analysis

We separate compilation and grammar propagation from model inference, token-probability processing, and joint inference.

Context expansion. Let QlocQ_{\mathrm{loc}} be the local grammar states, g>1g > 1 the number of possible continuation-frame symbols, dmax⁡d_{\max} the stack-depth bound, and BB the maximum number of remaining context assignments per local-state–stack pair. Then

Sdmax⁡≤∣Qloc∣B∑ℓ=0dmax⁡gℓ=O(∣Qloc∣Bgdmax⁡).(47)S_{d_{\max}} \le|Q_{\mathrm{loc}}|B \sum_{\ell=0}^{d_{\max}} g^\ell= O\left(|Q_{\mathrm{loc}}|Bg^{d_{\max}}\right). \tag*{(47)}

The stack factor is dmax⁡+1d_{\max} + 1 for g=1g = 1. The bound need not be attained. For bounded-depth brackets with gg types, however, each opening-only prefix has a distinct matching completion. A minimal complete DFA needs one state per stack plus a sink:

SDFAmin⁡=1+∑ℓ=0dmax⁡gℓ=Θ(gdmax⁡).(48)S_{\mathrm{DFA}}^{\min} = 1 + \sum_{\ell=0}^{d_{\max}} g^\ell= \Theta\left(g^{d_{\max}}\right). \tag*{(48)}

This is a worst-case DFA representation gap, not a universal runtime bound.

Unordered properties. We prove Proposition 3.2. Fix k≥1k \ge1 and distinct Unicode letters a1,…,aka_1,\ldots,a_k. Let GkG_k be the object schema with properties a1,…,aka_1,\ldots,a_k, all required, no additional properties, and the value schema {"const":0} for every property. Let LkL_k be the set of its serializations, and write PiP_i for the pair "aia_i:0".

DFA bound. For S⊆{1,…,k}S \subseteq\{1,\ldots,k\}, let uSu_S open the object and write the pairs PiP_i with i∈Si \in S in increasing order of ii, separated by commas. When ∅≠S≠{1,…,k}\varnothing\ne S \ne\{1,\ldots,k\}, uSu_S also ends with a comma. Let wSw_S write the remaining pairs in the same way and close the object, so that uSwS∈Lku_Sw_S \in L_k. Now take S≠TS \ne T and assume without loss of generality that some i∈S∖Ti \in S \setminus T exists. The string uTwSu_Tw_S never writes PiP_i, because i∉Ti \notin T and wSw_S writes only properties outside SS. Since aia_i is required, uTwS∉Lku_Tw_S \notin L_k. The 2k2^k prefixes are therefore pairwise inequivalent, and by the Myhill–Nerode theorem [13] every DFA for LkL_k has at least 2k2^k states.

Grammar bound. Let GG be a context-free grammar for LkL_k, and let ss be its size, i.e., the total length of its productions. Let RkR_k be the regular language of strings that open an object, write exactly kk pairs from {P1,…,Pk}\{P_1,\ldots,P_k\} separated by commas, and close the object. A DFA for RkR_k has O(k)O(k) states. Every property is required and RkR_k allows exactly kk pairs, so Lk∩RkL_k \cap R_k contains exactly the strings that write each PiP_i once, in some order. The product construction for intersecting a context-free language with a regular language [13] gives a grammar for Lk∩RkL_k \cap R_k whose size is polynomial in ss and kk. Let hh be the homomorphism that keeps each aia_i and erases every other character. Replacing every terminal of a grammar by its image under hh does not enlarge the grammar, and h(Lk∩Rk)h(L_k \cap R_k) is the set of all permutations of a1,…,aka_1,\ldots,a_k. Every context-free grammar for this set has size 2Ω(k)2^{\Omega(k)} [9]. Hence poly⁡(s,k)≥2Ω(k)\operatorname{poly}(s,k) \ge2^{\Omega(k)}, and therefore s=2Ω(k)s = 2^{\Omega(k)}.

Factorized representation. Under the parsing-environment factorization of § 4.1, the object needs local grammar states only for its delimiters, property names, separators, and values, so O(k)O(k) of them suffice. The environment η\eta stores the set of properties already written, a kk-bit value. Programs that complete a property name carry the guard “ai∉ηa_i \notin\eta” and the update “add aia_i to η\eta”. The program that closes the object carries the guard “η\eta contains every required property”. All 2k2^k field histories share these programs.

Entry and instantiation counts. A dense context-expanded table has Sdmax⁡∣V∣S_{d_{\max}}|\mathcal{V}| entries; factorized compilation has at most ∣Qloc∣∣V∣|Q_{\mathrm{loc}}||\mathcal{V}| local-state–token entries. These are counts, not constant-time operations. For reachable frontiers Ci−1C_{i-1}, define

Rt=∑i=1H∣Ci−1∣,Πq,i†={G∈Πq:G∩Vit≠∅},K=max⁡q∣Πq∣,Ninst=∑i=1H∑c∈Ci−1∣Πq(c),i†∣≤min⁡{Nquery,RtK}.(49)\begin{aligned} R_t &= \sum_{i=1}^{H}|C_{i-1}|,\\ \Pi_{q,i}^{\dagger} &= \{G \in\Pi_q : G \cap\mathcal{V}_i^t \ne\varnothing\}, \qquad K = \max_q |\Pi_q|,\\ N_{\mathrm{inst}} &= \sum_{i=1}^{H}\sum_{c\in C_{i-1}}|\Pi_{q(c),i}^{\dagger}| \le\min\{N_{\mathrm{query}},R_tK\}. \tag*{(49)} \end{aligned}

where Nquery=∑i∑c∈Ci−1∣Vit∣N_{\mathrm{query}} = \sum_i \sum_{c\in C_{i-1}}|\mathcal{V}_i^t|. Repeated configurations are counted per position. With full-vocabulary candidates, the ungrouped count is Rt∣V∣R_t|\mathcal{V}|.

Construction cost. Let TsetupT_{\mathrm{setup}} include shared schema lowering and static-distance analysis. Let C(q,v)C(q,v) include a cold entry’s queue processing, improvement propagation, and effect/key construction. Let WjW_j include a top-level instantiation’s binding, all residual descendants, closures, suffix compilation, and successor creation. For cold pairs Pcold⊆Qloc×V\mathcal{P}_{\mathrm{cold}} \subseteq Q_{\mathrm{loc}}\times\mathcal{V}, actual top-level queries ∣Jinst∣≤Ninst|\mathcal{J}_{\mathrm{inst}}| \le N_{\mathrm{inst}}, and additional indexing and label/graph work AtA_t,

Tconstruct=O(Tsetup+∑(q,v)∈PcoldC(q,v)+∑j∈JinstWj+At).(50)T_{\mathrm{construct}} = O\left(T_{\mathrm{setup}}+\sum_{(q,v)\in\mathcal{P}_{\mathrm{cold}}}C(q,v)+\sum_{j\in\mathcal{J}_{\mathrm{inst}}}W_j+A_t\right). \tag*{(50)}

Each shared construction is charged once; recursive work included in WjW_j is not counted again. If C(q,v)≤τcC(q,v)\le\tau_c and Wj≤τwW_j\le\tau_w, then

Tconstruct=O(Tsetup+τc∣Qloc∣∣V∣+τwRtK+At).(51)T_{\mathrm{construct}} = O\left(T_{\mathrm{setup}}+\tau_c|Q_{\mathrm{loc}}||\mathcal{V}|+\tau_wR_tK+A_t\right). \tag*{(51)}

Neither per-entry cost is assumed constant for arbitrary grammars. Grouping also does not remove the work needed to discover effects or emit individual token labels.

Scope. For an LL-byte entry, if every depth prefix is at least −κL-\kappa L, then −κL≤m≤0-\kappa L\le m\le0 and each complete key admits at most κL+1\kappa L+1 retained values, including its first admission. This bounds re-expansion per key, not the number or size of keys. Similarly, residual progress bounds a recursive chain by LL strict decreases, not the total work of its branching tree. Local stacks and pending programs may still grow, RtR_t may approach HSdmax⁡HS_{d_{\max}}, and KK may approach ∣V∣|\mathcal{V}|. Cold assets are reusable across requests with the same grammar and binding scope; graph reuse additionally requires compatible candidate sets and boundary/protocol conditions. The analysis therefore characterizes avoided replication without claiming an unconditional exponential decoding speedup.

Additional Experimental Details

This section provides additional implementation and evaluation settings for the experiments in § 5.

Implementation and Decoding Settings

Inference uses NVIDIA H20-3e GPUs with approximately 140 GiB of visible memory per device. Both models run in BF16 with model CUDA Graphs enabled. LLaDA2.2 (Bie et al., [4]) uses SGLang (Zheng et al., [38]) with tensor parallelism across four GPUs, while DiffusionGemma (DiffusionGemma Team et al., [6]) uses vLLM (Kwon et al., [16]) 0.28.0 with one GPU per model instance. DConstrain implements cold and warm compilation in C++ and joint inference in CUDA.

Cold-compilation experiments run on an Intel Xeon Platinum 8575C CPU. Each schema compilation is single-threaded, with up to 64 schemas compiled concurrently. Cold timing starts after tokenizer and service initialization and ends when the reusable compiled artifact is ready for online use. Warm compilation and model inference are excluded from cold-compilation time.

LLaDA2.2. The adaptive runtime comparison uses 32-token physical blocks, with the first block’s available positions determined by the prompt suffix. Generation is greedy with seed zero. MASK-to-token updates use a confidence threshold of 0.5, falling back to the highest-confidence MASK position when none qualifies. The token-to-token threshold is 0.0; DELETE and SPLIT are disabled. A block is committed after all MASK positions are filled and token assignments stabilize. Generation terminates at an accepted EOS or the 2,048-token output limit, with bounded update/refinement rounds; budget exhaustion is counted as failure.

DiffusionGemma. Generation uses 256-token canvases, seed zero, and the native entropy-bound sampler. The entropy budget is 0.1, and temperature decreases linearly from 0.8 to 0.4. Gumbel-max candidates are retained at entropy-selected positions while the remaining positions are re-noised, with native soft self-conditioning preserved. Generation uses at most 48 denoising iterations per canvas and terminates at EOS/EOT or the 2,048-token output limit.

Compilation and Evaluation Settings

The BFCL pool contains 2,495 cases, obtained by screening all required cases in BFCL and excluding cases whose schemas admit no valid instance. The JSONSchemaBench (JSB) pool contains all 5,754 training schemas, and the ComplexFuncBench (CFB) pool contains all 1,000 benchmark cases.

The main cold-compilation experiments and ablation study use the full corresponding pools. The main BFCL runtime tables report both all-attempted and common runtime-success cohorts, as defined below. Unless otherwise specified, other analyses and appendix experiments use fixed subsets of 300 BFCL cases and 300 JSB schemas, and the full 1,000-case CFB pool, as applicable. Table 6 uses cases successfully completed by both DINGO-Opt and DConstrain within the designated pool. Failed compilation cases are not replaced.

For cold compilation, the nominal timeout is 180 s per schema. Success rates include all attempted cases, while compilation latency statistics use each method’s successfully compiled cases. Reported speedups divide the baseline’s arithmetic mean latency by DConstrain’s over paired successful cases. Timeouts and failures affect success rates but are excluded from these latency ratios.

BFCL completion and quality cohorts. In Table 2, cold-stage admission, runtime completion, strict-schema validity, and official BFCL semantic accuracy all use the full denominator of 2,495. NN counts runtime completions regardless of schema validity; TPS and TPF use those NN cases. Native-Opt has no constraint-compilation stage. DConstrain completes all 2,495 cases with 100% cold admission, runtime completion, and strict-schema validity under both models and both order settings.

For Table 3, we define four independent cohorts, one for each combination of model and property-order condition, by intersecting the runtime-success sets of Native-Opt, LAVE-Opt, EPIC-Opt, and DConstrain. Schema-invalid completions are retained. The Schema-order and Any-order cohorts contain 1,874 and 2,201 cases for DiffusionGemma, and 2,448 and 2,149 cases for LLaDA2.2, respectively. DINGO-Opt completes all Schema-order cases; its validity, TPF, and semantic accuracy on the Schema-order common cohorts match DConstrain. Under Any-order, its cold-compilation success is 85.81% for DiffusionGemma and 71.30% for LLaDA2.2. Table 2 reports its Any-order outcomes over the full pool. Including DINGO-Opt would substantially reduce the common-success cohorts in Table 3, so Table 6 compares it with DConstrain on their paired successful cases. In Table 2, Schema-order DINGO-Opt has TPF 8.11 for DiffusionGemma and 6.86 for LLaDA2.2, semantic accuracy 37.19% and 72.63%, and TPS 23.13 and 101.32, respectively.

Schema validity is evaluated independently of solver acceptance and semantic correctness. The two main BFCL runtime tables report strict-schema validity and the official semantic evaluator separately; semantic accuracy is not filtered by schema validity. Other reported joint-correctness metrics additionally require schema validity. JSONSchemaBench validates outputs against the original schema. Timeouts and exhausted decoding budgets count as runtime failures; schema-invalid completions count against validity but remain completed runs.

Throughput accounting. For the main BFCL tables, TPF is the number of model non-stop token IDs divided by all generation forwards for the selected cases. CPU-generated completion text is excluded from model-token counts. The Overhead columns report inverse-TPS overhead over Native-Opt in the same model–order panel, (TPSNative-Opt/TPSmethod−1)×100%(\mathrm{TPS}_{\mathrm{Native\text{-}Opt}}/\mathrm{TPS}_{\mathrm{method}} - 1) \times100\%. In Table 2 and the Schema-order panel of Table 3, DConstrain TPS subscripts give TPSDConstrain/TPSDINGO-Opt\mathrm{TPS}_{\mathrm{DConstrain}}/\mathrm{TPS}_{\mathrm{DINGO\text{-}Opt}} in the same table and panel; its bold Overhead entries show the reduction factor hDINGO/hDConstrainh_{\mathrm{DINGO}}/h_{\mathrm{DConstrain}}, where h=TPSNative-Opt/TPS−1h = \mathrm{TPS}_{\mathrm{Native\text{-}Opt}}/\mathrm{TPS} - 1. Schema and Any denote schema-order and arbitrary-order settings; for Native-Opt, they identify the prompt condition.

Runtime timing. End-to-end latency is measured by wall-clock time at the request level, while GPU joint-inference stages are measured with CUDA events. Warm compilation measures the request-local successor-construction work, which overlaps with model execution; these intervals are therefore not additive. Cold compilation and artifact loading are excluded from runtime latency. Runtime latency statistics in Table 6 are arithmetic means over the paired cases successfully completed by both compared methods.

Paired latency comparison. Table 6 reports BFCL and JSB latency on the cases successfully completed by both DINGO-Opt and DConstrain in each dataset–order setting. E2E is the mean request latency. Solve/forward is the mean joint-inference latency per generation forward. On BFCL under Any-order, DConstrain reduces end-to-end latency by 6.65× for LLaDA2.2 and 46.26× for DiffusionGemma, and reduces solve latency per forward by 26.40× and 108.54×, respectively.

Engineering Optimizations

We complement DConstrain’s compilation design with engineering optimizations that reduce execution overhead and graph-storage cost.

Native compilation pipeline. Cold and warm compilation execute in a native C++ pipeline, reducing interpreter overhead in grammar processing and transition instantiation. Reusable schema artifacts are stored in packed native arrays, avoiding per-edge Python objects and their allocation overhead.

Compact sparse graph storage. We store canvas-specific grammar graphs in compressed sparse row (CSR) format, using row offsets and contiguous edge arrays. This representation stores only existing transitions rather than allocating dense graph structures. CUDA joint-inference kernels consume the CSR representation directly, connecting grammar propagation with GPU execution.

DINGO-Opt adopts the same C++ pipeline and CSR representation while retaining finite-state compilation. Direct-PDA-Opt uses edge merging, shared token-membership storage, and grouped GPU reductions while interpreting reached parser configurations on demand, without compiling symbolic transition programs. Its + TG variant additionally applies conservative token grouping before interpretation (Appendix § 10.§ 1).

Asynchronous execution. Native CPU workers run warm compilation during the first forward pass of each canvas and grammar propagation during every forward pass. Neither stage reads the model scores. The scheduling interface supports both eager execution and model CUDA Graph replay. Data transfer and readiness tracking connect warm compilation to GPU joint inference, which begins when both graph data and model scores are available. Score-dependent operations therefore remain on the critical path. This overlap limits exposed warm-compilation latency, while workspace reuse reduces repeated setup costs. We measure end-to-end latency directly rather than summing overlapping components, and report compilation and exposed costs in § 5.1.

Additional Analyses of Constraint Semantics and Runtime

Warm Compilation Scaling and Runtime Overlap

DConstrain avoids materializing context-expanded token transitions during cold compilation, but exact joint inference still requires the runtime contexts that are reachable from the current decoding canvas. Warm compilation instantiates context-specific successors on demand from shared transition programs. This section examines whether the resulting deferred work becomes a runtime bottleneck as parsing-environment and stack complexity increase, and how this work is overlapped with model computation during execution.

Scaling with runtime-context complexity. Figure 4 complements the cold-compilation scaling analysis in Figure 3 by measuring the corresponding online cost. We consider the two sources of runtime-context growth targeted by the factorized representation. For arbitrary-order objects, increasing the number of parameter fields increases the number of possible parsing-environment configurations. For nested structures, increasing nesting depth increases the diversity of continuation-stack contexts that may be reached during grammar propagation.

Warm-compilation scaling with runtime-context complexity across CFB and BFCL

Figure 4. Warm-compilation scaling with runtime-context complexity. (a) CPU warm-compilation time per 32-token block on CFB with arbitrary property order, grouped by the maximum number of parameter fields per object; the line and band report the median and interquartile range. (b) Per-request end-to-end latency and accumulated CPU warm-compilation time on BFCL as nesting depth increases. (c) Mean CPU warm-compilation time per call over the same depth sweep. Bands in (b,c) show the observed range across requests. Dashed lines denote the corresponding mean model-forward time.

On the CFB any-order sweep in Figure 4(a), median CPU warm-compilation time per 32-token block increases gradually with the maximum number of parameter fields per object. Even at the largest field counts, the median remains well below the corresponding mean model-forward time of 9.09 ms. Thus, supporting arbitrary schema-valid property order introduces additional online work, but the measured warm-compilation cost remains small relative to the model computation with which it can overlap.

Figure 4(b) and Figure 4(c) examine nesting depth on BFCL. As depth increases from four to eight, warm-compilation work increases, consistent with a larger set of reachable stack contexts. The increase is visible both in the total warm-compilation work accumulated within a request and in the mean cost of an individual warm-compilation call. At depth eight, the mean per-call CPU cost remains below the approximately 9 ms mean model-forward time, while end-to-end request latency remains comparatively stable across the depth sweep. Across the depth sweep, mean warm-compilation cost stays below the mean model-forward time, and end-to-end latency remains comparatively stable.

Warm compilation during asynchronous execution. The scaling experiments above characterize how online work changes with specific sources of context complexity. Figure 2 in the main text reports warm-compilation timings from actual asynchronous execution across the broader evaluation workloads. Native CPU workers run score-independent warm compilation concurrently with GPU model forward computation. Joint inference starts when both the graph and model scores are ready, so only warm compilation remaining at that point is exposed on the decoding critical path. The figure sorts the measured CPU warm-compilation times and shows the corresponding mean model-forward duration as a reference; the percentage annotations summarize the fraction of warm-compilation calls below that duration.

For LLaDA2.2 on CFB, arbitrary property order increases warm-compilation cost relative to schema order, as expected from the additional parsing-environment alternatives, while the distribution remains below the corresponding mean forward time over the plotted samples. On JSONSchemaBench, which contains substantially more heterogeneous schemas, the distribution has a longer tail: 97.17% of warm-compilation calls remain below the 8.90 ms mean model-forward duration, while the largest observed call reaches 34.61 ms.

The same pattern holds with the substantially larger 256-token canvases of DiffusionGemma. On BFCL and CFB with arbitrary property order, 99.47% and 94.20% of warm-compilation calls, respectively, are below the corresponding mean model-forward durations of 26.4 and 26.7 ms. On JSONSchemaBench, 99.3% are below the 25.64 ms mean forward duration, with a maximum observed warm-compilation time of 30.32 ms.

Implications for deferred instantiation. Together, Figure 4 and Figure 2 clarify the trade-off introduced by two-stage compilation. DConstrain shares compiled transition logic across the runtime contexts reached during grammar propagation. It performs context-specific instantiation only when the corresponding configurations become reachable. The resulting online work grows with runtime-context complexity, as expected, but remains modest relative to model-forward computation over the evaluated regimes and is overlapped with model execution by the asynchronous schedule. The request-level means in Table 6 account for this overlap directly.

Additional Experimental Results

These experiments complement the main runtime and compilation results in § 5. We examine direct pushdown interpretation, tree-parallelized automata inference, compiled representations, and compilation coverage.

Comparison with Direct Pushdown Interpretation

The ablations in § 5.2 vary reuse within DConstrain. Here we additionally evaluate a baseline that computes (c,v)↦TG(c,v)(c,v) \mapsto T_G(c,v) by directly interpreting the pushdown parser at reached runtime configurations, without materializing a context-expanded DFA or compiling symbolic transition programs. This comparison tests whether on-demand interpretation alone can provide efficient successor construction.

Baseline variants. Direct-PDA-Opt already merges output edges with common destinations and uses shared token-membership storage and grouped GPU reductions. Direct-PDA-Opt + TG additionally groups tokens before interpretation: bytes are equivalent only when their raw transitions agree at every local RTN node, and token-trie paths with identical byte-class sequences are merged. It also reuses unions of token memberships. Calls, returns, and environment updates still execute in the interpreter, and all original token identities and model scores are retained. This conservative grouping uses no symbolic transition programs and differs from DConstrain’s local token-effect grouping.

Evaluation setting. We evaluate all variants on the same fixed set of 300 BFCL cases, with LLaDA2.2, BF16, tensor parallelism of four, batch size one, and 32-token blocks. All variants use the same name-first tool-call format, arbitrary parameter-field order, a nesting-depth limit of four, prompt, and MAP decoding. These controlled runs execute graph construction and model forward serially, with a fresh runtime per request. E2E spans the first prefill through runtime and parser cleanup after generation; cold preparation is excluded. Figure 5 uses the original paired runs. Figure 6 reruns DConstrain and the grouped baseline in the same service on the same 300 cases. All 300 cases produce identical output tokens across variants and satisfy their schemas.

Latency percentile curves comparing DConstrain and Direct-PDA-Opt across end-to-end, total warm compilation, mean warm compilation, and cold compilation time

Figure 5. DConstrain versus Direct-PDA-Opt without pre-interpretation token grouping on 300 BFCL cases with LLaDA2.2. Panels report (a) complete-request E2E, (b) accumulated warm-compilation time per request, (c) each request’s mean time per warm-compilation call, and (d) cold-compilation time. Each curve shows its latency percentiles from P0 to P95; the upper 5% is omitted without rescaling the percentile axis.

Latency percentile curves comparing DConstrain and Direct-PDA-Opt + TG across end-to-end, total warm compilation, mean warm compilation, and cold compilation time

Figure 6. DConstrain versus Direct-PDA-Opt + TG, which adds conservative pre-interpretation token grouping and membership reuse. Both methods are rerun on the same 300 BFCL cases. Panel definitions and the P0–P95 display follow Figure 5.

Runtime comparison. Pre-interpretation grouping substantially reduces the direct interpreter’s online cost, but a large gap remains. In the grouped paired run, mean E2E is 878.10 ms for Direct-PDA-Opt + TG and 136.63 ms for DConstrain, a 6.43× speedup. The warm-compilation curves show that repeated runtime interpretation remains expensive even after conservative grouping. Together with the compiler ablations, these results support compiling and reusing transition programs as a contribution beyond simply avoiding DFA expansion.

Tree-Parallelized Automata Inference

DConstrain changes how the canvas-specific grammar graph is constructed while preserving the token-labeled successor relation consumed by downstream automata-based inference. It is therefore solver-agnostic rather than specialized to the Viterbi solver used in our main experiments. We verify this compatibility by applying both Viterbi inference and the inference algorithm of [5] directly to DConstrain graphs, using both sequential and tree-parallelized implementations.

We further examine whether tree parallelism can reduce the solver cost underlying Table 6. All four solver variants are evaluated on the same 300 BFCL cases using both DINGO and DConstrain graph representations. Table 7 reports results for two cases near the 25th and 95th percentiles of DINGO graph node count, denoted P25 and P95. The selected cases and inference objectives are matched across graph representations.

GraphMethodP25 BFCL schema Time (ms) ↓P25 BFCL schema Mem. (GiB) ↓P95 BFCL schema Time (ms) ↓P95 BFCL schema Mem. (GiB) ↓
OursViterbi seq.3.900.0130.850.03
OursDANG seq.4.700.0148.970.09
OursViterbi tree30.801.147824.1912.55
OursDANG tree60.701.564344.1712.30
DINGOViterbi seq.39.800.01425.080.08
DINGOViterbi tree7.130.21880.3812.84
DINGODANG seq.331.320.0213536.260.09
DINGODANG tree11.400.293577.1317.63

Table 7. Solver latency (ms) and peak solver GPU memory (GiB). All four solver variants are evaluated on 300 BFCL cases; the table displays cases near the 25th and 95th percentiles of DINGO graph node count. P25/P95 refer to graph size, not latency quantiles. “Ours” denotes DConstrain; “seq.” and “tree” denote sequential and tree-parallelized execution. DANG denotes the inference method of Dang & Ermon [5].

We consider the log-depth tree construction proposed by [5] and apply the same reduction to MAP inference for a direct comparison with the Viterbi-style decoding used by DINGO ([30]). Let LL denote the decoding-window length, SS the automaton states, and EE the grammar-transition structure. Conventional Viterbi inference performs position-wise dynamic programming, where state scores at position ii depend on those at position i−1i - 1, yielding a sequential dependency across the decoding window. Tree-based inference instead composes adjacent transition operators in a binary reduction tree, reducing the sequential depth from O(L)O(L) to O(log⁡L)O(\log L). For MAP inference, the same construction can be performed over the max-product semiring [12], preserving the Viterbi objective [32] while exposing tree-level parallelism.

This reduction trades sequential depth for substantially more computation and intermediate state. Under the state-space formulation, sequential message passing requires

O(L(∣S∣2+∣E∣∣V∣))(52)O\left(L\left(\lvert S\rvert^2+\lvert E\rvert\lvert V\rvert\right)\right) \tag*{(52)}

work, whereas the tree construction requires

O(L(∣S∣3+∣E∣∣V∣))(53)O\left(L\left(\lvert S\rvert^3+\lvert E\rvert\lvert V\rvert\right)\right) \tag*{(53)}

work while reducing the critical path to O(log⁡L)O(\log L). Dang and Ermon characterize this trade-off as an ∣S∣\lvert S\rvert-fold increase in message-passing FLOPs in exchange for greater GPU parallelism. The memory cost can also increase substantially: each interval in the reduction tree materializes a state-to-state transition summary of size O(∣S∣2)O(|S|^{2}). Retaining the summaries required by the subsequent top-down pass therefore requires O(L∣S∣2)O(L|S|^{2}) intermediate storage, compared with O(L∣S∣)O(L|S|) backpointer storage for conventional Viterbi reconstruction, or O(∣S∣)O(|S|) score storage when reconstruction is unnecessary. This quadratic dependence on the automaton state space can become expensive for large structured-output graphs.

Table 7 shows that the benefit of tree parallelism depends strongly on graph size. On the P25 DINGO graph, tree-parallelized Viterbi reduces latency from 39.8 ms to 7.13 ms, a 5.58× speedup, but remains slower than sequential Viterbi on the DConstrain graph at 3.90 ms. On the P95 DINGO graph, tree-parallelized Viterbi instead increases latency from 425.08 ms to 880.38 ms, while sequential Viterbi on the DConstrain graph requires only 30.85 ms. Peak solver GPU memory on the DINGO graph increases from 0.01 GiB to 0.21 GiB at P25 and from 0.08 GiB to 12.84 GiB at P95, approximately 21× and 167×, respectively. Tree parallelism also increases both latency and memory for Viterbi on the DConstrain graph in these two cases. These measurements illustrate that reducing sequential depth does not guarantee lower solver cost: as the graph grows, the additional dense intermediate computation and storage can dominate the available parallelism.

Compiled Representations with DiffusionGemma

Table 8 complements the LLaDA2.2 results in Table 5. DConstrain’s median recorded memory footprint is 4.10 MB on BFCL, 4.23 MB on JSONSchemaBench, and 4.57 MB on ComplexFuncBench; the corresponding P95 values are 5.39 MB, 28.41 MB, and 5.09 MB. State counts use the three-method successful intersection, while edge and memory quantiles use each method’s successful cases.

Table 8. Compiled representations with the DiffusionGemma tokenizer on fixed sets of 300 BFCL cases, 300 JSONSchemaBench schemas, and 1,000 ComplexFuncBench cases. Edges are reported in thousands; edge and memory columns show P50 and P95. Mean state counts use the three-method successful intersection (258, 202, and 421 cases, respectively); edge and memory quantiles use each method’s successful cases. States denote automaton states for baselines and local RTN nodes for DConstrain; edges are token-level versus symbolic. ‡Memory measures baseline edge-array payloads versus DConstrain’s recorded native-snapshot payloads, in decimal MB, rather than total process memory.

DatasetMethodStates ↓Edges (10310^3) ↓Memory (MB)‡ ↓
MeanP50P95P50P95
BFCLDINGO235.21884.932 070.6142.4999.46
NFA240.21593.881 774.7228.5385.25
DConstrain208.610.764.004.105.39
JSONSchemaBenchDINGO187.28591.322 066.6128.4099.24
NFA223.56596.353 001.7828.65144.16
DConstrain169.920.8551.804.2328.41
ComplexFuncBenchDINGO460.211 776.403 252.1685.32156.17
NFA465.212 365.893 842.17113.62184.51
DConstrain424.232.353.704.575.09

caption: Compiled representation and memory footprint

To complement the any-order compilation results in Table 1, Table 9 compares the compiled representations produced by DINGO-Opt and DConstrain under the native tool-call protocols. All representation statistics are computed on the same successful intersection within each setting. Because DConstrain succeeds on every evaluated case, the intersection size nn is determined by the finite-state baseline’s compilation coverage. The results show that arbitrary property order leads to very large context-expanded transition structures for DINGO-Opt, whereas DConstrain retains compact local RTN nodes and symbolic transitions.

Table 9. Compiled representations under native tool-call protocols with arbitrary parameter-field order. Statistics use the common successful intersection within each setting. States denote DFA states for DINGO-Opt and local RTN nodes for DConstrain; edges denote token-level and symbolic transitions, respectively. DConstrain successfully compiles every evaluated case.

TokenizerDatasetDepthSuccessMethodStatesEdges (10310^3)Payload (MB)
MeanP50P95P50P95
LLaDA2.2BFCL4213/300DINGO-Opt655.9249 124.94161 307.592 358.167 743.37
DConstrain164.983.278.87––
CFB499/1000DINGO-Opt409.1977 163.56169 703.333 704.118 146.34
DConstrain247.529.6515.14––
DiffusionGemmaBFCL42141/2495DINGO-Opt1 737.949 178.1965 604.92440.593 149.94
DConstrain481.190.963.583.464.20
CFB4137/1000DINGO-Opt1 379.6919 669.0762 942.46944.233 021.61
DConstrain693.852.283.613.663.86

caption:

Cold Compilation with Additional Tokenizers

To evaluate whether DConstrain’s compilation behavior depends on the two tokenizers used in the main experiments, we additionally compile the same structured-output workloads with the Dream 7B and LLaDA 8B tokenizers. These experiments evaluate compilation only and do not run model inference. All settings use arbitrary property order and the same recursive structured-output grammar configuration.

Table 10 shows that DConstrain retains high compilation coverage and sub-second median cold-compilation latency across both additional tokenizers. BFCL and ComplexFuncBench compile successfully in all cases, while JSONSchemaBench succeeds on 281 of 300 evaluated schemas. The identical local-state counts across tokenizers reflect the tokenizer-independent pushdown grammar structure, while token-dependent symbolic transitions, payload size, and compilation latency vary with tokenization. These results indicate that the factorized compilation design is not specific to the LLaDA2.2 or DiffusionGemma tokenizers used in the main experiments.

TokenizerDatasetSuccessStatesEdges (10310^3)
MeanP50P95P50P95P50P95
Dream 7BBFCL300/300416.250.924.242.774.080.361.05
JSONSchemaBench281/300616.651.03157.532.7824.710.3812.85
ComplexFuncBench1000/1000770.052.834.393.223.690.670.97
LLaDA 8BBFCL300/300416.250.854.002.093.030.310.81
JSONSchemaBench281/300616.650.93138.532.0814.900.3310.78
ComplexFuncBench1000/1000770.052.634.062.452.800.600.84

Table 10. Any-order cold compilation with Dream 7B and LLaDA 8B tokenizers. All runs use the same recursive structured-output grammar configuration and nesting bounds of 8/8. Statistics use successful compilations; Success reports coverage. States are mean local RTN node counts, edges are symbolic transitions, and payload is the schema-exclusive native-snapshot footprint in decimal MB. Cold compilation uses 64 concurrent single-threaded workers.

Failure Analysis on JSONSchemaBench

We further analyze the remaining DConstrain compilation failures on JSONSchemaBench with the LLaDA2.2 tokenizer. Table 11 categorizes all 1,072 failed schemas out of 5,754, corresponding to an 18.6% failure rate and an 81.4% success rate. Most failures arise from unsupported schema semantics rather than compiler execution failures: semantic-coverage limitations account for 789 cases (13.7% of the full benchmark and 73.6% of all failures). Resource limits account for another 274 cases (4.8% of the benchmark), primarily RSS exhaustion and the 180 s compilation timeout. Only nine cases (0.2%) are attributable to known implementation errors or unresolved compiler behavior.

Failure causeCasesFull set (%)
Schema coverage and semantic limitations
Unsupported keyword or keyword combination2855.0
oneOf branch exclusivity not provable1783.1
General allOf intersection unsupported1272.2
Nested resource scopes (id/$id) unsupported | 127 | 2.2
Nested schema-dialect switching unsupported280.5
Dynamic-property constraints conflict with empty-object subset380.7
Regular expression outside supported dialect40.1
Tuple-style items unsupported10.0
$ref and outer-type intersection not provable | 1 | 0.0
Resource and construction limits
State/transition/closure or pattern-size budget exceeded681.2
RSS limit exceeded1342.3
Compilation timeout721.3
Implementation and unresolved failures
_deduplicate_json_values implementation error40.1
Duplicate enum values rejected30.1
Compiled language unexpectedly empty20.0
Total failures1,07218.6

Table 11. Failure breakdown for DConstrain on JSONSchemaBench with the LLaDA2.2 tokenizer. Percentages are relative to all 5,754 schemas and rounded to one decimal place; the total is calculated from counts before rounding.

The dominant failure modes therefore reflect the current supported schema fragment rather than failures of the factorized compilation mechanism itself. In particular, oneOf/allOf reasoning and nested resource semantics account for a substantial fraction of unsupported cases. Resource failures form the second-largest category, showing that although DConstrain substantially reduces context expansion, sufficiently complex schemas can still exceed finite construction or memory budgets.

Localizing frontend coverage limitations. To separate frontend coverage from factorized execution, we replayed the 178 oneOf branch-disjointness rejections and 127 general allOf rejections in Table 11 using the archived frontend from the reported experiment. All 305 rejections were reproduced by the schema-to-parser frontend alone, without invoking the factorized token compiler. These failures therefore precede factorized execution; their localization does not establish that downstream compilation would succeed after extending the frontend.

Frontend acceptance versus semantic preservation. We examined the same 305 original schemas using XGrammar [7]. With strict_mode=True, XGrammar 0.2.8 returned grammars for 298 schemas. A bounded search identified 124 distinct schemas for which the native matcher accepted a complete JSON text that violated the original schema. We independently replayed all 124 counterexamples and confirmed their invalidity with jsonschema 4.26.0; 104 were also confirmed by fastjsonschema 2.22.2. We additionally found valid instances for 86 schemas, establishing their satisfiability. Replaying the same invalid texts in XGrammar 0.1.27 reproduced violations for 123 schemas. Table 12 summarizes these results.

Historical rejectionCasesCompiled XG 0.2.8Counterexamples XG 0.2.8Same witnesses XG 0.1.27
oneOf disjointness1781754342
General allOf1271238181
Total305298124123

Table 12. Targeted semantic audit of 305 historical DConstrain rejections. All counts refer to schemas. Counterexamples are complete JSON texts accepted by XGrammar but rejected under the original schema. Rows use DConstrain’s first rejection cause, which need not match the constraint violated by the witness. Counterexample counts are lower bounds from a bounded search; absence of a witness does not establish semantic preservation.

The audit used an empty tokenizer and the native complete-string matching interface, requiring an accepting terminal state. It therefore tests membership in the compiled character language, rather than compilation against the LLaDA2.2 vocabulary or the likelihood of generating these texts during model inference. Validation followed each schema’s declared dialect, defaulting to Draft 2020-12 when unspecified. Optional format assertions and network reference retrieval were disabled.

For example, JSB schema o41599 specifies oneOf over integer, string, number, boolean, and null. Both tested XGrammar versions accept 0, which satisfies both the integer and number branches and thus violates the exactly-one requirement. Similarly, schema o4455 explicitly requires an object and contains a multi-branch allOf, yet both matchers accept 0. Both examples were confirmed by both validators.

Scope of the conclusions. Frontend acceptance alone is insufficient evidence that the original schema constraints are preserved. This targeted audit does not estimate overall semantic accuracy, establish DConstrain’s semantic correctness on all accepted schemas, or imply that every rejected schema is intrinsically difficult. We distinguish execution correctness relative to supported reference-parser semantics from frontend coverage and resource-bounded construction. Incomplete coverage, resource failures, and implementation issues remain limitations of the current system.

Limitations. DConstrain substantially reduces the cost of nested constraints during cold compilation by retaining a symbolic RTN representation rather than expanding stack contexts into finite states, and this representation can in principle express context-free structure. However, factorization does not eliminate the worst-case complexity of joint inference. During warm compilation, uncertainty over unresolved token choices can propagate across the decoding canvas and induce a rapidly growing set of reachable runtime contexts; in the worst case, this expansion can still be exponential in nesting depth or other sources of branching. DConstrain therefore extends the practical nesting depth substantially relative to finite-state baselines, but it does not provide unbounded or uniformly efficient compilation for arbitrary deeply nested grammars.

References

  1. [1]Marianne Arriola, Aaron Gokaslan, Justin T. Chiu, Zhihan Yang, Zhixuan Qi, Jiaqi Han, Subham Sekhar Sahoo, and Volodymyr Kuleshov. Block diffusion: Interpolating between autoregressive and diffusion language models. In International Conference on Learning Representations, 2025. URL https://openreview.net/forum?id=tyEyYT267x.arxiv.org/abs/2503.09573
  2. [2]Jacob Austin, Daniel D. Johnson, Jonathan Ho, Daniel Tarlow, and Rianne van den Berg. Structured Denoising Diffusion Models in Discrete State-Spaces. In Advances in Neural Information Processing Systems, volume 34, pp. 17981–17993, 2021. URL https://proceedings.neurips.cc/paper/2021/hash/958c530554f78bdc8e97125b70e6973d-Abstract.html.arxiv.org/abs/2107.03006
  3. [3]Luca Beurer-Kellner, Marc Fischer, and Martin Vechev. Guiding LLMs the right way: Fast, non-invasive constrained generation. In International Conference on Machine Learning, pp. 3658–3673, 2024. URL https://proceedings.mlr.press/v235/beurer-kellner24a.html.
  4. [4]Tiwei Bie, Jiansheng Cai, Maosong Cao, Xiang Cao, Binbin Chen, Fuyuan Chen, Kun Chen, Yuqi Ding, Lun Du, Zhuocheng Gong, Yanmei Gu, Kaiyuan Guan, Xiaoxu Guo, Kairong Han, Zenan Huang, Zijin Huang, Zhenzhong Lan, Chengxi Li, Jianguo Li, Zhe Li, Ruiqi Liang, Xinyao Lin, Huabin Liu, Lin Liu, Xinyi Liu, Xuejie Liu, Guoshan Lu, Yuan Lu, Yuxin Ma, Chenhui Mao, Xiaojing Qi, Kaida Qiu, Xiaoyu Shi, Yiding Tian, Huanyu Wang, Qi Wang, Rui Wang, Shuaidi Wang, Lanning Wei, Tao Wu, Siyang Xiao, Yipeng Xing, Chenkai Xu, Song Yan, Ying Yan, Jingyi Yang, Yichun Yang, Liangyu Zha, Tianze Zhang, Yifan Zhang, Junbo Zhao, Wenqian Zhao, Da Zheng, Jianyuan Zhong, Jiahao Zhou, Junlin Zhou, Tianyu Zhou, Liwang Zhu, and Yihong Zhuang. LLaDA2.2: Enabling agentic diffusion language models via levenshtein editing. Technical report, Inclusion AI, 2026. URL https://github.com/inclusionAI/LLaDA2.X/blob/main/LLaDA2_2_tech_report.pdf.
  5. [5]Meihua Dang and Stefano Ermon. Constrained decoding for diffusion language models via efficient inference over finite automata, 2026. URL https://arxiv.org/abs/2607.07026. arXiv:2607.07026.
  6. [6]DiffusionGemma Team, Adrien Ali Taiga, James Assienne, Daniele Calandriello, Rahma Chaabouni, João Gante, Tamara von Glehn, Nate Keating, Chris Knutsen, Martin Kukla, Tianlin Liu, Ivan Lobov, Ofir Nabati, João Gabriel Oliveira, Nicolas Perez-Nieves, Nastasia Prutianova, Bobak Shahriari, Jean Tarbouriech, Pavel Tyelitski, Çağlar Ünlü, Cindy Wu, Glenn Cameron, Jerome Connor, Sertan Girgin, Maarten Grootendorst, Alon Levkovitch, Eliya Nachmani, Omar Sanseviero, Piotr Stanczyk, Quentin Berthet, Andrew Campbell, Clément Crepy, Valentin De Bortoli, Arnaud Doucet, Romuald Elie, Alexandre Galashov, Klaus Greff, Alexis Jacq, David Ruhe, Yu-Han Wu, Sebastian Flennerhag, Brendan O’Donoghue, George Scrivener, and Shantanu Thakoor. DiffusionGemma Technical Report, 2026. URL https://arxiv.org/abs/2608.00146. arXiv:2608.00146.
  7. [7]Yixin Dong, Charlie F. Ruan, Yaxing Cai, Ruihang Lai, Ziyi Xu, Yilong Zhao, and Tianqi Chen. XGrammar: Flexible and efficient structured generation engine for large language models. In Proceedings of Machine Learning and Systems, volume 7. MLSys, 2025. URL https://proceedings.mlsys.org/paper_files/paper/2025/hash/5c20ca4b0b0bbd2f1d839dc605e70f-Abstract-Conference.html.arxiv.org/abs/2411.15100
  8. [8]Jay Earley. An efficient context-free parsing algorithm. Communications of the ACM, 13(2):94–102, 1970. doi: 10.1145/362007.362035. URL https://doi.org/10.1145/362007.362035.
  9. [9]Keith Ellul, Bryan Krawetz, Jeffrey Shallit, and Ming wei Wang. Regular expressions: New results and open problems. Journal of Automata, Languages and Combinatorics, 10(4):407–437, 2005. URL https://jalc.de/issues/2005/issue_10_4/abs-407.pdf.DOI
  10. [10]Saibo Geng, Martin Josifoski, Maxime Peyrard, and Robert West. Grammar-constrained decoding for structured NLP tasks without finetuning. In Proceedings of the 2023 Conference on Empirical Methods in Natural Language Processing, pp. 10932–10952. Association for Computational Linguistics, 2023. doi: 10.18653/v1/2023.emnlp-main.674. URL https://aclanthology.org/2023.emnlp-main.674/.DOI
  11. [11]Saibo Geng, Hudson Cooper, Michal Moskal, Samuel Jenkins, Julian Berman, Nathan Ranchin, Robert West, Eric Horvitz, and Harsha Nori. JSONSchemaBench: A Rigorous Benchmark of Structured Outputs for Language Models, 2025. URL https://arxiv.org/abs/2501.10868. arXiv:2501.10868.
  12. [12]Joshua Goodman. Semiring parsing. Computational Linguistics, 25(4):573–606, 1999. URL https://aclanthology.org/J99-4004/.
  13. [13]John E. Hopcroft, Rajeev Motwani, and Jeffrey D. Ullman. Introduction to Automata Theory, Languages, and Computation. Pearson/Addison-Wesley, third edition, 2007. ISBN 978-0-321-45536-9.
  14. [14]Hyundong Jin and Yo-Sub Han. EPIC: Efficient and parallel inference under CFG constraints for diffusion language models, 2026. URL https://arxiv.org/abs/2606.00722. arXiv:2606.00722.
  15. [15]Terry Koo, Frederick Liu, and Luheng He. Automata-based constraints for language model decoding. In Conference on Language Modeling, 2024. URL https://openreview.net/forum?id=BDbblmyzY.arxiv.org/abs/2407.08103
  16. [16]Woosuk Kwon, Zhuohan Li, Siyuan Zhuang, Ying Sheng, Lianmin Zheng, Cody Hao Yu, Joseph E. Gonzalez, Hao Zhang, and Ion Stoica. Efficient Memory Management for Large Language Model Serving with PagedAttention. In Proceedings of the 29th Symposium on Operating Systems Principles, pp. 611–626, 2023. doi: 10.1145/3600006.3613165. URL https://doi.org/10.1145/3600006.3613165.
  17. [17]Linzhang Li, Yixin Dong, Guanjie Wang, Ziyi Xu, Alexander Jiang, and Tianqi Chen. XGrammar-2: Dynamic and efficient structured generation engine for agentic LLMs, 2026. URL https://arxiv.org/abs/2601.04426. arXiv:2601.04426.
  18. [18]Xiang Lisa Li, John Thickstun, Ishaan Gulrajani, Percy Liang, and Tatsunori Hashimoto. Diffusion-LM improves controllable text generation. In Advances in Neural Information Processing Systems, volume 35, pp. 4328–4343, 2022. doi: 10.52202/068431-0313. URL https://doi.org/10.52202/068431-0313.
  19. [19]Aaron Lou, Chenlin Meng, and Stefano Ermon. Discrete Diffusion Modeling by Estimating the Ratios of the Data Distribution. In International Conference on Machine Learning, pp. 32819–32848, 2024. URL https://proceedings.mlr.press/v235/lou24a.html.arxiv.org/abs/2310.16834
  20. [20]Michał Moskal, Harsha Nori, Hudson Cooper, and Loc Huynh. LLGuidance: Making structured outputs go brrr. Microsoft technical article, 2025. URL https://guidance-ai.github.io/llguidance/llg-go-brrr. June 11, 2025.
  21. [21]Niels Mündler, Jasper Dekoninck, and Martin Vechev. Constrained decoding of diffusion LLMs with context-free grammars. In International Conference on Learning Representations, pp. 99362–99408, 2026. URL https://proceedings.iclr.cc/paper_files/paper/2026/hash/a1622fc2f8e37ea5fc696d1c13861c36-Abstract-Conference.html.arxiv.org/abs/2508.10111
  22. [22]Shen Nie, Fengqi Zhu, Zebin You, Xiaolu Zhang, Jingyang Ou, Jun Hu, Jun Zhou, Yankai Lin, Ji-Rong Wen, and Chongxuan Li. Large Language Diffusion Models. In Advances in Neural Information Processing Systems, volume 38, pp. 50608–50646, 2025. doi: 10.52202/085713-1689. URL https://proceedings.neurips.cc/paper_files/paper/2025/hash/48b383b24230e0e6e649d9c98dae4d8c-Abstract-Conference.html.DOI
  23. [23]Kanghee Park, Jiayu Wang, Taylor Berg-Kirkpatrick, Nadia Polikarpova, and Loris D’Antoni. Grammar-Aligned Decoding. In Advances in Neural Information Processing Systems, volume 37, pp. 24547–24568, 2024. doi: 10.52202/079017-0774. URL https://proceedings.neurips.cc/paper_files/paper/2024/hash/2bdc2267c3d7d01523e2e17ac0a754f3-Abstract-Conference.html.DOI
  24. [24]Shishir G Patil, Huanzhi Mao, Fanjia Yan, Charlie Cheng-Jie Ji, Vishnu Suresh, Ion Stoica, and Joseph E. Gonzalez. The Berkeley Function Calling Leaderboard (BFCL): From Tool Use to Agentic Evaluation of Large Language Models. In International Conference on Machine Learning, pp. 48371–48392, 2025. URL https://proceedings.mlr.press/v267/patil25a.html.
  25. [25]Gabriel Poesia, Oleksandr Polozov, Vu Le, Ashish Tiwari, Gustavo Soares, Christopher Meek, and Sumit Gulwani. Synchromesh: Reliable code generation from pre-trained language models. In International Conference on Learning Representations, 2022. URL https://openreview.net/forum?id=KmtVD97J43e.arxiv.org/abs/2201.11227
  26. [27]Subham S. Sahoo, Marianne Arriola, Yair Schiff, Aaron Gokaslan, Edgar Marroquin, Justin T. Chiu, Alexander Rush, and Volodymyr Kuleshov. Simple and Effective Masked Diffusion Language Models. In Advances in Neural Information Processing Systems, volume 37, pp. 130136–130184, 2024. doi: 10.52202/079017-4135. URL https://proceedings.neurips.cc/paper_files/paper/2024/hash/eb0b13cc515724ab8015bc978fdde0ad-Abstract-Conference.html.
  27. [28]Timo Schick, Jane Dwivedi-Yu, Roberto Dessi, Roberta Raileanu, Maria Lomeli, Eric Hambro, Luke Zettlemoyer, Nicola Cancedda, and Thomas Scialom. Toolformer: Language models can teach themselves to use tools. In Advances in Neural Information Processing Systems, volume 36, pp. 68539–68551, 2023. doi: 10.52202/075280-2997. URL https://doi.org/10.52202/075280-2997.
  28. [29]Torsten Scholak, Nathan Schucher, and Dzmitry Bahdanau. PICARD: Parsing incrementally for constrained auto-regressive decoding from language models. In Proceedings of the 2021 Conference on Empirical Methods in Natural Language Processing, pp. 9895–9901. Association for Computational Linguistics, 2021. doi: 10.18653/v1/2021.emnlp-main.779. URL https://aclanthology.org/2021.emnlp-main.779/.DOI
  29. [30]Tarun Suresh, Debangshu Banerjee, Shubham Ugare, Sasa Misailovic, and Gagandeep Singh. DINGO: Constrained inference for diffusion LLMs. In Advances in Neural Information Processing Systems, volume 38, pp. 160518–160551. Curran Associates, Inc., 2025. doi: 10.52202/085713-5362. URL https://proceedings.neurips.cc/paper_files/paper/2025/hash/eb17a2030d1bd4a1bd29531bcd626705-Abstract-Conference.html.DOI
  30. [31]Aditya Thimmaiah, Lara Marinov, Jayanth Srinivasa, Haris Vikalo, Junyi Jessy Li, and Milos Gligoric. Twist, don’t tilt: Trajectory-exact constrained decoding for masked diffusion models, 2026. URL https://arxiv.org/abs/2609.35609. arXiv:2609.35609.
  31. [32]A. Viterbi. Error bounds for convolutional codes and an asymptotically optimum decoding algorithm. IEEE Transactions on Information Theory, 13(2):260–269, 1967. doi: 10.1109/tit.1967.1054010. URL https://doi.org/10.1109/tit.1967.1054010.
  32. [33]Brandon T. Willard and Rémi Louf. Efficient Guided Generation for Large Language Models, 2023. URL https://arxiv.org/abs/2307.09702. arXiv:2307.09702.
  33. [34]William A. Woods. Transition network grammars for natural language analysis. Communications of the ACM, 13(10):591–606, 1970. doi: 10.1145/355598.362773. URL https://doi.org/10.1145/355598.362773.
  34. [35]Austin Wright, Henry Andrews, Ben Hutton, and Greg Dennis. JSON Schema: A media type for describing JSON documents, 2022. URL https://json-schema.org/draft/2020-12/json-schema-core. Internet-Draft draft-bhutton-json-schema-01 (JSON Schema Draft 2020-12).
  35. [36]Jiacheng Ye, Zhibhui Xie, Lin Zheng, Jiahui Gao, Zirui Wu, Xin Jiang, Zhenguo Li, and Lingpeng Kong. Dream 7B: Diffusion Large Language Models, 2025. URL https://arxiv.org/abs/2508.15487. arXiv:2508.15487.
  36. [37]Yitong Zhang, Yongmin Li, Yuetong Liu, Jia Li, Xiaoran Jia, Zherui Li, and Ge Li. Lookahead-then-Verify: Reliable Constrained Decoding for Diffusion LLMs under Context-Free Grammars, 2026. URL https://arxiv.org/abs/2602.00612. arXiv:2602.00612.
  37. [38]Lianmin Zheng, Liangsheng Yin, Zhiqiang Xie, Chuyue Sun, Jeff Huang, Cody H. Yu, Shiyi Cao, Christos Kozyrakis, Ion Stoica, Joseph E. Gonzalez, Clark Barrett, and Ying Sheng. SGLang: Efficient Execution of Structured Language Model Programs. In Advances in Neural Information Processing Systems, volume 37, pp. 62557–62583, 2024. doi: 10.52202/079017-2000. URL https://proceedings.neurips.cc/paper_files/paper/2024/hash/724be4472168f31ba1c9ac630f15dec8-Abstract-Conference.html.DOI
  38. [39]Lucen Zhong, Zhengxiao Du, Xiaohan Zhang, Haiyi Hu, and Jie Tang. ComplexFuncBench: Exploring Multi-Step and Constrained Function Calling under Long-Context Scenario, 2025. URL https://arxiv.org/abs/2501.10132. arXiv:2501.10132.

Paper details

vlnc:W_wngsqjyw
v1 · latestHistory (1)

published · Fresh — added to the Hub within the last 30 days

added ·

Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

CC BY 4.0

Original source

  • Computer Science

Not recorded for this paper · View statement →

Looking for related papers…
Contents