Support PP-free Megatron forward/backward warmup - #1830
Open
nvcastet wants to merge 1 commit into
Open
Conversation
nvcastet
requested review from
Shi-Dong,
Zhichenzzz,
fzyzcjy,
guapisolo,
jybsuper,
maocheng23,
yueming-yuan and
yushengsu-thu
as code owners
July 27, 2026 22:11
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add PP-free Megatron forward/backward warmup
Summary
Add an opt-in
--enable-pp-free-warmupoption for Megatron actors.Before the first actor step, every pipeline stage performs one local forward and backward pass concurrently. This initializes JIT kernels without pipeline dependencies, then initializes the bidirectional NCCL pipeline channels before the first real pipeline execution.
The warmup pass shaves ~20min on 1st step of DSV4+GB300 RL training (~4x speedup).
The warmup:
Motivation
During the first normal pipeline execution, a stage cannot compile its kernels until it receives activations from the preceding stage. Forward compilation therefore propagates from the first stage to the last. Backward compilation then propagates in reverse.
The first use of each pipeline communication path also triggers lazy NCCL setup.
Before: serialized pipeline warmup
flowchart LR R0F["Rank 0<br/>JIT compile FWD kernels"] C0F["NCCL PP<br/>comm setup"] MF["..."] RNF["Rank N<br/>JIT compile FWD kernels"] RNB["Rank N<br/>JIT compile BWD kernels"] CNB["NCCL PP<br/>comm setup"] MB["..."] R0B["Rank 0<br/>JIT compile BWD kernels"] R0F --> C0F --> MF --> RNF --> RNB RNB --> CNB --> MB --> R0BAfter: PP-free warmup on all ranks concurrently
flowchart TB subgraph S0["Rank 0"] direction LR R0F["JIT compile<br/>FWD kernels"] --> R0B["JIT compile<br/>BWD kernels"] --> R0C["PP comm setup"] end DOTS["..."] subgraph SN["Rank N"] direction LR RNF["JIT compile<br/>FWD kernels"] --> RNB["JIT compile<br/>BWD kernels"] --> RNC["PP comm setup"] end S0 ~~~ DOTS DOTS ~~~ SNPerformance
Measured on 16 GB300 nodes:
--distributed-timeout-minutes 60so the serialized first pass could completeValidation
Activations and gradients were dumped with and without warmup flag to validate that warmup did not impact training. The raw reward and KL were also compared.