betaFeedback

WorksComputer Science

TraceQuery: learning what to recompute from full-denoising trajectory in diffusion language models

Abstract

Diffusion large language models (dLLMs) enable flexible generation through iterative masked denoising, but incur substantial inference cost because token representations are repeatedly recomputed across denoising steps. Existing cache-based methods reduce this cost by reusing intermediate results across denoising steps and recomputing only a subset of positions at each step, chosen either on a fixed schedule or by heuristic signals of change. Our trajectory experiments instead point to decoding trajectory as the more relevant quantity. Cached generation remains accurate when it stays close to the full-denoising trajectory, with errors concentrated around unmask-order deviations and reduced as longer reference prefixes are recovered. This suggests a more direct principle: limiting representation error helps, but keeping generation on the full-denoising trajectory is a more direct route to accurate decoding. We therefore formulate efficient dLLM inference as trajectory-guided querying. Rather than broadly repairing representation error, we use full-denoising trajectories to supervise which unresolved positions should receive limited fresh computation. Based on this formulation, we introduce TRACEQUERY, a lightweight sparse decoding framework that predicts a small set of near-future trajectory-relevant positions, queries only those candidates, and lets the backbone select which one to commit from their fresh predictions. TRACEQUERY delivers the strongest quality-computation trade-off among cache-based approaches, sustaining high accuracy with substantially fewer fresh token computations, and generalizes across tasks, model variants, and families. Code: https://github.com/fish1928/tracequery.git

Code: https://github.com/fish1928/tracequery.git

Introduction

Diffusion large language models (dLLMs) have emerged as a promising alternative to autoregressive language models by replacing fixed left-to-right generation with iterative masked denoising (Sahoo et al., 2024; Ou et al., 2025; Nie et al., 2026). By repeatedly predicting unresolved tokens under bidirectional attention, dLLMs support flexible generation orders and expose opportunities for parallel decoding [7] (Ye et al. 2025; Song et al. 2025). However, these advantages come with substantial inference cost. At each denoising step, standard dLLMs repeatedly recompute token representations over large portions of the sequence, even though only one or a few tokens may ultimately be committed [4, 3]. When the number of denoising steps grows with generation length, this redundant recomputation can lead to cubic decoding cost [10] (Ma et al. 2026). To reduce this redundancy, recent work maintains an approximate KV cache across denoising steps, reusing stable representations and selectively refreshing only a subset of positions [10, 6] (Ma et al. 2026; Wu et al. 2026). Despite increasingly fine-grained refresh policies, these methods share a common objective: limiting the representation error introduced by cache reuse.

We revisit this objective by examining how cached decoding behaves relative to full denoising. Our trajectory analysis (Figure 1) shows that cached decoding deviates from the full-denoising unmasking order even when token-level predictions agree. Accuracy also drops as the injected fulldenoising prefix shortens, tying quality to keeping generation anchored to the reference trajectory. These observations motivate the following causal view:

Figure 1. Trajectory agreement and dependence on trajectory guidance. (a) We compare decoding progress under full denoising and cached decoding. Each underlying observation corresponds to a token position, paired by the step at which it is unmasked under full denoising and its corresponding step under cached decoding. Rather than plotting individual observations, we show the 80% density contours. Concentration along the diagonal indicates agreement with the full-denoising unmask order, while broader deviations reflect trajectory divergence. (b) Accuracy on examples solved by full denoising as the injected full-denoising prefix is progressively removed.

representation error→decision perturbation→trajectory divergence→quality degradation.\mathit{representation\ error} \to\mathit{decision\ perturbation} \to\mathit{trajectory\ divergence} \to\mathit{quality\ degradation}.

Refreshing cache entries intervenes at the first link of this chain by reducing representation error, but it controls decision perturbation and trajectory divergence only indirectly. The link from representation error to decoding decisions is highly non-uniform. Many errors are decision-irrelevant and leave the next commitment unchanged, while a small subset can alter a consequential decision and redirect the subsequent trajectory. This makes representation repair inefficient, because computation may be spent correcting harmless errors, while even useful corrections must propagate through later representations and decisions before improving the decoding trajectory. This suggests a more direct principle: limiting representation error helps, but keeping generation on the full-denoising trajectory is a more direct route to accurate decoding.

This view gives the full-denoising trajectory a new role. A full-denoising run provides a sequence of decisions made by the original backbone from fully recomputed representations, without cache-induced error. Although multiple decoding trajectories may lead to equally good generations, this trajectory is immediately available from the model itself and requires neither additional trajectory search nor external supervision. It therefore provides a natural, unapproximated reference for anticipating the decoding decisions that lie in the near future.

Based on this view, we formulate efficient dLLM inference as trajectory-guided querying. Rather than searching for an optimal trajectory, we use the already available full-denoising trajectory to guide where a limited query budget should be spent. At each denoising step, the objective is to identify unresolved positions that appear soon along the full-denoising reference trajectory and include them in a small fresh-query set. Importantly, the trajectory does not determine the final decoding decision. It supervises candidate selection, while the backbone queries the selected candidates with fresh computation and retains control over which position to commit.

We introduce TRACEQUERY, a lightweight trajectory-guided sparse decoding framework illustrated in Figure 2. During training, TRACEQUERY learns from full-denoising trajectories to rank unresolved positions according to their near-future relevance. During inference, it selects a small candidate set from inexpensive signals available in the current decoding state. Only these candidates receive fresh computation, while the remaining positions continue to reuse cached representations. The backbone dLLM then selects the final commitment from the freshly evaluated candidates. TRACEQUERY therefore splits the two decisions: the router decides where fresh computation goes, and the backbone decides what to commit.

Overview of TRACEQUERY inference and router training

