πŸ”₯ Open-dLLM: Open Diffusion Large Language Models

May 11, 2026 Β· View on GitHub

🌍 Languages: English | δΈ­ζ–‡ | ζ—₯本θͺž

πŸ‘‰ TL;DR: Open-dLLM is the most open release of a diffusion-based large language model to date β€”
including pretraining, evaluation, inference, and checkpoints.

Representation Alignment

Open-dLLM supports representation alignment for adapting autoregressive LMs into diffusion LMs with 4x speedup. This feature is based on our recent paper, Don’t Retrainβ€”Align: Adapting Autoregressive LMs to Diffusion LMs via Representation Alignment. Check out Representation Alignment Tutorial.

GitHub Β Β Β Β  Notion Β Β Β Β  Hugging Face

πŸ’» Code Β  | Β  πŸ“– Blog Β  | Β  πŸ€— Model

πŸŽ₯ Demo

Quick Sort Demo

QuickSort generation using Open-dCoder (0.5B)

YouTube link Β Β Β Β  Bilibili link


✨ Highlights

  • πŸ‹οΈ Pretraining pipeline + open datasets
  • ⚑ Inference scripts β€” easy sampling & generation
  • πŸ“Š Evaluation suite β€” HumanEval, MBPP, Infilling (lm-eval-harness + custom metrics)
  • πŸ“¦ Weights + checkpoints on Hugging Face
  • 🀝 Transparent configs for full reproducibility

Why Open-dLLM?

Most diffusion LLM repos (e.g., LLaDA, Dream) only release inference scripts + weights, which limits reproducibility.
Open-dLLM is the first to open-source the entire stack for diffusion LLMs.

πŸ‘‰ With Open-dLLM, you can go from raw data β†’ training β†’ checkpoints β†’ evaluation β†’ inference, all in one repo.


πŸ”Ž Transparency Comparison of Diffusion LLM Releases

ProjectDataTraining CodeInferenceEvaluationWeights
Open-dLLM / Open-dCoder (ours)βœ…βœ…βœ…βœ…βœ…
LLaDAβŒβŒβœ…βš οΈ Limitedβœ…
DreamβŒβŒβœ…βš οΈ Limitedβœ…
Gemini-Diffusion❌❌❌❌❌ (API only)
Seed Diffusion❌❌❌❌❌ (API only)
Mercury❌❌❌❌❌ (API only)

βœ… = fully available Β· ❌ = not provided Β· ⚠️ = partial/limited


βš™οΈ Install

We use micromamba for environment management (feel free to adapt to conda):

micromamba install -c nvidia/label/cuda-12.3.0 cuda-toolkit -y
pip install ninja

# install the newest torch with cu121
pip install torch==2.6.0 --index-url https://download.pytorch.org/whl/cu121

pip install "flash-attn==2.7.4.post1" \
  --extra-index-url https://github.com/Dao-AILab/flash-attention/releases/download

pip install --upgrade --no-cache-dir \
  tensordict torchdata triton>=3.1.0 \
  transformers==4.54.1 accelerate datasets peft hf-transfer \
  codetiming hydra-core pandas pyarrow>=15.0.0 pylatexenc \
  wandb ninja liger-kernel==0.5.8
# optional
pip install pytest yapf py-spy pyext pre-commit ruff packaging

pip install -e .
pip install lm-evaluation-harness/ human-eval-infilling/

πŸš€ Quickstart: Sampling

from transformers import AutoTokenizer
from veomni.models.transformers.qwen2.modeling_qwen2 import Qwen2ForCausalLM
from veomni.models.transformers.qwen2.generation_utils import MDMGenerationConfig
import torch

model_id = "fredzzp/open-dcoder-0.5B"
device = "cuda" if torch.cuda.is_available() else "cpu"

# Load tokenizer + model
tokenizer = AutoTokenizer.from_pretrained(model_id, trust_remote_code=True)
model = Qwen2ForCausalLM.from_pretrained(
    model_id, torch_dtype=torch.bfloat16, trust_remote_code=True
).to(device).eval()

# Prompt
prompt = "Write a quick sort algorithm in python."
input_ids = tokenizer(prompt, return_tensors="pt").input_ids.to(device)

# Generation config
gen_cfg = MDMGenerationConfig(max_new_tokens=128, steps=200, temperature=0.7)

with torch.no_grad():
    outputs = model.diffusion_generate(inputs=input_ids, generation_config=gen_cfg)

print(tokenizer.decode(outputs.sequences[0], skip_special_tokens=True))

πŸ‘‰ For full logging, history tracking, and file output:

python sample.py

πŸ“Š Benchmarking

We release a fully open-source evaluation suite for diffusion-based LLMs (dLLMs), covering both standard code generation tasks and code infilling tasks.

Benchmarks include: HumanEval / HumanEval+, MBPP / MBPP+, HumanEval-Infill, SantaCoder-FIM.


Standard Code Generation

