What the four startup switches in #5001 move earlier, and what still runs in order
NVIDIA-NeMo/RL #5001
(builds on the Megatron compile cache from #4715).
All permalinks pin the PR head 5223071.
Before
Single-controller setup reserves the vLLM workers first, then builds vLLM, NeMo-Gym and the trainer side by side. It checks the dataset's Gym routes only after Gym is up. Every job's first training step pays for torch.compile and Triton autotuning from scratch.
This PR
Four switches, all off by default, set as environment variables: start the trainer earlier, scan routes earlier, keep compile results between jobs, and run a fake first step ahead of time.
Status
New and opt-in. The review is still pending. It asks to turn two switches on for everyone with no flag, and to make the warm-up a config key (C2). It also it found a crash in the warm-up switch when CUDA graphs are on (page 2).
Three pages on this PR. This one shows the feature. Page 2 shows a crash the review found in it; page 3 proposes a simpler way for setup to start the warm-up.
Where this sits. Only the v2 single-controller path reads these switches. The v1 driver loops (grpo_train, async_grpo_train, PPO, distillation) do not. The early trainer build and the early route scan need NeMo-Gym with vLLM on separate GPUs. The warm-up needs a Megatron trainer. Dotted words have a short explanation: hover or tap them.
main
this PR
after the review's fixes (proposed)
v1 (driver loops)
no switches
unchanged
unchanged
v2 (single controller)
no switches
4 switches as NRL_* env vars, off by default
① and ② always on where they apply, no flag. ④ becomes an async_rl config key, off by default. ③ stays env vars (C2). The warm-up skips CUDA-graph runs and restores RNG state in place (C1).
# how you turn them on in this PR: driver environment, passed to every Ray actor
export NRL_EARLY_TRAINER_SUBMIT=1 # ① build the trainer earlier
export NRL_OVERLAP_ROUTE_SCAN=1 # ② scan the dataset's Gym routes earlier
export NRL_MEGATRON_TRITON_CACHE_AUTOTUNING=1 # ③ keep Triton autotune results ...
export NRL_MEGATRON_TORCH_COMPILE_JOB_ID=my-run # ③ ... and torch.compile shape profiles
export NRL_TRAINER_WARMUP=1 # ④ fake first step while setup or rollouts run# proposed in review comment C2, not in the PR:# ① and ② have no reason to be off, so they lose their flags and always run where they apply# ③ stays env vars, next to the compile cache from #4715# ④ becomes config, off by default until it has a test (C3) and works with CUDA graphs (C1)
async_rl:
trainer_warmup: {enabled: false, seqlens: null}
② Early route scan. Each dataset row names the Gym route it needs. The PR collects those names as soon as the dataset loads, e.g. {"train": {"alpha", "beta"}} in the PR's test. Once Gym is up, the coverage check only compares sets. A split whose routes only the running Gym knows (taskset rows) is still scanned at check time.
③ Compile results kept between jobs. The two variables are passed to the Megatron workers as Triton's and torch's own TRITON_CACHE_AUTOTUNING and TORCH_COMPILE_JOB_ID. The cache sync script then also publishes torch's per-rank shape profiles. They only do anything when the persistent compile cache from #4715 is on. Kernels whose autotune configs have a pre_hook are still benchmarked in every job.
④ Trainer warm-up. Each Megatron rank runs one logprob pass and one forward/backward on a fake batch. For the 1B math example the default lengths are [512, 512, 512, 512] tokens (max length 512, packing budget 4 × 512). Then it undoes what a real step would read: no optimizer step, gradients dropped, metric trackers and RNG reset. If the trainer is ready before vLLM, setup runs it right away. Otherwise the controller runs it alongside the first rollouts, and the train pump waits for it before step 1.
So what. Nothing changes unless you set a switch. Switches ① and ② only move work earlier. ③ and ④ make step 1 cheaper, but they can also stop a run before step 1:
④ with CUDA graphs on fails at startup. The fix is on page 2.
④ can also run out of memory, since it uses full-size microbatches.
③ can hang the first step if the ranks load shape profiles saved at different points of an earlier run.
The PR gives no before/after timings yet. The review asks for time to the end of step 1, with each switch on and off.
The review comments linked above are part of a pending review, so they open only for its author until the review is published.