Diffusion LLM with Native Variable Generation Lengths: Let [EOS] Lead the Way

Yicun Yang, Cong Wang, Shaobo Wang, Zichen Wen, Biqing Qi, Hanlin Xu, Linfeng ZhangarXiv 2025 · OpenReview

Abstract

Diffusion-based large language models (dLLMs) have exhibited substantial potential for parallel text generation, which may enable more efficient generation compared to autoregressive models. However, current dLLMs suffer from fixed generation lengths, which indicates the generation lengths of dLLMs have to be determined before decoding as a hyper-parameter, leading to issues in efficiency and flexibility. To solve these problems, in this work, we propose to train a diffusion LLM with native variable generation lengths, abbreviated as dLLM-Var. Concretely, we aim to train a model to accurately predict the [EOS] token in the generated text, which makes a dLLM be able to natively infer in a block diffusion manner, while still maintaining the ability of global bi-directional (full) attention and high parallelism. Experiments on standard benchmarks demonstrate that our method achieves a 30.1x speedup over traditional dLLM inference paradigms and a 2.4x speedup relative to autoregressive models such as Qwen and Llama. Our method achieves higher accuracy and faster inference, elevating dLLMs beyond mere academic novelty and supporting their practical use in real-world applications. Codes and models have been released.

Introduction: The Fixed-Length Bottleneck

Large Language Models (LLMs) are currently dominated by two paradigms: Autoregressive (AR) models and Diffusion-based models (dLLMs). AR models, such as Llama or GPT, generate text sequentially—one token at a time. While flexible in length, their sequential nature limits inference speed and parallelization.

The traditional sequential generation paradigm of Autoregressive Models.

Conversely, dLLMs generate text by iteratively refining noise across a block of tokens, offering high parallelism. However, dLLMs have historically been constrained by fixed generation lengths. Users must pre-define the number of tokens to be generated before decoding begins. If the target length is too short, the output is truncated; if too long, the model often produces repetitive or nonsensical "hallucination tails" to fill the remaining slots. This rigidity has hindered the practical adoption of dLLMs in real-world scenarios.

Methodology: dLLM-Var

To overcome these limitations, we propose dLLM-Var, a diffusion LLM capable of native variable generation lengths. The core innovation lies in teaching the model to accurately predict the [EOS] (End of Sequence) token, allowing it to terminate generation dynamically.

dLLM-Var: A new paradigm for variable-length diffusion generation developed by EPIC Lab.

1. Fixed Masking for Termination Tokens

In standard dLLM training, tokens are masked randomly. dLLM-Var modifies this by ensuring the [EOS] token is always masked during training. This forces the model to learn the specific semantic and structural cues that signal the end of a sequence to successfully reconstruct the data.

2. Multi-Sample Packing and Full Attention

Training on single samples often leads to models simply appending [EOS] to the end of a fixed block. To prevent this, we employ multi-sample packing, where multiple independent sequences are concatenated into a single training block, separated by [EOS] tokens. By utilizing global bidirectional (full) attention, the model learns to recognize [EOS] as a meaningful boundary between distinct contexts rather than just a block-end marker.

3. Block Diffusion Inference

During inference, dLLM-Var operates in a block diffusion manner. It generates text in discrete chunks (e.g., 64 tokens). If an [EOS] token is predicted within a block, the process terminates. Otherwise, the model appends a new block of masked tokens and continues, leveraging Key-Value (KV) caching to maintain high efficiency.

Training and Datasets

The model was trained using 6.4 million supervised fine-tuning (SFT) dataset pairs over three epochs. To evaluate its capabilities, we tested dLLM-Var on six standard industry benchmarks covering mathematical reasoning (GSM8K, MATH), hard science (GPQA), logical reasoning (BBH), and Python coding (HumanEval, MBPP).

Key Results

Accuracy and Self-Correction

dLLM-Var demonstrates superior performance compared to existing models. On the Big-Bench Hard (BBH) benchmark, it achieved a score of 52.55, surpassing Llama-3-8B-Instruct (51.40). Crucially, the model effectively eliminated the "hallucination tail" by stopping precisely when the task was completed. Furthermore, the iterative nature of diffusion allows for native self-correction; the model can fix grammatical or logical errors during the denoising steps, a feat AR models struggle to achieve without external tools.

Inference Speedup

The proposed method achieves significant efficiency gains over both traditional diffusion and autoregressive paradigms:

  • 30.1× speedup compared to vanilla LLaDA (a leading dLLM).
  • 2.4× speedup relative to standard autoregressive models like Llama-3-8B-Instruct.

Conclusion

By enabling native variable generation lengths, dLLM-Var bridges the gap between the flexibility of autoregressive models and the speed of diffusion models. While current limitations include unidirectional constraints on finalized blocks to allow for KV cache reuse, the ability for iterative self-correction and high parallelism positions dLLM-Var as a viable candidate for unseating traditional autoregressive giants in practical AI applications.

Summary updated

BibTeX
@misc{yang2025diffusion,
  author = {Yicun Yang and Cong Wang and Shaobo Wang and Zichen Wen and Biqing Qi and Hanlin Xu and Linfeng Zhang},
  title = {{Diffusion LLM with Native Variable Generation Lengths: Let [EOS] Lead the Way}},
  year = {2025},
  eprint = {2510.24605},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2510.24605},
}
Figure