Instructions to use yifanyu/QwenDLM-4B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use yifanyu/QwenDLM-4B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="yifanyu/QwenDLM-4B", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoModel model = AutoModel.from_pretrained("yifanyu/QwenDLM-4B", trust_remote_code=True, device_map="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use yifanyu/QwenDLM-4B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "yifanyu/QwenDLM-4B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yifanyu/QwenDLM-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/yifanyu/QwenDLM-4B
- SGLang
How to use yifanyu/QwenDLM-4B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "yifanyu/QwenDLM-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yifanyu/QwenDLM-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "yifanyu/QwenDLM-4B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "yifanyu/QwenDLM-4B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use yifanyu/QwenDLM-4B with Docker Model Runner:
docker model run hf.co/yifanyu/QwenDLM-4B
QwenDLM-4B
QwenDLM (4B): Qwen3-4B-Thinking-2507 converted into a block diffusion language model (SDAR-style, 256-token blocks) with a self-conditioning residual adapter, the start model of QwenDLM-4B-ORL
Results
Accuracy (%) / tokens per forward (TPF); each model uses its selected decoder.
| Model | GSM8K | MATH-500 | HumanEval | MBPP |
|---|---|---|---|---|
| QwenDLM-4B | 90.4 / 2.4 | 88.0 / 2.1 | 82.9 / 1.8 | 79.2 / 2.1 |
| QwenDLM-4B-ORL | 92.4 / 5.9 | 92.2 / 5.8 | 89.6 / 11.1 | 79.4 / 8.0 |
Speed

Tokens per second for a single request on one H100 (BF16), with the paper's prompts and decoders. dlmrt decodes QwenDLM-4B about 1.5× faster than SGLang, and ORL raises it to 1,298 tokens/s:
| Model | Engine | GSM8K | HumanEval | Mean |
|---|---|---|---|---|
| QwenDLM-4B | SGLang | 210 | 164 | 187 |
| QwenDLM-4B | dlmrt | 328 | 249 | 289 |
| QwenDLM-4B-ORL | SGLang | 718 | 1,148 | 933 |
| QwenDLM-4B-ORL | dlmrt | 987 | 1,609 | 1,298 |
Usage
Plain
transformersgeneration does not run the paper's decoding. Two engines do: dlmrt, our inference engine, and the ORL repository's SGLang engine and decoder configuration, which the paper's evaluation uses.
dlmrt
dlmrt, our inference engine, decodes one request at a time with the paper's decoder (role="base")
and measures the paper's throughput; see its README for installation, tensor parallelism and the commands of every
paper cell.
from dlmrt import LLM
llm = LLM("yifanyu/QwenDLM-4B", role="base")
out = llm.generate("Write a Python function that reverses a linked list.", max_new_tokens=4096)
print(out.text)
print(f"{out.request_tps:.0f} tokens/s")
python -m dlmrt serve --model yifanyu/QwenDLM-4B --role base --port 18080
curl -N localhost:18080/generate -d '{"messages": [{"role": "user", "content": "Hi!"}], "max_new_tokens": 512}'
The paper's evaluation pipeline
Reproduce the paper's numbers (GSM8K, MATH-500, HumanEval, MBPP) with the repository's evaluation pipeline:
git clone https://github.com/Introspective-Diffusion/ORL orl && cd orl/evaluation
export ORL_EVAL_WORK=/path/to/eval-work
bash scripts/build_images.sh && bash scripts/prepare.sh
hf download yifanyu/QwenDLM-4B --local-dir $ORL_EVAL_WORK/hf/QwenDLM-4B
bash scripts/main_table.sh qwen-dlm-base $ORL_EVAL_WORK/hf/QwenDLM-4B
Serve it with the engine settings of the evaluation (paper_decoding.json) and a paper decoder (here GSM8K's):
python3 -m repro.paper.render_config --suite main --model qwen-dlm-base --benchmark gsm8k --seed 1234 --out decoder.yaml
apptainer exec --nv -B "$PWD,$ORL_EVAL_WORK" $ORL_EVAL_WORK/images/sglang-gen.sif \
env PYTHONPATH=$ORL_EVAL_WORK/runtime/qwen-dlm/engine/inference/sglang \
SGLANG_FLASHINFER_PREFILL_BACKEND=fa3 SDAR_FUSED_ROW_STATS=1 SDAR_COMMIT_GRAPH=1 \
python3 -m sglang.launch_server --model-path $ORL_EVAL_WORK/hf/QwenDLM-4B --trust-remote-code \
--tp-size 1 --max-running-requests 1 --context-length 65536 --attention-backend flashinfer \
--chunked-prefill-size -1 --sdar-rollout-cuda-graph --sdar-rollout-cuda-graph-capture-sizes 1 \
--dllm-algorithm SDARPrefixKV --dllm-algorithm-config decoder.yaml --port 30000
Training ORL from this model
This is checkpoint 38750 of the QwenDLM conversion run. The ORL runs start from it after rescaling the residual adapter (the result's weights and configuration are byte-identical to the paper's start model); the training data is the dataset yifanyu/ORL-training-data:
hf download yifanyu/ORL-training-data --repo-type dataset --local-dir $DATA
apptainer exec -B $PWD $SIF $PY training/tools/make_scrp_base.py QwenDLM-4B QwenDLM-4B-scrp8 --gamma 8
bash training/scripts/reproduce_qwen_dlm.sh $RUNS/qwen_dlm QwenDLM-4B-scrp8 $DATA --sif $SIF --python $PY
Checkpoint identity
Paper role qwen-dlm-base. checkpoint_manifest.json records the hashes of the weights, tokenizer, configuration and
custom model code, and paper_decoding.json the engine and benchmark-specific decoding settings, which downloading
the model does not apply.
Related Models
| Model | Hugging Face | Description |
|---|---|---|
| Qwen3-4B-Thinking-2507 | Qwen/Qwen3-4B-Thinking-2507 | Start model of this checkpoint |
| QwenDLM-4B | yifanyu/QwenDLM-4B | This model |
| QwenDLM-4B-ORL | yifanyu/QwenDLM-4B-ORL | ORL on QwenDLM-4B |
| LLaDA2.1-mini-ORL | yifanyu/LLaDA2.1-mini-ORL | ORL on LLaDA-2.1-mini |
| LLaDA2.1-mini-ORL-NVFP4 | yifanyu/LLaDA2.1-mini-ORL-NVFP4 | NVFP4 quantization of LLaDA2.1-mini-ORL |
| DiffusionGemma-26B-A4B-it-ORL | yifanyu/DiffusionGemma-26B-A4B-it-ORL | ORL on DiffusionGemma-26B-A4B |
| DiffusionGemma-26B-A4B-it-ORL-NVFP4 | yifanyu/DiffusionGemma-26B-A4B-it-ORL-NVFP4 | NVFP4 quantization of DiffusionGemma-26B-A4B-it-ORL |
| ORL-training-data | yifanyu/ORL-training-data | Dataset of the three ORL training runs |
Citation
@misc{yu2026orl,
title = {On-Policy Residual Learning for Diffusion Language Models},
author = {Yu, Yifan and Jian, Yuqing and Li, Jisen and Hu, Yuezhou and Zhang, Tianyi and Wu, Xiaoxia and
Zhu, Rui-Jie and Wang, Junxiong and Zhou, Zhongzhu and Lai, Fan and Zou, James and Xu, Chenfeng},
year = {2026},
eprint = {2610.20687},
archivePrefix = {arXiv},
primaryClass = {cs.LG},
url = {https://arxiv.org/abs/2610.20687}
}
- Downloads last month
- 881