Manuscript Offprint

arXiv:2608.30922

CARVE: Verified Expansion for Variable-Length Generation in Diffusion Language Models

Wail Bouhedja, Amr Mohamed, Guokan Shang

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Masked diffusion language models predict tokens from a partially observed response canvas, enabling bidirectional conditioning and parallel token refinement. Yet standard masked-diffusion decoders use a rigid inference interface: the number of masked positions allocated to the answer is fixed before generation begins. Choosing this length is difficult. A short canvas can truncate reasoning or code, while a long canvas wastes computation and can perturb denoising. We introduce CARVE (Counterfactual-Aware Reveal with Verified Expansion), a training-free variable-length algorithm for masked diffusion LMs. Starting from a shorter canvas, CARVE can grow the response during decoding by inserting additional [MASK] positions. Rather than keeping every insertion, CARVE tests a candidate expanded canvas and asks a counterfactual question: would the model make similar predictions for the unresolved positions in the original canvas if the extra masked space were present? The inserted masks are kept only when they induce low Jensen–Shannon (JS) divergence on aligned unresolved positions. This makes length growth a verified stability decision rather than a pure confidence heuristic. CARVE applies without retraining to both full-canvas and blockwise diffusion decoders. Across code generation and mathematical reasoning benchmarks, CARVE consistently improves average performance over fixed-length baselines across all evaluated model families. Crucially, CARVE achieves these accuracy gains while reducing inference cost, reaching half the FLOPs of fixed-length decoding in some settings.

1 Introduction

Autoregressive language models (Brown et al., 2020) have a simple interface for open-ended generation: they emit one token at a time and stop when an end-of-sequence token is produced. Masked diffusion language models (Austin et al., 2021a; Campbell et al., 2022; Zheng et al., 2023; Lou et al., 2023; Sahoo et al., 2024; Shi et al., 2024), by contrast, generate by iteratively denoising a canvas of masked tokens. This paradigm enables attractive properties such as parallel token updates, bidirectional conditioning, and arbitrary-order refinement, and has recently scaled to competitive instruction-following models such as LLaDA (Nie et al., 2026) and Dream (Ye et al., 2025). However, it exposes a basic inference problem: the generation length must typically be fixed before decoding begins.

This fixed-canvas assumption is poorly matched to realistic generation. If the canvas is too short, the model may truncate code, reasoning, or explanations. If the canvas is too long, inference wastes computation on masked positions that may not be needed for the final answer, and can even harm quality by forcing the model to denoise beyond the useful response (Rossi et al., 2026). The appropriate length is also instance-dependent: two prompts from the same task may require very different response lengths, even when they use the same decoding setup. As a result, variable-length decoding is not a minor engineering detail, but a central obstacle to making diffusion LMs practical for open-ended generation.

A natural solution is to adapt the canvas during denoising. Prior work such as DAEDAL (Li et al., 2025) proposes training-free length expansion for diffusion language models by using internal confidence signals to decide when to allocate additional masked tokens. This shows that response length need not be fixed before decoding begins and can instead be adjusted during inference. Yet expansion introduces a second question that is easy to overlook: adding masks changes the denoising problem itself. In a bidirectional masked diffusion model, inserting new masked positions may perturb the model's predictions at other still-unresolved positions. An appropriate length expansion rule should therefore ask both whether additional space might be useful and whether inserting that space leaves the existing predictions sufficiently stable.

We introduce CARVE (Counterfactual-Aware Reveal with Verified Expansion), a training-free variable-length decoding algorithm for masked diffusion language models. CARVE augments a standard diffusion sampler with a verified expansion step. Before certain reveal steps, CARVE proposes inserting a number of additional masked tokens into the current canvas. It then runs the model once on the expanded canvas and compares the predictive distributions of the original and expanded canvases at aligned still-masked positions. The insertion is accepted only when the mean Jensen–Shannon divergence between these distributions remains below a fixed threshold. Otherwise, the expanded branch is rejected and we continue with the original canvas. In this way, the canvas grows only when the proposed expansion leaves the predictive distributions at aligned unresolved positions sufficiently stable under this criterion.

This turns length expansion into a stability check rather than a pure confidence heuristic. Each proposed insertion asks a local counterfactual question: would the model make essentially the same predictions for the unresolved tokens if the canvas contained additional space? When the answer is yes, the added masks can be committed without substantially changing the denoising state. When the answer is no, the proposal is treated as a destabilizing edit and discarded. This criterion differs from expansion rules based only on absolute confidence or end-of-sequence (EOS) token behavior (Yang et al., 2026): it measures the effect of the insertion on the model's remaining predictive state. The same principle applies across different masked diffusion backends; in this work, we instantiate CARVE for both full-canvas Dream decoding and blockwise LLaDA decoding.

Our experiments evaluate CARVE on code and mathematical reasoning benchmarks across different dLLMs. We compare against fixed-length baseline decoding and DAEDAL (Li et al., 2025), the closest training-free variable-length baseline. Across models, CARVE improves average performance over fixed-length baseline decoding. Our analysis of model-forward FLOPs further shows that verified expansion does not simply trade additional computation for accuracy: adaptive reveal and EOS cropping often offset the cost of branching. Consequently, CARVE provides a dual advantage, improving average task accuracy while yielding up to roughly half as many FLOPs as fixed-length decoding in some settings. Code is publicly available 1^{1}. Our contributions are:

• We propose CARVE, a training-free variable-length algorithm that verifies each proposed canvas expansion by measuring Jensen–Shannon divergence on aligned unresolved positions.

• We show that verified expansion provides a model-agnostic mechanism for masked diffusion LMs, applying the same algorithm to both full-canvas Dream decoding and blockwise LLaDA decoding.

• We demonstrate that CARVE improves average performance over fixed-length baselines across code and mathematical reasoning benchmarks on three diffusion LMs, while often reducing inference FLOPs relative to fixed-length decoding.

References (25)