Figure 2. Overview of TRACEQUERY. Full denoising first provides an offline reference trajectory describing the future order of decoding decisions. The router is trained to recover the near-future portion of this trajectory from inexpensive signals available during decoding. At inference time, after step tt commits AtA_t, the router ranks the remaining unresolved positions and selects a small query set Qt+1Q_{t+1}. Only these positions receive fresh computation, while other positions reuse cached representations. The backbone dLLM then makes the final commitment from the freshly queried candidates. Periodic broad recomputation is retained to control accumulated approximation error.

Our main contributions are summarized as follows:

  • We propose trajectory-guided querying. Representation error degrades generation through perturbed consequential decisions, so rather than spending limited computation to repair the error, we let the available full-denoising trajectory guide it directly toward the decisions that lie ahead.

  • We build TRACEQUERY, a lightweight sparse decoding framework that implements this formulation with a router trained on full-denoising trajectories. From inexpensive decoding-state signals, the router decides which few positions receive fresh computation, and the backbone decides what to commit from the freshly evaluated candidates.

  • A single learned router approaches full-denoising quality with substantially fewer fresh token computations across tasks, model variants, and dLLM families, improving the quality–computation trade-off over cache-based baselines.

Related Work

Diffusion language models generate text through iterative masked denoising rather than fixed left-to-right factorization, enabling bidirectional context and flexible decoding orders [2, 8, 11] (Sahoo et al. 2024; Ou et al. 2025). Recent large-scale models such as LLaDA and Dream demonstrate that this paradigm can scale to competitive language modeling and reasoning performance (Nie et al., 2026; Ye et al., 2025), while systems such as Seed and Mercury further highlight its potential for parallel generation [7] (Song et al. 2025).

Learned and Trajectory-Aware Decoding. Prior methods learn, search, guide, or verify unmasking decisions and denoising trajectories [5, 9, 4] (Pan et al. 2026). TRACEQUERY instead learns which masked positions to query: its router allocates fresh computation, while the backbone determines the committed position and token. Full-denoising trajectories provide offline supervision, with no external guider, online search, or draft verification at inference.

KV Reuse and Adaptive Refresh. Exact KV reuse is difficult in dLLMs because bidirectional attention changes token representations as decoding proceeds. Early methods reuse states across completed blocks [1] or stabilized regions, with periodic recomputation to limit staleness [4] (Wu et al. 2026). dKV (Ma et al., 2026) identifies local fidelity: each decoding decision changes representations most strongly at a limited set of positions, making uniform refresh unnecessary. Building on this principle, dLLM-Cache [10] uses V-state verification to select refresh positions, while d2Cache [6] combines confidence and local mask density for unresolved positions with attention-based selection for prompt and decoded positions. These methods adapt which cached states to refresh; TRACEQUERY focuses on which unresolved positions receive fresh queries before the next commitment.

Different from the above works, our analysis suggests that the downstream effect of cache-induced error is more closely reflected by trajectory deviation than by representation error alone. We use the available full-denoising trajectory to guide fresh computation toward positions that are likely to matter for upcoming decoding decisions.

Preliminaries

This section introduces masked diffusion decoding, the full-denoising reference trajectory, and the cache setting used by TRACEQUERY. These definitions apply to both single-block and block-wise diffusion decoding.

Masked Diffusion Decoding

A masked diffusion language model operates on a partially masked sequence x(t)x^{(t)} at denoising step tt. Let Mt\mathcal{M}_t and Ut\mathcal{U}_t denote the unresolved and already-resolved positions, respectively. The model predicts token distributions for positions in Mt\mathcal{M}_t in parallel, and a decoding policy selects a subset At⊆Mt\mathcal{A}_t \subseteq\mathcal{M}_t to commit:

pDLLM(x1:N∣τ)=∏t=0T−1∏i∈Atpθ(xi∣x(t)),τ=(A0,…,AT−1),(1)p_{\mathrm{DLLM}}(x_{1:N}\mid\tau)=\prod_{t=0}^{T-1}\prod_{i\in\mathcal{A}_t}p_\theta(x_i\mid x^{(t)}),\qquad\tau=(\mathcal{A}_0,\ldots,\mathcal{A}_{T-1}), \tag*{(1)}

where NN is the sequence length, TT is the number of denoising steps, and τ\tau denotes the decoding trajectory induced by the sequence of commitments. After committing At\mathcal{A}_t, the resolved and unresolved sets evolve as

Ut+1=Ut∪At,Mt+1=Mt∖At.(2)\mathcal{U}_{t+1}=\mathcal{U}_t\cup\mathcal{A}_t,\qquad\mathcal{M}_{t+1}=\mathcal{M}_t\setminus\mathcal{A}_t. \tag*{(2)}

Under single-token decoding, At={it}\mathcal{A}_t=\{i_t\}, where iti_t is the position selected at step tt. Unlike autoregressive decoding, tt specifies only temporal progression and is not tied to a fixed sequence position. Consequently, the ordering of committed positions itself becomes part of the decoding process.

Full-Denoising Reference Trajectory

For a given prompt, we fix the backbone model, decoding policy, denoising schedule, and token-sampling configuration. At each denoising step, the full-denoising baseline performs a forward pass over the entire active generation region and recomputes the representations used to make the next commitment. In particular, it does not reuse approximate representations from earlier denoising steps. The decoding policy then selects the next position from predictions obtained using these fully recomputed representations.

Let AtFD\mathcal{A}^{\mathrm{FD}}_t denote the set of positions committed at step tt by full denoising. Under single-token decoding, AtFD={itFD}\mathcal{A}^{\mathrm{FD}}_t=\{i^{\mathrm{FD}}_t\}, and we define the full-denoising reference trajectory as