MethodHumanEvalHumanEval+MBPPMBPP+
Pass@1Pass@10Pass@1Pass@10Pass@1Pass@10Pass@1Pass@10
LLaDA (8B)35.450.030.543.338.853.452.669.1
Dream (7B)56.759.250.053.755.456.271.572.5
Mask DFM (1.3B)9.117.67.913.46.225.0––
Edit Flow (1.3B)12.824.310.420.710.036.4––
Open-dCoder (0.5B, Ours)20.838.417.635.216.738.423.953.6

Despite being only 0.5B parameters, Open-dCoder competes with much larger dLLMs in code completion tasks.


Code Infilling

MethodHumanEval Infill Pass@1SantaCoder Exact Match
LLaDA-8B48.335.1
Dream-7B39.440.7
DiffuCoder-7B54.838.8
Dream-Coder-7B55.340.0
Open-dCoder (0.5B, Ours)32.529.6
Open-dCoder (0.5B, Ours) Oracle Length77.456.4

We followed the average fixed length evaluation setting in DreamOn to get the results.


πŸ§ͺ Evaluation

Install evaluation packages:

pip install -e lm-evaluation-harness human-eval-infilling

Code Completion (HumanEval, MBPP)

cd eval/eval_completion
bash run_eval.sh

Code Infilling

cd eval/eval_infill
bash run_eval.sh

πŸ‹οΈ Pretraining

  • Data: Concise, high-quality code corpus FineCode, hosted on Hugging Face.
  • Initialization: Following Dream, continued pretraining from Qwen2.5-Coder, adapting it into the diffusion framework.
  • Loss: Masked Diffusion Model (MDM) objective β€” masking ratios uniformly sampled from [0,1], reconstructed with cross-entropy loss.

Download Data

python3 scripts/download_hf_data.py --repo_id fredzzp/fine_code --local_dir ./data

Training

export TOKENIZERS_PARALLELISM=false
NNODES=1
NPROC_PER_NODE=$(nvidia-smi --query-gpu=name --format=csv,noheader | wc -l)
NODE_RANK=${NODE_RANK:=0}
MASTER_ADDR=${MASTER_ADDR:=0.0.0.0}
MASTER_PORT=${MASTER_PORT:=12345}



torchrun --nnodes=$NNODES --nproc-per-node $NPROC_PER_NODE --node-rank $NODE_RANK \
  --master-addr=$MASTER_ADDR --master-port=$MASTER_PORT tasks/train_torch.py \
  configs/pretrain/qwen2_5_coder_500M.yaml \
  --data.train_path=data/data \
  --train.ckpt_manager=dcp \
  --train.micro_batch_size=16 \
  --train.global_batch_size=512 \
  --train.output_dir=logs/Qwen2.5-Coder-0.5B_mdm \
  --train.save_steps=10000

example of multi-node training with repr alignment loss:


export TOKENIZERS_PARALLELISM=false

NNODES=${NNODES:=1}
NPROC_PER_NODE=$(nvidia-smi --query-gpu=name --format=csv,noheader | wc -l)
NODE_RANK=${NODE_RANK:=0}
MASTER_ADDR=${MASTER_ADDR:=0.0.0.0}
MASTER_PORT=${MASTER_PORT:=12345}
torchrun --nnodes=$NNODES --nproc-per-node $NPROC_PER_NODE --node-rank $NODE_RANK   --master-addr=$MASTER_ADDR --master-port=$MASTER_PORT  tasks/train_torch.py \
configs/pretrain/qwen2_5_coder_500M.yaml --data.train_path=data/data \
--data.num_workers=0 \
--data.prefetch_factor=1 \
--train.ckpt_manager=dcp \
--train.micro_batch_size=3 \
--train.global_batch_size=240 \
--train.repr_align_wt=10.0 \
--model.model_path=Qwen/Qwen2.5-Coder-3B-Instruct \
--train.save_steps=10000 \
--train.output_dir=logs/Qwen2.5-Coder-3B-Instruct_mdm_repr_align-10

Uploading Checkpoints to Hugging Face

from huggingface_hub import HfApi

REPO_ID = "fredzzp/open-dcoder-0.5B"
LOCAL_DIR = "logs/Qwen2.5-Coder-0.5B_mdm/checkpoints/global_step_370000/hf_ckpt"

api = HfApi()
api.create_repo(repo_id=REPO_ID, repo_type="model", exist_ok=True)
api.upload_folder(repo_id=REPO_ID, repo_type="model", folder_path=LOCAL_DIR)

πŸ™ Appreciation

This project builds on incredible prior work:

We stand on the shoulders of these projects, and hope Open-dLLM contributes back to the diffusion LLM community.

πŸ“š Citation

If you use Open-dLLM or Open-dCoder in your research, please cite us:

@misc{opendllm2025,
  title        = {Open-dLLM: Open Diffusion Large Language Models},
  author       = {Fred Zhangzhi Peng, Shuibai Zhang, Alex Tong, and contributors},
  year         = {2025},
  howpublished = {\url{https://github.com/pengzhangzhi/Open-dLLM}},
  note         = {Blog: \url{https://oval-shell-31c.notion.site/Open-Diffusion-Large-Language-Model-25e03bf6136480b7a4ebe3d53be9f68a?pvs=74}, 
                  Model: \url{https://huggingface.co/fredzzp/open-dcoder-0.5B}}
}