Faster Rollouts with MTP Speculative Decoding
MTP training requires the megatron backend and the vllm inference engine.
MTP is not supported on the Tinker backend yet.
MTP traininng is currently experimental. We are actively working on benchmarking MTP in fully async, multi-turn RL scenarios as well as providing guidelines on when it is most useful.
In this example we train a model's native Multi-Token Prediction (MTP) head with a decoupled draft loss, and reuse that head for vLLM speculative decoding to speed up rollout. Because the draft loss is autograd-decoupled, it trains only the MTP head and never perturbs the policy, leaving the RL dynamics unchanged.
Source code: examples/train/spec_decode/.
Overview
During RL training, rollouts (generation) are typically the throughput bottleneck. Speculative decoding improves throughput (at lower batch size) with a small, cheap drafter that proposes the next k tokens, which the policy then verifies in a single forward pass.
Since the policy distribution changes in RL, the drafter must be co-trained to stay aligned. By default SkyRL trains the MTP heads with a hard-label cross-entropy on the tokens the policy generated. At CP=1 and PP=1, the distribution loss (a top-k soft cross-entropy against the policy's own next-token distribution) is an option.
There are two pieces:
- Training the head — a decoupled draft loss trains the MTP head on the policy's own outputs on the Megatron backend.
- Drafting with it — the trained head is handed to vLLM as an MTP drafter. Every weight sync reloads it: in vLLM's native draft session right after the policy under
ncclanddelta, or in the policy's own session undersharded_rdt.
How does it work?
The draft loss reuses the hidden states the policy's forward pass already computed: it replays the MTP block on the detached trunk and trains the head against the token the policy generated (hard_label) or the policy's own detached next-token distribution (distribution). The loss is vocab-parallel, so it works under tensor parallelism.
Everything but the head is detached: trunk, re-embedding, output weight, and teacher. So the draft gradient reaches only the MTP head, never the backbone. The head shares the policy's gradient buffer and optimizer but is clipped by its own gradient norm.
Enabling MTP
trainer.mtp is the single high-level knob. It propagates to both the training side (Megatron MTP heads + draft loss) and the inference side (vLLM speculative_config):
trainer.mtp.enabled=true \
trainer.mtp.num_speculative_tokens=3 \
trainer.mtp.loss_weight=0.2This requires an MTP-capable checkpoint — most recent models ship one. Training always trains the checkpoint's own heads. If the model resolves to zero heads, the run fails during model init rather than silently training without a drafter.
num_speculative_tokens is the vLLM draft depth, independent of the trained head count. Single-head checkpoints reuse the one head autoregressively at depths > 1 — more speedup, but acceptance decays with depth, since the head only trains at depth 1. Start at k=3 and tune with the per-depth metrics.
The draft loss is megatron backend only. trainer.mtp.enabled=true under trainer.strategy=fsdp will not build any heads.
Syncing the drafter requires the megatron backend and the nccl (default), delta or sharded_rdt weight sync backend. Serialized FP8 weight sync and adapter-only LoRA (merge_lora=false) are rejected at config validation.
Configuration
The high-level knob:
| Field | Default | Description |
|---|---|---|
trainer.mtp.enabled | false | Train MTP heads and use them for speculative decoding. |
trainer.mtp.num_speculative_tokens | 1 | vLLM draft depth per step. |
trainer.mtp.loss_weight | 0.1 | Weight w of the draft loss in policy_loss + w * draft_loss. The draft loss is a token mean over the whole mini-batch (every microbatch and DP rank), so each token weighs the same however the mini-batch is split. |
trainer.mtp.loss_type | hard_label | Draft loss. distribution distills the policy's full next-token distribution, so it needs CP=1, PP=1 and trainer.fused_lm_head_logprob=false. hard_label is cross-entropy on the generated tokens and also runs with CP, PP and the fused LM head. |
trainer.mtp.lr | null | Peak learning rate of the MTP heads, in their own optimizer param group on the policy's schedule. null uses the policy's optimizer_config.lr. A pretrained head barely moves at an RL lr such as 1e-6, so a head that should track the policy usually needs a larger one. |
Megatron-side fields tune the draft loss; most distribution runs only need mtp_loss_topk. The hard_label loss rejects a set mtp_loss_topk:
| Field | Default | Description |
|---|---|---|
mtp_num_layers | null | Head count. null honors the model's HF config; 0 force-disables MTP. |
mtp_loss_topk | null | distribution only. Distill the teacher's top-k tokens instead of the full vocab: O(seq*k) memory rather than O(seq*vocab). null uses the exact full-vocab loss. |
mtp_loss_chunk_size | 1024 | Sequence-chunk size for the draft loss, to bound peak memory: distribution checkpoints each chunk of its full-vocab soft cross-entropy (and ignores it when mtp_loss_topk is set), hard_label chunks its log-prob computation. Numerically identical to no chunking. |
mtp_loss_weight | 0.1 | Set automatically from trainer.mtp.loss_weight. |
mtp_loss_type | hard_label | Set automatically from trainer.mtp.loss_type. |
Example
Complete examples in examples/train/spec_decode/; the first two run on a single 8xH100 node:
| Script | Task | Model |
|---|---|---|
run_megatron_dapo_mimo_7b_rl_specdecode.sh | DAPO on dapo-math-17k | XiaomiMiMo/MiMo-7B-RL |
run_megatron_dapo_qwen3.5_9b_specdecode.sh | DAPO on dapo-math-17k | Qwen/Qwen3.5-9B |
run_megatron_dapo_glm5.3_specdecode.sh | DAPO on dapo-math-17k, multi-node (8x8 B200) | zai-org/GLM-5.3-BF16 |
The MTP-specific parameters are:
MTP_ENABLED=true
MTP_NUM_SPECULATIVE_TOKENS=3
MTP_LOSS_WEIGHT=0.2
MTP_LOSS_TOPK=256
uv run --isolated --extra megatron -m examples.train.algorithms.dapo.main_dapo \
trainer.strategy=megatron \
trainer.mtp.enabled=$MTP_ENABLED \
trainer.mtp.num_speculative_tokens=$MTP_NUM_SPECULATIVE_TOKENS \
trainer.mtp.loss_weight=$MTP_LOSS_WEIGHT \
trainer.mtp.loss_type=distribution \
trainer.policy.megatron_config.mtp_loss_topk=$MTP_LOSS_TOPK \
generator.inference_engine.backend=vllm \
...To run it (from the SkyRL root directory):
bash examples/train/algorithms/dapo/prepare_dapo_data.sh
export WANDB_API_KEY=<your_key_here>
bash examples/train/spec_decode/run_megatron_dapo_mimo_7b_rl_specdecode.shMonitoring acceptance
Acceptance determines your speedup. It is logged under vllm/train/:
draft_acceptance_rate— accepted / drafted tokens.draft_mean_acceptance_length— tokens produced per target forward pass. This is the speedup factor: 1.0 means no gain,k+1is the ceiling.draft_acceptance_rate_pos_{1..k}— per-depth breakdown.draft_num_draft_tokens,draft_num_accepted_tokens— raw counts.
The draft loss is logged as mtp_loss on the training side.
Watch the per-depth breakdown when tuning k: acceptance decays with depth, so a low draft_acceptance_rate_pos_k means k is too deep for your model.
Results
We evaluate a DAPO run of Qwen3.5-9B against a baseline with speculative decoding disabled. The runs differ only in the MTP switch.
Setup. Single 8xH100 node. Training: Megatron TP=4, PP=1, CP=1, bf16. Rollout: 8 vLLM engines (round-robin router), depth-3 speculative decoding. DAPO on dapo-math-17k, AIME-2024 eval, 32 prompts x 8 samples/step, max_generate_length=8192.
Rollout throughput
Speculative decoding roughly doubles generation throughput in rollout:

| Phase | Baseline | MTP | Speedup |
|---|---|---|---|
| Total step | 400.7 s | 246.8 s | 1.62x |
| Rollout | 310.1 s | 152.4 s | 2.03x |
| Policy train | 57.3 s | 61.3 s | 0.93x |
Rollout is 2.03x faster; at ~77% of the step, that gives a 1.62x step speedup. Draft acceptance was 77.3%, with a mean accepted length of 3.32 tokens (88.6/77.0/66.3% at depth 1/2/3).
No effect on policy training
Reward and policy loss track the baseline, differing only by the run-to-run noise of independent runs. test_mtp_grad_isolation asserts the gradient isolation directly in CI.


Small training overhead
The MTP head adds ~7% to the train phase (57.3 → 61.3 s/step), easily paid for by the 2x rollout speedup.

Multi-node: GLM-5.3 on 8x8 B200
run_megatron_dapo_glm5.3_specdecode.sh applies the same A/B to GLM-5.3 (753B MoE). See examples/train/spec_decode/README.md for the Ray and env-file setup.
Setup. 8x8 B200, not colocated: 6 trainer nodes and 2 inference nodes.
- Training: Megatron
TP=1, CP=16, PP=3, EP=16, bf16, optimizer state on node-local NVMe. - Rollout: 2 vLLM DP8 x EP8 engines with NVFP4 routed experts and an NVFP4 KV cache, weight sync over
sharded_rdt, depth-4 probabilistic drafting. - DAPO on
dapo-math-17k, 16 prompts x 16 samples/step,max_generate_length=8192. mainplus the MTP training PRs (#2758, #2760, #2762, #2763), from a freshuv sync --extra megatron.- 4 steps per arm, run one after the other on the same nodes; means over steps 2–4.
| Phase | Baseline | MTP | Speedup |
|---|---|---|---|
| Total step | 392 s | 289 s | 1.36x |
| Rollout | 186 s | 79 s | 2.36x |
| Policy train | 157 s | 160 s | 0.98x |
| Weight sync | 11.5 s | 11.6 s | 0.99x |
Rollout is 2.36x faster; at ~47% of the step, that gives a 1.36x step speedup. The mean accepted length was 3.66 tokens, with 88.3 / 73.0 / 58.7 / 46.3% acceptance at depth 1 / 2 / 3 / 4. Every step has a response cut at 8,192 tokens, so rollout time is set by that longest sequence; its decode speedup (2.37x) matches the rollout speedup.
No effect on policy training. Reward and the rollout/trainer log-prob gap are similar in both arms (one run each, over steps 2-4): 0.20 vs 0.18 raw reward, 0.071 vs 0.071 mean |log-prob diff|.
What's Next
Native MTP heads are the first drafter SkyRL supports. We're working on broader drafter support:
- DFlash
- DSpark
- EAGLE-3
- Dynamic draft length