τFD=(A0FD,…,AT−1FD)=(i0FD,…,iT−1FD).(3)\tau^{\mathrm{FD}}=(\mathcal{A}^{\mathrm{FD}}_0,\ldots,\mathcal{A}^{\mathrm{FD}}_{T-1})=(i^{\mathrm{FD}}_0,\ldots,i^{\mathrm{FD}}_{T-1}). \tag*{(3)}

The trajectory records only the order in which positions are unmasked; it does not include the identities of the committed tokens. The superscript FD indicates that the corresponding decisions are produced by full denoising. We use τFD\tau^{\mathrm{FD}} as an operational reference for the behavior of the unmodified backbone and decoding policy in the absence of cache-induced approximation. It is neither assumed to be the unique decoding trajectory nor guaranteed to produce a correct or optimal output. Nevertheless, it can be generated offline directly from the frozen backbone, without external annotations or additional trajectory search, and therefore provides a well-defined target for supervising and evaluating trajectory agreement under cached decoding.

Cached Diffusion Inference

We partition the sequence into three regions: the prefix P\mathcal{P}, the active generation region G\mathcal{G}, and the postfix S\mathcal{S}. Previously completed blocks belong to P\mathcal{P}, while subsequent blocks belong to S\mathcal{S}. At denoising step tt, the active generation region is partitioned into

G=Ut∪Mt,Ut∩Mt=∅.(4)\mathcal{G}=\mathcal{U}_t\cup\mathcal{M}_t,\qquad\mathcal{U}_t\cap\mathcal{M}_t=\varnothing. \tag*{(4)}

Decoding starts with a full forward pass to initialize the persistent KV cache. Following existing region-wise caching strategies (Wu et al., 2026; Liu et al., 2026b), the active generation region is periodically recomputed to control accumulated approximation error, while the prefix and postfix are reused over longer intervals. TRACEQUERY operates only within the active generation region G\mathcal{G}.

Methodology

Trajectory Recovery under a Query Budget

Let τFD\tau^{\mathrm{FD}} be the full-denoising reference trajectory defined in § 3.2. After step tt, its remaining ordered suffix is

πtFD=(it+1FD,…,iT−1FD).(5)\pi_t^{\mathrm{FD}} = \left(i_{t+1}^{\mathrm{FD}}, \ldots, i_{T-1}^{\mathrm{FD}}\right). \tag*{(5)}

Given a maximum query horizon HH, we define

Ht=min⁡(H,∣Mt+1FD∣),πt,HtFD=(it+1FD,…,it+HtFD),Qt+1oracle={it+1FD,…,it+HtFD}.(6)\begin{aligned} H_t &= \min\left(H,\left|\mathcal{M}_{t+1}^{\mathrm{FD}}\right|\right),\\ \pi_{t,H_t}^{\mathrm{FD}} &= \left(i_{t+1}^{\mathrm{FD}},\ldots,i_{t+H_t}^{\mathrm{FD}}\right),\\ Q_{t+1}^{\mathrm{oracle}} &= \left\{i_{t+1}^{\mathrm{FD}},\ldots,i_{t+H_t}^{\mathrm{FD}}\right\}. \tag*{(6)} \end{aligned}

where Mt+1FD\mathcal{M}_{t+1}^{\mathrm{FD}} is the masked set in the corresponding full-denoising state. The ordered prefix πt,HtFD\pi_{t,H_t}^{\mathrm{FD}} specifies the next HtH_t reference decisions, while Qt+1oracleQ_{t+1}^{\mathrm{oracle}} is the query set that would be available if the reference trajectory were known at inference time. Here, “oracle” denotes access to τFD\tau^{\mathrm{FD}}, rather than global optimality. We formulate computation allocation as predicting this near-future reference set from the current decoding state. During training, πt,HtFD\pi_{t,H_t}^{\mathrm{FD}} provides ordered supervision; during inference, TRACEQUERY selects at most HH positions using only signals available from the cached decoding state. Thus, the target is determined by future decoding behavior rather than by cached-state magnitude, age, or representation error.

Trajectory-Supervised Router Training

We train the TRACEQUERY router offline on intermediate states collected from full-denoising trajectories. For each reference state, let it,jFDi_{t,j}^{\mathrm{FD}} denote the jj-th element of πt,HtFD\pi_{t,H_t}^{\mathrm{FD}}.

For every unresolved position i∈Mt+1FDi \in\mathcal{M}^{\mathrm{FD}}_{t+1}, we construct

zi(t)=[ai,last(t),ρi(t),di(t)],si(t)=fϕ(zi(t)),(7)\mathbf{z}^{(t)}_i = \left[a^{(t)}_{i,\mathrm{last}}, \rho^{(t)}_i, d^{(t)}_i\right], \qquad s^{(t)}_i = f_{\phi}\left(\mathbf{z}^{(t)}_i\right), \tag*{(7)}

where the features are normalized last-layer attention from recently committed positions, local mask density, and relative distance to recently committed positions, respectively. The scorer fϕf_{\phi} is a two-layer MLP shared across positions and denoising steps. Detailed feature definitions are provided in Appendix B.

At ranking stage jj, previously selected reference positions are removed:

Ct,j=Mt+1FD∖{it,1FD,…,it,j−1FD}.(8)C_{t,j} = \mathcal{M}^{\mathrm{FD}}_{t+1} \setminus\left\{i^{\mathrm{FD}}_{t,1}, \ldots, i^{\mathrm{FD}}_{t,j-1}\right\}. \tag*{(8)}

We train the router with a truncated Plackett–Luce objective:

