Repository navigation
Description
Summary
Decision requested. Review the two opt-in BF16 EAGLE3 drafts as a pair. ModelOpt owns the teacher feature adapter and final normalization. Megatron-LM owns data selection, next-token batching and its training integration. Keep the existing offline checkpoint and feature contract. Use a matched-total-GPU TP sweep on a representative larger workload to decide whether CP is needed.
What the pilot shows. Megatron-LM processed teacher tokens faster in the online training window in all five long-context pairs. HF finished the full 40-step training command sooner in all five. Combined peak GPU memory favored Megatron-LM on Qwen3 and HF on SmolLM2. Exported checkpoints had acceptance length within 0.008 and identical greedy outputs on the tested prompts. The results establish feasibility and motivate a TP comparison under the same GPU and producer budget.
ModelOpt #3473 · Megatron-LM #9550 · Original issue #3349
Performance Findings
- Online throughput and end-to-end command time answer different questions. Online throughput covers teacher prefill, feature transfer and trainer updates. End-to-end command time starts with the producer ready and also includes trainer startup, initialization, checkpoint loading and saving. In the Qwen3 8,192-token pair, the online window took 31.9 s on HF and 23.3 s on Megatron-LM. The full commands took 61.2 s and 73.1 s, leaving 29.3 s and 49.8 s outside the measured online window. That extra time outweighed the faster Megatron-LM training window at 40 steps. The pilot did not time the individual startup and save phases.
- Memory depended on the teacher and drafter configuration. At the tested Qwen3 settings, Megatron-LM was 32–50% faster online and used 30–35% less combined peak GPU memory. At the tested SmolLM2 settings, it was 6–11% faster online and used 19–22% more combined peak GPU memory. The SmolLM2 7,680-token Megatron-LM attempt stopped in Transformer Engine's unfused attention softmax while the shared training GPU had 454 MiB free. The completed paired comparison used 6,144 tokens.
- Increasing drafter depth widened the online throughput gap in the controlled Qwen3 4,096-token case. The four- and eight-layer drafters had 70.3M and 133.2M trainable parameters and identical overlapping initial tensors. With eight layers HF online throughput fell 14%, while Megatron-LM fell 3%. Acceptance length stayed close to 1.21 for both.
- Exported acceptance length was close across backends. The largest paired difference was 0.0076. The two exports in each case generated identical greedy token sequences for all 12 held-out prompts under the evaluation configuration.
Benchmark measurement
The short-context feasibility run and long-context follow-up used distinct counters and timing boundaries. Interpret comparisons within each series.
| Series | Token count | GPU memory scope | Time window |
|---|---|---|---|
| Short-context feasibility | 40 × (S − 1) next-token labels in the fixed corpus |
Trainer-only peak PyTorch allocated memory. The separate TP=2 check reports per-rank allocation | HF Trainer's train_runtime or the sum of Megatron-LM's logged iteration times. Both include initial training iterations |
| Long-context follow-up | Teacher input tokens for the first 40 consumed samples (40 × S). HF prefetches one additional sample and its overhead remains in the measured time |
Peak sum of simultaneous NVML samples for the trainer process tree and vLLM producer engine. Other jobs are excluded from the sum | Synchronized online training window covering prefill, feature transfer and updates. End-to-end command time is measured separately from trainer launch through checkpoint save, with the producer already running |
| Exported acceptance length | 1 + accepted draft tokens / draft rounds, aggregated over the requests |
— | Separate greedy decode evaluation after export and packaging |
Shared-host load can affect timing. Both training series used same-host NIXL/UCX. The long-context follow-up used two RTX PRO 6000 Blackwell GPUs and kept the trainer and producer placement fixed. The vLLM 0.29.0 producer had a 1.5 GiB KV cache, concurrency 2 and four transfer slots. Within each pair, teacher weights, input order and initial drafter weights matched. The first 40 input token sequences matched by hash. Both trainers used BF16, batch size 1, TTT=1, TP=CP=PP=1 and AdamW with FP32 master weights at a constant learning rate of 1e-4. WikiText-103 revision
Long-context follow-up
Each cell is HF / Megatron-LM. Training loss is the mean of the last five native log entries. The implementations differ slightly in sequence-boundary masking. Both native exports were packaged for vLLM with a common tensor layout, teacher RoPE and RMSNorm settings, auxiliary-layer configuration and frozen teacher weights where needed. Acceptance length used 12 held-out WikiText-103 prompts per pair, 128 greedy output tokens per prompt and a three-token speculative budget. vLLM acceptance metric
| Teacher | Draft layers | Context tokens | Online throughput (teacher tokens/s) | Combined peak GiB | Training loss (last 5) | Acceptance length | End-to-end command time (s) |
|---|---|---|---|---|---|---|---|
| Qwen3-0.6B | 4 | 4,096 | 9,627 / 12,736 | 25.74 / 16.99 | 6.954 / 6.959 | 1.210 / 1.209 | 46.3 / 62.6 |
| Qwen3-0.6B | 4 | 8,192 | 10,285 / 14,087 | 50.54 / 32.77 | 6.718 / 6.723 | 1.202 / 1.209 | 61.2 / 73.1 |
| Qwen3-0.6B | 8 | 4,096 | 8,285 / 12,402 | 31.11 / 21.76 | 6.838 / 6.844 | 1.211 / 1.214 | 49.1 / 61.5 |
| SmolLM2-360M-Instruct | 8 | 4,096 | 10,437 / 11,018 | 19.93 / 23.71 | 8.431 / 8.435 | 1.259 / 1.255 | 39.1 / 61.3 |
| SmolLM2-360M-Instruct | 8 | 6,144 | 9,722 / 10,808 | 34.63 / 42.36 | 8.024 / 8.029 | 1.223 / 1.224 | 49.5 / 69.8 |
These benchmark measurements used ModelOpt 49304a5700f6d4a38aa15c98c557d80081f265a9 and Megatron-LM 3642b5686b0dce123fd9f5cfe893e43152e510aa.
Short-context feasibility
The initial series used Qwen3-0.6B and a one-layer drafter for 40 steps. Columns retain the short-context measurement definitions above.
| Sequence cap | HF labels/s | Megatron-LM labels/s | HF trainer peak | Megatron-LM trainer peak |
|---|---|---|---|---|
| 256 | 1,314 | 1,375 | 1,560 MiB | 1,183 MiB |
| 1,024 | 4,939 | 4,591 | 3,920 MiB | 2,386 MiB |
The separate TP=2 feasibility check at 256 tokens completed 12 updates with 12 producer requests and about 929 MiB peak PyTorch allocation per rank. That run used a second trainer GPU. A separate 450-token check matched every teacher top-1 token against eager Transformers and measured 2.2% relative L2 logit error. A fixed-weight GPU regression matched logits and loss exactly between streaming pre-norm and equivalent offline post-norm inputs.
Cross-repository interface contract
- Capture-layer IDs. Serving and checkpoint conversion use the same teacher weights and tokenizer. The checkpoint's auxiliary IDs are zero-based transformer layer outputs. vLLM takes completed-layer counts. Send each configured auxiliary ID plus one in forward layer order, followed by a distinct final capture at the teacher's layer count. For Qwen3-0.6B, checkpoint IDs
[1, 13, 24]map to vLLM captures[2, 14, 25, 28]. The capture descriptor reports tokens and tensor metadata. Layer identity and order are set in configuration. - Token, feature and mask alignment. The producer returns BF16 capture planes shaped
[T, K+1, H], one row per captured prompt token and one plane per auxiliary layer plus the final residual. The reader checks the returned prompt token IDs and assigns zero supervision to any extra decode position. For trainer sequence capS, ModelOpt emitsS+1token IDs and an unshifted mask, plusSfeature rows of widthK*HandH. It right-pads IDs with EOS and pads features and supervision with zeros. Megatron-LM uses IDs[:S]as inputs and IDs and supervision[1:S+1]for next-token labels and their mask. TP rank 0 reads once per replica, and the existing broadcast passes the features to the offline forward in sequence-major layout. - Final norm. The slot's final plane is the pre-norm residual. The streaming forward sets
base_hidden_prenorm=True, prompting ModelOpt to apply the checkpoint's final norm once before the teacher LM head. Existing disk-backed post-norm features use the default path. - Supported layout. The connector needs a single identifiable capture cache group and a four-dimensional per-layer cache view with an unambiguous capture-plane axis. Disable chunked prefill and prefix caching for the whole-prompt capture path. A slot must fit the entire prompt, and the server must allow one additional generation token. The trainer integration covers BF16 text, an offline EAGLE3 GPTModel checkpoint, micro-batch size 1 and CP=PP=1.
ModelOpt streaming reader · Megatron-LM offline finetune entry point
Tradeoffs and next decision
- An offline dump gives a reusable parity reference and avoids repeating teacher compute when the same features are replayed. Streaming removes corpus writes and reads and pays teacher compute on each replay.
- TP shards draft parameters and optimizer state but broadcasts full teacher features to the participating ranks. The current logits path also gathers vocabulary shards. At width
H=4096, three auxiliary planes plus the final plane use 32 KiB per BF16 teacher token, or 128 MiB per 4,096-token sample before transport overhead. Inter-node RDMA remains unmeasured here. - Use the same total GPU and producer budget to measure TP at target drafter sizes and context lengths. Record the online throughput, end-to-end command time, combined and per-rank memory, training loss and exported acceptance length. Decide whether CP is justified from the resulting memory and throughput profiles. A CP change would require parity for IDs, labels, masks, positions and teacher features after sequence partitioning.
- The remaining interface question is whether a future protocol should advertise capture-layer IDs and pre-norm/post-norm semantics for validation at startup.
Companion drafts ModelOpt #3473 and Megatron-LM #9550.
Activity