DFlash
is a novel speculative decoding method that utilizes a lightweight
block diffusion
model for drafting. It enables efficient, high-quality parallel drafting that pushes the limits of inference speed.
This model is the
drafter
component. It must be used in conjunction with the target model
Qwen/Qwen3-8B
.
🚀 Quick Start
This model requires
trust_remote_code=True
to load the custom architecture for block diffusion generation.
Installation
Ensure you have
transformers
and
torch
installed. Our evaluation is conducted with torch==2.9.0 and transformers=4.57.3.
pip install transformers==4.57.3 torch==2.9.0
Inference Example
The following example demonstrates how to load the DFlash drafter and the Qwen3-8B target model to perform speculative decoding.
import torch
from transformers import AutoModel, AutoModelForCausalLM, AutoTokenizer
# 1. Load the DFlash Draft Model# Note: trust_remote_code=True is required for DFlash. We recommend run on one GPU currently.
model = AutoModel.from_pretrained(
"z-lab/Qwen3-8B-DFlash-b16",
trust_remote_code=True,
dtype="auto",
device_map="cuda:0"
).eval()
# 2. Load the Target Model
target = AutoModelForCausalLM.from_pretrained(
"Qwen/Qwen3-8B",
dtype="auto",
device_map="cuda:0"
).eval()
# 3. Load Tokenizer
tokenizer = AutoTokenizer.from_pretrained("Qwen/Qwen3-8B")
# Essential: Add the mask token required for diffusion steps
tokenizer.add_special_tokens({"mask_token": "<|MASK|>"})
# 4. Prepare Input
prompt = "How many positive whole-number divisors does 196 have?"
messages = [
{"role": "user", "content": prompt}
]
# Note: this draft model is used for thinking mode disabled
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
enable_thinking=False
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
# 5. Run Speculative Decoding# The 'spec_generate' function is a custom method provided by the DFlash model
generate_ids = model.spec_generate(
input_ids=model_inputs["input_ids"],
max_new_tokens=2048,
temperature=0.0,
target=target,
mask_token_id=tokenizer.mask_token_id,
stop_token_ids=[tokenizer.eos_token_id]
)
print(tokenizer.decode(generate_ids[0], skip_special_tokens=True))
Evaluation
DFlash achieves up to
6.17x
lossless acceleration for
Qwen3-8B
, making it nearly
2.5x
faster than the state-of-the-art speculative decoding method EAGLE-3. Check out our
GitHub repository
to see how to reproduce the results.
Citation
If you find DFlash useful for your research or applications, please cite our project. The full paper is coming soon!
@article{chen2026dflash,
title = {DFlash: Block Diffusion for Flash Speculative Decoding},
author = {Chen, Jian and Liu, Zhijian},
journal = {arXiv preprint},
year = {2026},
url = {[https://github.com/z-lab/dflash](https://github.com/z-lab/dflash)},
note = {Paper coming soon}
}
Runs of z-lab Qwen3-8B-DFlash-b16 on huggingface.co
14.4K
Total runs
266
24-hour runs
39
3-day runs
-2.5K
7-day runs
-67.5K
30-day runs
More Information About Qwen3-8B-DFlash-b16 huggingface.co Model
Qwen3-8B-DFlash-b16 huggingface.co is an AI model on huggingface.co that provides Qwen3-8B-DFlash-b16's model effect (), which can be used instantly with this z-lab Qwen3-8B-DFlash-b16 model. huggingface.co supports a free trial of the Qwen3-8B-DFlash-b16 model, and also provides paid use of the Qwen3-8B-DFlash-b16. Support call Qwen3-8B-DFlash-b16 model through api, including Node.js, Python, http.
Qwen3-8B-DFlash-b16 huggingface.co is an online trial and call api platform, which integrates Qwen3-8B-DFlash-b16's modeling effects, including api services, and provides a free online trial of Qwen3-8B-DFlash-b16, you can try Qwen3-8B-DFlash-b16 online for free by clicking the link below.
z-lab Qwen3-8B-DFlash-b16 online free url in huggingface.co:
Qwen3-8B-DFlash-b16 is an open source model from GitHub that offers a free installation service, and any user can find Qwen3-8B-DFlash-b16 on GitHub to install. At the same time, huggingface.co provides the effect of Qwen3-8B-DFlash-b16 install, users can directly use Qwen3-8B-DFlash-b16 installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
Qwen3-8B-DFlash-b16 install url in huggingface.co: