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 sdpa or --attn eager (not flash_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
-
Safetensors
Model size
4B params
Tensor type
F32
·
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support

Model tree for xuan-luo/test-parallel

Finetuned
Qwen/Qwen3-4B
Finetuned
(877)
this model

Dataset used to train xuan-luo/test-parallel

Papers for xuan-luo/test-parallel