LPL=−1∣D∣∑(x,t)∈D∑j=1Htlog⁡exp⁡(sit,jFD(t))∑i∈Ct,jexp⁡(si(t)).(9)\mathcal{L}_{\mathrm{PL}} = -\frac{1}{|\mathcal{D}|} \sum_{(x,t)\in\mathcal{D}} \sum_{j=1}^{H_t} \log\frac{\exp\left(s^{(t)}_{i^{\mathrm{FD}}_{t,j}}\right)}{\sum_{i\in C_{t,j}}\exp\left(s^{(t)}_i\right)}. \tag*{(9)}

where D\mathcal{D} is the collection of intermediate reference states. The objective assigns higher scores to positions that occur earlier in the future full-denoising order. The reference trajectory is used only during offline training.

TraceQuery Inference

At inference time, the trained router scores every unresolved position i∈Mt+1i \in\mathcal{M}_{t+1} and selects the HtH_t highest-scoring positions:

Qt+1=arg⁡max⁡Q⊆Mt+1∣Q∣=Ht∑i∈Qsi(t).(10)\mathcal{Q}_{t+1} = \underset{\substack{Q\subseteq\mathcal{M}_{t+1}\\ |Q|=H_t}}{\arg\max} \sum_{i\in Q}s^{(t)}_i. \tag*{(10)}

The router scores determine only which positions are queried. For each i∈Qt+1i \in\mathcal{Q}_{t+1}, the backbone recomputes its representation against the persistent KV cache and obtains a query-updated token distribution p~i(t+1)\widetilde{p}^{(t+1)}_i. Because the remaining representations are cached, this sparse query is not equivalent to full recomputation.

Under confidence-based greedy single-token decoding, the backbone computes

v^i(t+1)=arg⁡max⁡v∈Vp~i(t+1)(v),ci(t+1)=p~i(t+1)(v^i(t+1)),\widehat{v}^{(t+1)}_i = \arg\max_{v\in\mathcal{V}} \widetilde{p}^{(t+1)}_i(v), \qquad c^{(t+1)}_i = \widetilde{p}^{(t+1)}_i\left(\widehat{v}^{(t+1)}_i\right),
it+1=arg⁡max⁡i∈Qt+1ci(t+1),At+1={it+1}.(11)i_{t+1} = \arg\max_{i\in\mathcal{Q}_{t+1}} c^{(t+1)}_i, \qquad A_{t+1} = \left\{i_{t+1}\right\}. \tag*{(11)}

It replaces the mask at it+1i_{t+1} with v^it+1(t+1)\widehat{v}^{(t+1)}_{i_{t+1}} and updates

Mt+2=Mt+1∖{it+1}.(12)\mathcal{M}_{t+2} = \mathcal{M}_{t+1} \setminus\left\{i_{t+1}\right\}. \tag*{(12)}

All other positions in Qt+1∖{it+1}\mathcal{Q}_{t+1} \setminus\left\{i_{t+1}\right\} remain masked, while positions outside Qt+1\mathcal{Q}_{t+1} continue to reuse their cached representations. The loop repeats between scheduled broad-recomputation steps until the active generation region is resolved. No reference trajectory or oracle computation is used at inference time.

Experiments

We have shown in Figure 1 that trajectory fidelity is strongly associated with downstream performance. Based on this observation, we ask three questions: whether trajectory-guided querying yields end-to-end gains across models and tasks, how efficiently it allocates computation relative to existing cache-based methods, and which router design choices account for its performance.

Experimental Setup

Models. We evaluate four representative diffusion language models: LLaDA-Base, LLaDA-Instruct, Dream-Base, and Dream-Instruct. For the instruction-tuned models, we do not apply chat templates. In our preliminary evaluation, chat templates improve performance on some benchmarks but degrade it on others, introducing an additional source of variation unrelated to the inference method itself. We therefore use a unified prompt format across all models.

Benchmarks. We evaluate reasoning, knowledge, and code generation using five benchmarks: MATH-500(512), BBH-125(256), GSM8K(256), HumanEval(512), and MBPP(512). All benchmarks use the same precision, decoding configuration, and hardware environment.

Baselines. We compare TRACEQUERY against full denoising and two selective cache-based acceleration methods: dLLM-Cache, and d2Cache. The controlled comparison varies the operating point of each method to obtain matched-quality and matched-computation settings, while the final end-to-end evaluation uses the adopted configuration of each method.

Efficiency metrics. We report downstream task score together with total computation in TFLOPs, an wall-clock inference time. For batch experiments, we additionally report the number of samples that can be processed under the same resource budget. TFLOPs measure the algorithmic computation footprint, while wall-clock time captures the practical execution cost of each method.

End-to-End Evaluation

We begin with the main result: end-to-end performance across four backbone models and five benchmarks. Each method uses its adopted operating configuration. We compare full denoising, dLLM-Cache, d2Cache, and TRACEQUERY for each backbone.

Table 1 reports downstream task performance together with total computation, and wall-clock inference time. Full denoising provides the quality reference, while the three cache-based methods represent different strategies for reducing repeated computation through approximate reuse and selective refresh.

