[SGLang-Diffusion LLM] Add inference support for d3LLM models (arXiv:2601.07568)#20615
[SGLang-Diffusion LLM] Add inference support for d3LLM models (arXiv:2601.07568)#20615flowermouse wants to merge 2 commits intosgl-project:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request integrates d3LLM models into SGLang, significantly enhancing its capability to serve ultra-fast diffusion language models. The core objective is to enable efficient inference for models that utilize full-sequence bidirectional attention, which differs from traditional autoregressive or block-causal diffusion LLMs. This required a fundamental re-evaluation and adjustment of how requests are processed, how KV caches are managed, and how CUDA graphs are utilized, ensuring optimal performance and compatibility with these novel architectures. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This is a significant feature addition, adding support for d3LLM models, which are fast diffusion language models. The changes span across model implementation, new decoding algorithms, and modifications to the serving core to support bidirectional attention models. The code changes look solid and are accompanied by new tests. My main feedback is on improving the documentation for the new FullAttnMultiBlock algorithm to ensure the configuration keys and their descriptions are consistent with the implementation, which is important for users.
| ```yaml | ||
| # Confidence threshold for accepting predicted tokens | ||
| # Range: 0.0 - 1.0 | ||
| threshold: 0.5 | ||
| # Additional threshold increment per decoding step | ||
| block_add: 0.1 | ||
| # Threshold for considering a token as "decoded" | ||
| decoded_thresh: 0.95 | ||
| # Sub-block size for parallel decoding | ||
| sub_block_size: 32 | ||
| # Number of iterations to delay before caching | ||
| cache_delay_iter: 2 | ||
| # Interval for refreshing the attention cache | ||
| refresh_interval: 10000 | ||
| ``` |
There was a problem hiding this comment.
The configuration keys and descriptions for FullAttnMultiBlock in this documentation seem to be inconsistent with the implementation in python/sglang/srt/dllm/algorithm/full_attn_multi_block.py.
Specifically:
- The key
block_addin the YAML should likely beblock_add_threshold. Its description "Additional threshold increment per decoding step" is also misleading. Based on the code, it's the "previous block progress threshold to add the next block". - The key
decoded_threshshould likely bedecoded_token_threshold. Its description "Threshold for considering a token as 'decoded'" is also not quite accurate. It's the "previous block progress threshold for full activation". - The key
sub_block_sizeis documented here but does not appear to be used in theFullAttnMultiBlockalgorithm implementation.
Could you please update the documentation to match the implementation for clarity and correctness? This will help users configure the algorithm correctly.
| ```yaml | |
| # Confidence threshold for accepting predicted tokens | |
| # Range: 0.0 - 1.0 | |
| threshold: 0.5 | |
| # Additional threshold increment per decoding step | |
| block_add: 0.1 | |
| # Threshold for considering a token as "decoded" | |
| decoded_thresh: 0.95 | |
| # Sub-block size for parallel decoding | |
| sub_block_size: 32 | |
| # Number of iterations to delay before caching | |
| cache_delay_iter: 2 | |
| # Interval for refreshing the attention cache | |
| refresh_interval: 10000 | |
| ``` | |
| # Confidence threshold for accepting predicted tokens | |
| # Range: 0.0 - 1.0 | |
| threshold: 0.5 | |
| # Previous block progress threshold to add the next block | |
| # Range: 0.0 - 1.0 | |
| block_add_threshold: 0.1 | |
| # Previous block progress threshold for a block to be considered fully active | |
| # Range: 0.0 - 1.0 | |
| decoded_token_threshold: 0.95 | |
| # Number of iterations to delay before caching | |
| cache_delay_iter: 2 | |
| # Interval for refreshing the attention cache | |
| refresh_interval: 10000 |
|
/tag-and-rerun-ci |
Summary
This PR adds SGLang serving support for d3LLM (arXiv:2601.07568), an ultra-fast diffusion language model based on pseudo-trajectory distillation. d3LLM achieves significantly higher tokens-per-forward (TPF) than vanilla diffusion LLMs while maintaining competitive accuracy, enabling up to 3×-5× end-to-end speedup over autoregressive baselines on H800 and B200.
Two models are supported:
Both models require bidirectional attention (instead of the block-causal diffusion in existing LLaDA 2.0/2.1), which demands a new dLLM decoding method support in SGLang.
Key Changes
New Files:
models/d3llm_llada.py,models/dream.py: Model implementations for d3LLM-LLaDA and d3LLM-Dreamdllm/algorithm/entropy_threshold.py:EntropyThresholddecoding algorithmdllm/algorithm/full_attn_multi_block.py:FullAttnMultiBlockdecoding algorithm for d3LLM multi-block parallel decoding with bidirectional attentionModified Files:
dllm/config.py: Addneeds_full_prefillandpad_full_generationflags toDllmConfigdllm/mixin/req.py,dllm/mixin/scheduler.py: Handle full-prefill mode in request lifecycleflashinfer_backend.py: Zero outprefix_lenswhenneeds_full_prefillis enabledschedule_batch.py: Skip tree-cache matching for full-prefill models; free old KV slots before re-extendschedule_policy.py: Adjust token budget and truncation for full-prefill modeforward_batch_info.py: Build positions from fullseq_lenfor bidirectional attentioncuda_graph_runner.py: Disable CUDA graph for variable-length full-prefill inputs; work around Blackwell (SM≥10) multi-BS capture instabilityhttp_server.py: Increasemax_new_tokensfor dLLM health checks to ensure proper warmupradix_cache.py: AddNoneguard fornodeininc_lock_ref/dec_lock_refTests & Docs:
test/registered/dllm/test_dllm_gsm8k.py: GSM8K benchmark test for d3LLM modelsdocs/supported_models/text_generation/diffusion_language_models.md: Updated documentationBenchmark Results
Dataset: GSM8K-CoT (zero-shot)
Decoding: FullAttnMultiBlock
TP Size: 1
Usage Example
Test Plan
test_dllm_gsm8k.pyfor CI integration