Views
No views yet

| Model Name | Base Model 🤗 | HF Link 🤗 |
|---|---|---|
| SDLM-3B-D4 | Qwen2.5-3B | https://huggingface.co/OpenGVLab/SDLM-3B-D4 |
| SDLM-3B-D8 | Qwen2.5-3B | https://huggingface.co/OpenGVLab/SDLM-3B-D8 |
| SDLM-32B-D4 | Qwen2.5-32B | https://huggingface.co/OpenGVLab/SDLM-32B-D4 |





transformers==4.37.2
torch>=2.5.0SDLM-3B-D4 using transformers.1import torch
2from transformers import AutoModelForCausalLM, AutoTokenizer
3from sdlm_inference import SDLM_generate
4
5if __name__ == "__main__":
6 ckpt_hf = 'OpenGVLab/SDLM-3B-D4'
7
8 model = AutoModelForCausalLM.from_pretrained(
9 ckpt_hf,
10 attn_implementation="eager",
11 trust_remote_code=True
12 ).to(dtype=torch.float16)
13 tokenizer = AutoTokenizer.from_pretrained(ckpt_hf)
14
15 prompt = 'Write a Fibonacci function in Python.'
16 messages = [
17 {"role": "system", "content": "You are a helpful assistant."},
18 {"role": "user", "content": prompt}
19 ]
20 text = tokenizer.apply_chat_template(
21 messages,
22 tokenize=False,
23 add_generation_prompt=True
24 )
25
26 model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
27
28 response, history = SDLM_generate(
29 model,
30 tokenizer,
31 model_inputs,
32 max_gen_len = 1024,
33 temperature = 0,
34 threshold = 0.5,
35 n_future_tokens = 4,
36 alg = 'prob_conf', # prob_conf | entropy_conf | self_speculative
37 save_history = True,
38 use_cache = True
39 )
40
41 print('response: ', response[0])
42
43 print('=======histroy')
44 for item in history:
45 print('cur total token ', item[1])
46 print(item[0][0])
47 print('--------')1@article{liu2025sdlm,
2 title={Sequential Diffusion Language Models},
3 author={Liu, Yangzhou and Cao, Yue and Li, Hao and Luo, Gen and Chen, Zhe and Wang, Weiyun and Liang, Xiaobo and Qi, Biqing and Wu, Lijun and Tian, Changyao and Zhang, Yanting and Li, Yuqiang and Lu, Tong and Qiao, Yu and Dai, Jifeng and Wang, Wenhai},
4 journal={arXiv preprint arXiv:2509.24007},
5 year={2025}
6}