ModelMethodMATH-500BBH-125GSM8KMBPPHumanEvalAvg.↑TFLOPs↓TPS↑Speedup↑
LLaDA BaseFull Denoising30.144.770.739.632.9100.05931531.0×
LLaDA BasedLLM-Cache29.543.570.237.832.998.11605651.23×
LLaDA Based2Cache29.044.968.538.829.396.6804330.6×
LLaDA BaseTRACEQUERY28.139.767.034.229.391.04151122.1×
LLaDA InstructFull Denoising34.958.076.336.835.4100.05828531.0×
LLaDA InstructdLLM-Cache34.356.473.428.436.694.91590651.23×
LLaDA Instructd2Cache34.940.652.835.536.683.0794330.6×
LLaDA InstructTRACEQUERY33.749.175.135.435.494.74091122.1×
Dream BaseFull Denoising39.843.271.655.037.8100.05554561.0×
Dream BasedLLM-Cache39.139.274.154.634.897.71252841.5×
Dream Based2Cache38.241.172.455.638.499.3753360.6×
Dream BaseTRACEQUERY37.240.372.052.030.593.83881192.1×
Dream InstructFull Denoising41.349.279.252.849.4100.05457561.0×
Dream InstructdLLM-Cache41.858.383.754.645.7104.51243841.5×
Dream Instructd2Cache40.047.275.353.046.696.4743360.6×
Dream InstructTRACEQUERY38.650.180.650.047.698.13871192.1×

Table 1. End-to-end quality and inference efficiency. We evaluate four dLLM backbones on five downstream benchmarks with batch size 16. Each method uses its adopted operating configuration. TPS denotes tokens per second.

Across the four backbones, TraceQuery trades a modest drop in accuracy for substantially lower compute: it retains 90-98% of full-denoising accuracy while using roughly 14× fewer TFLOPs per document, the lowest among the caching methods compared. Compared with the selective cache-based baselines, the advantage is particularly pronounced in TFLOPs and wall-clock time, consistent with the small query footprint observed in the controlled comparison. The improvement is also maintained across both base and instruction-tuned models, suggesting that the learned querying strategy is not specific to a single model variant or task family.

The controlled comparison in § 5.3 examines how computation allocation contributes to these results.

Controlled Efficiency Comparison

To examine this allocation directly, we compare TraceQuery against dLLM-Cache and d2Cache under controlled resource budgets. This experiment varies the operating point of each method to isolate how efficiently fresh computation is allocated. We consider two complementary settings: matched quality and matched computation.

Matched-quality computation. Figure 3(a) compares the amount of computation required to reach the same downstream quality. The x-axis reports total computation in TFLOPs. For each method, we adjust its computation budget and evaluate the resulting average performance across the all benchmarks.

Figure 3. Quality–compute and batch-scaling comparison. (a) Average score across benchmarks as a function of total computation, measured in TFLOPs. The red dashed line marks the score of full denoising without caching. TraceQuery reaches higher scores under comparable compute budgets. (b) Supported batch size as a function of wall-clock time per document. TraceQuery supports larger batches at comparable latency, demonstrating improved batch-scaling efficiency.

At the same quality level, TraceQuery requires substantially less fresh computation than other selective cache-based baselines. This difference follows from the allocation objective. dLLM-Cache, and d2Cache spend computation maintaining or refreshing a comparatively large set of cached representations, whereas TraceQuery uses a small query horizon and concentrates fresh computation on candidates expected to matter for upcoming decoding decisions. As a result, TraceQuery reaches the same quality with a smaller computation footprint.

Matched-compute batch efficiency. We next study how the per-sample query footprint affects batched inference. For sample bb, let Qt(b)Q_t^{(b)} denote the positions requiring fresh computation at denoising step tt. Batched execution combines these positions into a shared query set: Ut(B)=⋃b=1BQt(b)U_t(B) = \bigcup_{b=1}^{B} Q_t^{(b)}. As batch size increases, different samples contribute different queried positions, causing this union to grow. Methods with a large per-sample refresh budget can therefore quickly cover most of the generation region, making sparse batched inference increasingly close to dense recomputation.

In contrast, TraceQuery uses a much smaller query horizon, so the union grows substantially more slowly and sparse computation remains effective at larger batch sizes. Under the same computation budget, TraceQuery therefore supports substantially larger batches than the competing cache methods. The advantage is modest in the single-sample setting but grows rapidly with batch size, showing that reducing the per-sample query footprint provides an additional systems benefit beyond reducing FLOPs alone.

Together, the two controlled comparisons show that trajectory-guided querying improves both quality efficiency, by achieving the same quality with less computation, and batch efficiency, by accommodating more samples under the same resource budget.

Ablation Study

We then examine the router design underlying these results through the two-stage ablation shown in Figure 4. All results are averaged across LLaDA-Base, LLaDA-Instruct, Dream-Base, and Dream-Instruct.

Figure 4. Two-stage ablation of TRACEQUERY. (a) Stage I selects the router configuration by varying the feature combination, router architecture, ranking loss, normalization, and query horizon during router training. (b) Stage II fixes the selected configuration and evaluates alternative feature groups under closed-loop cached decoding. Results are averaged across four models and reported as accuracy change relative to the adopted configuration. Bars show paired 95% bootstrap confidence intervals; filled markers indicate intervals excluding zero, and gray dots denote per-benchmark changes.

Stage I: Router design. We tune the router on full-denoising trajectories, varying one design choice at a time and measuring Recall@5 over 17,670 held-out positions. Features matter most: adding geometry and confidence raises Recall@5 from 0.51 (attention alone) to 0.61 and 0.78, respectively. Stale confidence loses 13 points, while nonlinear architectures differ by less than 0.6 points. Loss and normalization choices are similarly stable, and performance holds for H=3H = 3–1212; we adopt H=5H = 5. We train on mixed tasks and retrain for each backbone. Stage II tests whether confidence remains useful under cached inference.

Stage II: Closed-loop feature evaluation. Stage I evaluates the router under offline trajectory supervision, but some features may behave differently once the model operates with cached states. We therefore fix all design choices selected in Stage I and evaluate alternative feature groups under closed-loop cached decoding.

