We are thrilled to introduce Stable-DiffCoder, which is a strong code diffusion large language model. Built directly on the Seed-Coder architecture, data, and training pipeline, it introduces a block diffusion continual pretraining (CPT) stage with a tailored warmup and block-wise clipped noise schedule.
Under identical architecture and data settings, we systematically analyze and design an efficient diffusion training pipeline that is not only stable but also potentially lifts the model’s performance ceiling. With this recipe, Stable-DiffCoder demonstrates overall performance improvements compared to its autoregressive (AR) counterpart across a broad set of code benchmarks, while any-order modeling improves structured code handling for editing and reasoning, and diffusion-based corruption aids learning for low-resource programming languages.
Notably, with only CPT followed by supervised fine-tuning, Stable-DiffCoder further surpasses many strong ∼8B AR and diffusion-based code models. These results demonstrate that diffusion-based training can improve code modeling quality beyond what AR training alone can achieve, even under tightly controlled data and architecture constraints.
This repo contains the
Stable-DiffCoder-8B-Base
model, which has the following features:
You need to install a specific version of
transformers
to adapt to the inference process:
pip install transformers==4.46.2
Explanation of Inference Parameters
steps
: Number of steps for diffusion generation
gen_length
: Maximum length of the generated output
block_length
: Length of the diffusion block, with a default value of 4
temperature
: Temperature for generation, with a default value of 0.0
remasking
: Remasking strategy, optional values are 'low_confidence' or 'random', default value is 'low_confidence' (for principle, refer to
LLADA
)
tokenizer
: Tokenizer used for text encoding and decoding
shift
: Whether to shift the output to the right by one position (similar to AutoRegressive/AR), default value is False
threshold
: Threshold for decoding (range: 0-1.0), default value is None; a smaller value results in faster decoding speed (for principle, refer to
Fast-DLLM
)
eos_id
: ID of the end-of-sequence token, default value is
tokenizer.eos_token_id
Quickstart
Here is a simple example demonstrating how to load the model and generate code.
Stable-DiffCoder-8B-Base natively supports Fill-in-the-Middle (FIM) tasks, where the model is given a prefix and a suffix and asked to predict the missing middle content. This allows for code infilling scenarios such as completing a function body or inserting missing logic between two pieces of code.
from transformers import AutoTokenizer, AutoModelForCausalLM
import torch
device = 'cuda'
model = AutoModelForCausalLM.from_pretrained('ByteDance-Seed/Stable-DiffCoder-8B-Base', trust_remote_code=True, torch_dtype=torch.bfloat16).to(device).eval()
tokenizer = AutoTokenizer.from_pretrained('ByteDance-Seed/Stable-DiffCoder-8B-Base', trust_remote_code=True)
prefix = "def add_numbers(a, b):\n "
suffix = "\n return result"# Combine prefix and suffix following the FIM format
prompt = '<[fim-suffix]>' + suffix + '<[fim-prefix]>' + prefix + '<[fim-middle]>'
input_ids = tokenizer(prompt)['input_ids']
input_ids = torch.tensor(input_ids).to(device).unsqueeze(0)
out = model.generate(input_ids, steps=64, gen_length=64, block_length=4, temperature=0., remasking='low_confidence', tokenizer=tokenizer, shift=False, threshold=None, eos_id=tokenizer.eos_token_id)
print(tokenizer.decode(out[0][input_ids.shape[1]:], skip_special_tokens=True))
Evaluation
Stable-DiffCoder-8B-Base has been evaluated on code generation, code completion, and code reasoning benchmarks, achieving state-of-the-art performance among ~8B open-source models.
This project is licensed under the MIT License. See the
LICENSE file
for details.
Citation
If you find our work helpful, feel free to give us a cite.
@misc{seed2026stablediffcoder,
title={{Stable-DiffCoder}: Pushing the Frontier of Code Diffusion Large Language Model},
author={{ByteDance Seed} and Chenghao Fan and Wen Heng and Bo Li and Sichen Liu and Yuxuan Song and Jing Su and Xiaoye Qu and Kai Shen and Wei Wei},
year={2026}
}
Runs of ByteDance-Seed Stable-DiffCoder-8B-Base on huggingface.co
302
Total runs
-9
24-hour runs
6
3-day runs
-37
7-day runs
28
30-day runs
More Information About Stable-DiffCoder-8B-Base huggingface.co Model
Stable-DiffCoder-8B-Base huggingface.co is an AI model on huggingface.co that provides Stable-DiffCoder-8B-Base's model effect (), which can be used instantly with this ByteDance-Seed Stable-DiffCoder-8B-Base model. huggingface.co supports a free trial of the Stable-DiffCoder-8B-Base model, and also provides paid use of the Stable-DiffCoder-8B-Base. Support call Stable-DiffCoder-8B-Base model through api, including Node.js, Python, http.
Stable-DiffCoder-8B-Base huggingface.co is an online trial and call api platform, which integrates Stable-DiffCoder-8B-Base's modeling effects, including api services, and provides a free online trial of Stable-DiffCoder-8B-Base, you can try Stable-DiffCoder-8B-Base online for free by clicking the link below.
ByteDance-Seed Stable-DiffCoder-8B-Base online free url in huggingface.co:
Stable-DiffCoder-8B-Base is an open source model from GitHub that offers a free installation service, and any user can find Stable-DiffCoder-8B-Base on GitHub to install. At the same time, huggingface.co provides the effect of Stable-DiffCoder-8B-Base install, users can directly use Stable-DiffCoder-8B-Base installed effect in huggingface.co for debugging and trial. It also supports api for free installation.
Stable-DiffCoder-8B-Base install url in huggingface.co: