Instructions to use xuan-luo/test-parallel with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use xuan-luo/test-parallel with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="xuan-luo/test-parallel", trust_remote_code=True) messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoModelForCausalLM model = AutoModelForCausalLM.from_pretrained("xuan-luo/test-parallel", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use xuan-luo/test-parallel with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "xuan-luo/test-parallel" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "xuan-luo/test-parallel", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/xuan-luo/test-parallel
- SGLang
How to use xuan-luo/test-parallel 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 "xuan-luo/test-parallel" \ --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": "xuan-luo/test-parallel", "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 "xuan-luo/test-parallel" \ --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": "xuan-luo/test-parallel", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use xuan-luo/test-parallel with Docker Model Runner:
docker model run hf.co/xuan-luo/test-parallel
Direct Multi-Token Decoding (DMTD) — Qwen3-4B
This repository contains the model for Direct Multi-Token Decoding.
Direct Multi-Token Decoding (DMTD) reuses the late ("decoding") layers of a decoder-only LLM to directly emit multiple tokens per cycle. DMTD adds no extra parameters, no auxiliary draft model, and no post-generation verification — it just fine-tunes the original network to decode in fixed multi-token cycles, giving up to ~2× inference speedup with minor quality loss.
Importantly, DMTD is complementary to speculative decoding: because a DMTD model can act as its own fast drafter, you can layer speculative decoding on top of DMTD. This repo ships several such self-speculative variants (see Decoding methods).
This checkpoint reuses the last 8 of 36 layers as decoding layers (E0D8) with a decoding cycle
length of mtp_horizon = 4.
🏋️ Training code lives on GitHub: luoxuan-cs/Direct-Multitoken-Decoding (how to download the dataset, process it, and run SFT).
Decoding methods
We implement several decoding methods on top of the same DMTD checkpoint. Each has a self-contained benchmark script that runs a think-mode math prompt and reports decoding-stage throughput. Because DMTD is compatible with speculative decoding, most variants are self-speculative (the DMTD model drafts and verifies itself, so the greedy output is lossless w.r.t. the full DMTD model). We don't cover the algorithmic details here — see the scripts and the paper.
- Vanilla (
generation_vanilla.py) — standard one-token-at-a-time Qwen3 baseline. - DMTD (
generation.py) — core direct multi-token decoding with cyclical refilling. - DMTD + speculative decoding (
generation_sd.py) — linear self-speculative drafting + one-shot verification. - DMTD + tree speculative decoding (
generation_tree_sd.py) — builds a tree of candidates verified in a single forward. - DMTD + Medusa-style tree speculative decoding (
generation_medusa_style.py) — per-step top-k act as Medusa "heads" assembled into a sparse tree.
Example invocations:
python generation_vanilla.py --max-new-tokens 256
python generation.py --max-new-tokens 256
python generation_sd.py --num-speculations 3 --max-new-tokens 256
python generation_tree_sd.py --branches 2,2,2 --max-new-tokens 256
python generation_medusa_style.py --topk 10 --max-new-tokens 256
Common flags: --max-new-tokens, --seed, --attn {sdpa,eager}, --dtype {bfloat16,float16,float32},
--prompt "...". Method-specific knobs: --num-speculations k (linear SD), --branches b0,b1,b2
(tree SD), --topk (Medusa-style). Speculative scripts also accept --check-lossless.
The DMTD inference models build explicit 4D attention masks — run them with
--attn sdpaor--attn eager(notflash_attention_2).
Citation
@article{luo2025dmtd,
title = {Direct Multi-Token Decoding},
author = {Luo, Xuan and Wang, Weizhi and Yan, Xifeng},
journal = {arXiv preprint arXiv:2510.11958},
year = {2025},
url = {https://arxiv.org/abs/2510.11958}
}
Trained on a-m-team/AM-Thinking-v1-Distilled (arXiv:2505.14464). Please also cite the dataset if you use it. The dataset is released for research purposes only.
Training code: luoxuan-cs/Direct-Multitoken-Decoding
- Downloads last month
- -