For each benchmark, we sample 100 prompts and measure accuracy relative to the adopted router. We test whether confidence and margin remain useful when cached, since training observes fresh values but inference updates them only on re-query. We compare four feature sets: Clean uses only attention and geometry; Policy-aged carries values forward according to the deployment refresh schedule; Random-aged draws values from earlier steps; and Conf/margin + age adds the time since each position’s last refresh. Closed-loop results reverse the offline ranking. We adopt Clean: conf/margin + age changes accuracy by −3.8 points (CI includes zero), while random-aged and policy-aged significantly reduce it by 5.2 and 7.8 points, respectively. Confidence is highly predictive offline, yet every cached variant underperforms without it, making closed-loop evaluation essential for feature selection.

Conclusion

We formulate efficient dLLM inference as trajectory-guided querying: allocating limited computation to positions likely to matter for upcoming decoding decisions. TRACEQUERY learns this allocation from full-denoising trajectories, then uses inexpensive decoding-state signals to select a small query set at inference time. The backbone’s updated predictions determine which position and token to commit. Across LLaDA and Dream models, TRACEQUERY improves the quality–computation trade-off over cache-based baselines, with further gains in batched inference from its small per-sample query footprint.

AI Use Statement

In this work, we used generative AI tools only for language polishing, grammar correction, improving the clarity of author-written text, and identifying potentially relevant related work. We did not use generative AI tools to generate research ideas, formulate mathematical claims, design experiments, implement methods, or analyze results. All AI-assisted content, including suggested related work, was reviewed, verified, and edited by the authors. We take responsibility for the final content of this work, including all text, claims, and artifacts.

Detailed Computation and Memory Analysis

Computation Complexity Let SS denote the total sequence length visible to attention, BB the size of the active generation region, TT the number of denoising steps, HH the query horizon, RR the number of full refresh steps, and LL the number of Transformer layers.

Under single-token decoding, a regular sparse step recomputes at most

q=H+1(13)q = H + 1 \tag*{(13)}

positions, consisting of HH future-query candidates and one recently committed position required by delayed cache admission. Near the end of a generation block, qq may be smaller when fewer than HH masked positions remain.

Querying qq positions against a KV cache of length SS requires O(LqS)\mathcal{O}(LqS) attention computation, whereas refreshing all BB positions in the active generation region requires O(LBS)\mathcal{O}(LBS). Ignoring the one-time cache initialization, the total attention cost is therefore

CTRACEQUERY=O(LS[RB+(T−R)(H+1)]).(14)C_{\mathrm{TRACEQUERY}} = \mathcal{O}\left(LS\left[RB + (T-R)(H+1)\right]\right). \tag*{(14)}

By comparison, full recomputation at every denoising step requires

CFull=O(LSTB).(15)C_{\mathrm{Full}} = \mathcal{O}(LSTB). \tag*{(15)}

For single-block diffusion, B=T=NB = T = N, where NN denotes the generation length. Assuming S=O(N)S = \mathcal{O}(N) and treating HH and RR as bounded constants,

CTRACEQUERY=O(LN2),CFull=O(LN3).(16)C_{\mathrm{TRACEQUERY}} = \mathcal{O}(LN^2), \qquad C_{\mathrm{Full}} = \mathcal{O}(LN^3). \tag*{(16)}

Thus, selective querying reduces the dominant attention-computation scaling from cubic to quadratic in generation length.

Cached Length SSKV CacheRelative Memory
256128 MiB∼1.008×\sim1.008\times
512256 MiB∼1.016×\sim1.016\times
1024512 MiB∼1.034×\sim1.034\times
20481 GiB∼1.067×\sim1.067\times

Table 2. Persistent KV-cache memory for the illustrative BF16 LLaDA-8B configuration under batch size 1. Relative memory denotes model weights plus KV cache divided by model-weight memory alone.

Concrete Decoding Configurations Our default experiments use a query horizon of H=5H = 5. For single-block generation with N=256N = 256, we perform R=16R = 16 global refreshes. A regular sparse step therefore recomputes at most six positions: five future-query candidates and one recently committed position. Using the number of attention query positions as a computation proxy, the relative attention workload is approximately

16×256+(256−16)×6256×256≈8.45%.(17)\frac{16 \times256 + (256 - 16) \times6}{256 \times256} \approx8.45\%. \tag*{(17)}

This quantity measures the reduction in attention-query computation and should not be interpreted as wall-clock speedup. Practical runtime additionally depends on projection and MLP computation, cache operations, router execution, kernel efficiency, and hardware utilization.

For a length-256 generation divided into 16 blocks, each active block contains 16 positions. We perform no additional periodic full refresh within each block and use the same query horizon H=5H = 5. The effect of query horizon and refresh schedule is evaluated empirically in § 5.

Persistent Memory Consumption TRACEQUERY maintains a persistent KV cache for the complete sequence. Let dKVd_{\mathrm{KV}} denote the dimensionality of the stored KV representation per token, bb the number of bytes per element, and BbatchB_{\mathrm{batch}} the batch size. The persistent KV-cache memory is

MKV=2BbatchLSdKVb,(18)M_{\mathrm{KV}} = 2B_{\mathrm{batch}}LSd_{\mathrm{KV}}b, \tag*{(18)}

where the factor of two accounts for keys and values. Thus,

MKV=O(LSdKV),(19)M_{\mathrm{KV}} = O(LSd_{\mathrm{KV}}), \tag*{(19)}

which scales linearly with sequence length.

For illustration, assuming a BF16 LLaDA-8B configuration with L=32L = 32, dKV=4096d_{\mathrm{KV}} = 4096, and batch size 1, the model parameters occupy approximately

Mmodel≈8×109×2=16 GB.(20)M_{\mathrm{model}} \approx8 \times10^{9} \times2 = 16\ \mathrm{GB}. \tag*{(20)}

For a cached sequence of length S=256S = 256, the corresponding KV cache requires

