Downloads · 30 days
19
2% of all-time downloads
xuan-luo/DMTD-Qwen3-4B
DMTD-Qwen3-4B is a text generation model from xuan-luo. Use it when you need the model to write or continue text. It is set up for transformers. The card lists the license as cc-by-nc-4.0.
This repository contains the model for Direct Multi-Token Decoding.
Downloads · 30 days
19
2% of all-time downloads
All-time downloads
1.1K
Public
Parameters
4B
8.1 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors8 GB · 100%
From the Hugging Face model README
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).
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.
generation_vanilla.py) — standard one-token-at-a-time Qwen3 baseline.generation.py) — core direct multi-token decoding with cyclical refilling.generation_sd.py) — linear self-speculative drafting + one-shot verification.generation_tree_sd.py) — builds a tree of candidates verified in a single forward.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).
@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