Abstract
While Diffusion Language Models (DLMs) offer the potential for high-speed parallel text generation, they often struggle with the structural brittleness of code, leading to performance collapse. We present Saber, a training-free sampling algorithm that introduces adaptive acceleration and a backtracking mechanism to DLMs. Saber achieves a 251.4% average inference speedup while simultaneously improving code accuracy (Pass@1) by 1.9% over standard methods, effectively breaking the traditional speed-quality trade-off.
Introduction
Autoregressive Models (ARMs) like GPT-4 are the current standard for code generation but are limited by their token-by-token generation process. Diffusion Language Models (DLMs) provide a faster alternative by unmasking multiple tokens in parallel. However, DLMs frequently fail in code generation due to two primary issues:
- Non-uniform difficulty: Predicting tokens is significantly harder when context is sparse (early steps) than when it is rich (later steps).
- Irreversibility: Standard DLM sampling is a one-way process. Once a token is unmasked, it cannot be corrected, leading to catastrophic error propagation.
Methodology: The Saber Framework
Saber (Sampling with Adaptive acceleration and Backtracking Enhanced Remasking) is a model-agnostic, training-free algorithm consisting of two core components:
Adaptive Acceleration via Dynamic Unmasking (AADU)
Instead of a static unmasking strategy, Saber employs a dynamic threshold based on the average confidence of previously unmasked tokens. In the early "context-poor" stages, the threshold remains high to ensure caution. As the model establishes more context and confidence rises, the threshold lowers, enabling aggressive parallel generation.
Backtracking-Enhanced Remasking Mechanism (BERM)
BERM introduces a self-correction layer. At each step, Saber re-evaluates the confidence of all unmasked tokens using the updated global context. If a token's confidence drops significantly—indicating a likely error—it is reverted to a [MASK] token to be reconsidered in subsequent steps.
Experimental Results
We evaluated Saber across five major benchmarks: HumanEval, MBPP, their extended versions (ET), and LiveCodeBench.
Key Insights: The Confidence Trajectory
Analysis of DLM behavior reveals that confidence naturally trends upward as more tokens are filled. Saber exploits this "Confidence Trajectory" by matching decoding aggression to the model's current certainty. Unlike ARMs where the prefix is fixed, DLM context evolves globally; a token that appears correct locally may be revealed as an error once the rest of the function is drafted.
Performance and Efficiency
Saber achieved the highest Pass@1 scores across all benchmarks. On HumanEval, accuracy improved from 43.3% to 45.1%. More importantly, it delivered massive speedups, reducing generation time on HumanEval from over 2 hours to just 41 minutes.
Conclusion and Future Work
Saber demonstrates that algorithmic improvements in sampling can enhance both speed and quality. While the backtracking mechanism introduces a marginal computational overhead per step, the reduction in total steps leads to a net gain in efficiency. Future research will focus on automating hyperparameter optimization for the backtracking threshold and exploring the application of these principles to general natural language tasks beyond code generation.
Summary updated