MKV=2×32×256×4096×2≈128 MiB,(21)M_{\mathrm{KV}} = 2 \times32 \times256 \times4096 \times2 \approx128\ \mathrm{MiB}, \tag*{(21)}

corresponding to less than 1% additional persistent storage relative to the BF16 model weights.

Decoding Signal Definitions

This appendix provides the detailed definitions of the decoding signals introduced in § 4.3. Let i∈Mti \in\mathcal{M}_t denote a still-masked candidate position and let Rt⊆Ut\mathcal{R}_t \subseteq\mathcal{U}_t denote the set of recently unmasked positions.

Confidence. Given the token probability distribution at position ii, confidence is defined as

ci(t)=max⁡vpθ(v∣x(t))i.(22)c_i^{(t)} = \max_v p_\theta\left(v \mid x^{(t)}\right)_i. \tag*{(22)}

Probability margin. Let pi,(1)(t)p_{i,(1)}^{(t)} and pi,(2)(t)p_{i,(2)}^{(t)} denote the largest and second-largest token probabilities at position ii. The probability margin is

mi(t)=pi,(1)(t)−pi,(2)(t).(23)m_i^{(t)} = p_{i,(1)}^{(t)} - p_{i,(2)}^{(t)}. \tag*{(23)}

Mask density. For a local neighborhood Wi\mathcal{W}_i centered at candidate ii, mask density is defined as

ρi(t)=1∣Wi∣∑j∈Wi1[j∈Mt].(24)\rho_i^{(t)} = \frac{1}{|\mathcal{W}_i|}\sum_{j \in\mathcal{W}_i} \mathbb{1}[j \in\mathcal{M}_t]. \tag*{(24)}

Relative distance. Let LL be the generation block size. The distance from candidate ii to recently unmasked positions is defined as

di(t)=min⁡j∈Rt∣i−j∣L,(25)d_i^{(t)} = \frac{\min_{j \in\mathcal{R}_t} |i-j|}{L}, \tag*{(25)}

and is normalized by the active generation length when required.

Last-layer attention. Let Aℓ,h(t)(j,i)A_{\ell,h}^{(t)}(j,i) denote the attention from position jj to position ii at layer ℓ\ell and head hh. The last-layer attention signal is

ai,last(t)=Agg⁡j∈Rt,hAL,h(t)(j,i),(26)a_{i,\mathrm{last}}^{(t)} = \operatorname{Agg}_{j \in\mathcal{R}_t,h} A_{L,h}^{(t)}(j,i), \tag*{(26)}

where LL denotes the final Transformer layer.

Full-layer attention. The full-layer attention signal aggregates the same dependency across Transformer layers:

ai,full(t)=Agg⁡ℓ,j∈Rt,hAℓ,h(t)(j,i).(27)a_{i,\mathrm{full}}^{(t)} = \operatorname{Agg}_{\ell,j \in\mathcal{R}_t,h} A_{\ell,h}^{(t)}(j,i). \tag*{(27)}

Inference and Training algorithm

Algorithm 1 TRACEQUERY Router Training

Require: Training samples X\mathcal{X}, diffusion model pθp_\theta, router fϕf_\phi, query horizon HH

  1. D←∅\mathcal{D} \gets\varnothing

  2. for all x∈Xx \in\mathcal{X} do

  3.     Run full-denoising decoding with one token unmasked per step

  4.     Record teacher trajectory τ=(i0,i1,…,iT−1)\tau= (i_0, i_1, \ldots, i_{T-1})

  5.     for t=0,…,T−2t = 0, \ldots, T-2 do

  6.         Collect signals for all i∈Mt+1i \in\mathcal{M}_{t+1}

  7.         Normalize last-layer attention with SOFTMAX

  8.         Store {zi(t),gi(t)}i∈Mt+1\{z_i^{(t)}, g_i^{(t)}\}_{i \in\mathcal{M}_{t+1}} in D\mathcal{D}

  9.     end for

  10. end for

  11. repeat

  12.     Sample a decoding state tt from D\mathcal{D}

  13.     for all i∈Mt+1i \in\mathcal{M}_{t+1} do

  14.         si(t)←fϕ(zi(t))s_i^{(t)} \gets f_\phi(z_i^{(t)})

  15.     end for

  16.     L←0\mathcal{L} \gets0

  17.     for j=1,…,Hj = 1, \ldots, H do

  18.         Ct,j←{i∈Mt+1:gi(t)≥j}C_{t,j} \gets\{i \in\mathcal{M}_{t+1}: g_i^{(t)} \ge j\}

  19.         i(j)←i^{(j)} \gets teacher’s jj-th future unmask

  20.         L←L−log⁡exp⁡(si(j)(t))∑i∈Ct,jexp⁡(si(t))\mathcal{L} \gets\mathcal{L} - \log\frac{\exp(s_{i^{(j)}}^{(t)})}{\sum_{i \in C_{t,j}}\exp(s_i^{(t)})}

  21.     end for

  22.     Update ϕ\phi using ∇ϕL\nabla_\phi\mathcal{L}

  23. until convergence

  24. return trained router fϕf_\phi

Algorithm 2 TRACEQUERY Inference

Require: Diffusion model pθp_\theta, router fϕf_\phi, query horizon HH, refresh schedule R\mathcal{R}

  1. Initialize masked set M0\mathcal{M}_0 and perform a full forward pass

  2. Cache all KV states; set Q0←M0\mathcal{Q}_0 \leftarrow\mathcal{M}_0

  3. for t=0,1,…t = 0, 1, \ldots while Mt≠∅\mathcal{M}_t \ne\varnothing do

  4.     if t∈Rt \in\mathcal{R} then

  5.         (Pt,At,KV)←FullForward⁡(Mt,KV)(P_t, A_t, \mathrm{KV}) \leftarrow\operatorname{FullForward}(\mathcal{M}_t, \mathrm{KV})

  6.         Et←Mt\mathcal{E}_t \leftarrow\mathcal{M}_t

  7.     else

  8.         (Pt,At,KV)←QueryForward⁡(Qt,KV)(P_t, A_t, \mathrm{KV}) \leftarrow\operatorname{QueryForward}(\mathcal{Q}_t, \mathrm{KV})

  9.         Et←Qt\mathcal{E}_t \leftarrow\mathcal{Q}_t

  10.     end if

  11.     it←arg⁡max⁡i∈EtConfidence⁡(Pt(i))i_t \leftarrow\arg\max_{i \in\mathcal{E}_t} \operatorname{Confidence}(P_t(i))

  12.     Commit position iti_t and update Mt+1←Mt∖{it}\mathcal{M}_{t+1} \leftarrow\mathcal{M}_t \setminus\{i_t\}

  13.     if Mt+1=∅\mathcal{M}_{t+1} = \varnothing then

  14.         break

  15.     end if

  16.     for all i∈Mt+1i \in\mathcal{M}_{t+1} do

  17.         zi(t)←[ai,last(t),ρi(t),di(t)]\mathbf{z}_i^{(t)} \leftarrow[a_{i,\mathrm{last}}^{(t)}, \rho_i^{(t)}, d_i^{(t)}]

  18.         si(t)←fϕ(zi(t))s_i^{(t)} \leftarrow f_\phi(\mathbf{z}_i^{(t)})

  19.     end for

  20.     Qt+1←TopH⁡({si(t)}i∈Mt+1,H)\mathcal{Q}_{t+1} \leftarrow\operatorname{TopH}(\{s_i^{(t)}\}_{i \in\mathcal{M}_{t+1}}, H)

  21. end for

  22. return generated sequence

References

  1. [1]Marianne Arriola, Aaron Gokaslan, Justin Chiu, Zhihan Yang, Zhixuan Qi, Jiaqi Han, Subham Sahoo, and Volodymyr Kuleshov. Block diffusion: Interpolating between autoregressive and diffusion language models. In International Conference on Learning Representations, volume 2025, pp. 50726–50753, 2025.
  2. [2]Jacob Austin, Daniel D. Johnson, Jonathan Ho, Daniel Tarlow, and Rianne van den Berg. Structured denoising diffusion models in discrete state-spaces. CoRR, abs/2107.03006, 2021. URL https://arxiv.org/abs/2107.03006.
  3. [3]Minsoo Cheong, Donghyun Son, Woosang Lim, and Sungjoo Yoo. EntropyCache: Decoded token entropy guided KV caching for diffusion language models. arXiv preprint arXiv:2603.18489, 2026. URL https://arxiv.org/abs/2603.18489.
  4. [4]Zhanqiu Hu, Jian Meng, Yash Akhauri, Mohamed Abdelfattah, Jae-sun Seo, Zhiru Zhang, and Udit Gupta. FlashdIm: Accelerating diffusion language model inference via efficient kv caching and guided diffusion. In International Conference on Learning Representations, volume 2026, pp. 153529–153544, 2026.arxiv.org/abs/2505.21467
  5. [5]Metod Jazbec, Theo X Olausson, Louis Béthune, Pierre Ablin, Michael Kirchhof, João Monteiro, Victor Turrisi, Jason Ramapuram, and Marco Cuturi. Learning unmasking policies for diffusion language models. arXiv preprint arXiv:2512.09106, 2025.arxiv.org/abs/2512.09106
  6. [6]Yuchu Jiang, Yue Cai, Xiangzhong Luo, Jiale Fu, Jiarui Wang, Chonghan Liu, and Xu Yang. d²Cache: Accelerating diffusion-based LLMs via dual adaptive caching. In International Conference on Learning Representations, 2026. URL https://arxiv.org/abs/2509.23094.
  7. [7]Inception Labs, Samar Khanna, Siddhant Kharbanda, Shufan Li, Harshit Varma, Eric Wang, Sawyer Birnbaum, Ziyang Luo, Yanis Mirouai, Akash Pralecha, et al. Mercury: Ultra-fast language models based on diffusion. arXiv preprint arXiv:2506.17298, 2025.arxiv.org/abs/2506.17298
  8. [8]Xiang Li, John Thickstun, Ishaan Gulrajani, Percy S Liang, and Tatsunori B Hashimoto. Diffusion-lm improves controllable text generation. Advances in neural information processing systems, 35: 4328–4343, 2022.arxiv.org/abs/2205.14217
  9. [9]Xuejie Liu, Yap Vit Chun, Yitao Liang, and Anji Liu. Lookahead path likelihood optimization for diffusion llms. arXiv preprint arXiv:2602.03496, 2026a.arxiv.org/abs/2602.03496
  10. [10]Zhiyuan Liu, Yicun Yang, Yaojie Zhang, Junjie Chen, Chang Zou, Qingyan Wei, Shaobo Wang, Yichen Zhu, and Linfeng Zhang. dLLM-Cache: Accelerating diffusion large language models with adaptive caching. In International Conference on Machine Learning, 2026b. URL https://arxiv.org/abs/2506.06295.
  11. [11]Aaron Lou, Chenlin Meng, and Stefano Ermon. Discrete diffusion modeling by estimating the ratios of the data distribution. arXiv preprint arXiv:2310.16834, 2023.arxiv.org/abs/2310.16834

Paper details

vlnc:W_j7c5ybwn
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 4

downloads · 0

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

  • Computer Science

generative AI tools

View statement
Looking for related papers…
Contents