Repository navigation
perf(sc): opt-in switches that shorten startup and the first training step - #5001
Conversation
|
@terrykong Hey I just wanted to mention that this PR depends on #4715 . Note in original PR, although wanted to flag it so it doesn't cause confusion later on. |
673d61e to
6e2c566
Compare
6e2c566 to
5223071
Compare
|
#4715 has merged, so this PR is now a single commit.
|
Connor-XY
left a comment
There was a problem hiding this comment.
Read through this with an eye on the compile-cache parts, since we've been doing similar persistent-cache work on the Megatron side for pretraining and SFT startup.
The startup switches look reasonable to me, and keeping everything opt-in with only the two refactors on by default makes this easy to take. Most of my comments are about NRL_MEGATRON_TORCH_COMPILE_JOB_ID.
-
Shape profiles break the cache's "published files never change" rule, and that's what causes the first-step hang in the docs. The sidecar pushes each rank's
code_state_*.pklwithrsync --updateevery 60 s, per node and per file. The next job can start with rank 0's profile from minute 5 and rank 7's from minute 40. Those ranks then make different static/dynamic decisions, compile different graphs, and the collectives stop lining up. I don't think "unset the job id if it hangs" is enough here. Could the profiles be published once, as a full set, after the job has finished at least one good step (or only on the final write-back pass), into a directory named for that job? Then a later job either gets all ranks from the same point or none. -
The job id is the only cache key. If someone keeps the same id but changes TP/PP/EP, world size, or the container, ranks will load profiles recorded for a different layout without any warning. Could the key be derived from (or at least checked against) the parallel config, world size and image? I'd make the user-supplied id an extra suffix on top of that.
-
Autotune caching won't help Mamba-hybrid models much. As the comment in
compile_cache.pysays, Triton skips the disk cache for any kernel whose configs have apre_hook. Themamba_ssmSSD kernels useinit_to_zeropre_hooks, so on hybrid models (Nemotron-H/NT-style) most of the autotune time comes back every job. It's fine to land the passthrough as is, but please say this in the docs so nobody expects a big step-1 drop on those models. We patched around this on our side and can share notes if useful. -
Determinism. The pre_hook kernels are still timed per process, so ranks can pick different configs within a run. That's the same mechanism we traced a cross-run determinism break to at 24+ nodes. Cached kernels now take their config from whichever node published first, so a run's numerics depend on the cache's history. That's probably fine for RL, but it's worth one line in the docs. It should also be skipped or warned about when deterministic mode is on.
-
Warm-up and shape profiles together. The synthetic warm-up seqlens get recorded into the dynamo profile too, which can mark dims dynamic or cause recompiles on the first real shapes. Has the combination of
NRL_TRAINER_WARMUP=1and the compile job id been run?
Smaller things are inline. Also the "ran unit/functional tests" box is still unchecked. Do you have a before/after on time-to-end-of-step-1 for each switch? That would make it easier to decide which ones are worth turning on by default later.
terrykong
left a comment
There was a problem hiding this comment.
Thanks for the docs table and for making each switch skip itself safely where it does not apply.
- (C1) With the warm-up and Megatron CUDA graphs on, the RNG save crashes before step 1. Once that is fixed, the warm-up would capture CUDA graphs on synthetic shapes. Skip the warm-up when CUDA graphs are on, restore the RNG states in place, and add a test.
- (C2) Remove the flags for the early route scan and the early trainer build, and always do both where they apply. Make the warm-up an
async_rl.trainer_warmupconfig key, off by default. - (C3) Turn the warm-up on in the fast L1 run of
grpo_async_gym_single_controller.sh, and fail the test if the warm-up was skipped. - (C8) Replace
_EarlyTrainerWarmupwith a wait in setup. Decide once whether the warm-up runs, and keep one copy of the step's field list.
The replies on Connor's threads (C4–C7) add to his points. +1 to his ask for before/after time to the end of step 1 for each switch.
Explainers: what the switches change · warm-up crash with CUDA graphs · warm-up without a callback
Generated by Claude Code
5223071 to
a5e6469
Compare
|
a5e6469 committed with changes for @Connor-XY feedback. Not yet resolved @terrykong points yet.
The sidecar no longer publishes shape profiles. The trainer saves every rank's profile as one set, in a folder named for the job and step, after steps 1, 2, 4, 8, … when a profile changed and the step succeeded on every rank. Rank 0 writes the set's manifest last and sets without one are never read, so a later job loads all ranks from one set or none. The "unset the job id" advice is gone from the docs.
Sets are stored under the job id, the user and a hash of the model, TP/PP/CP/SP/EP/ETP, first/last pipeline stage sizes, world size and torch version, so reusing an id after any of those change starts without a profile. The image isn't in the hash: torch matches each profile entry to its code by a hash of the source file, so entries recorded against other code aren't applied.
Triton still benchmarks kernels whose autotune configs carry a
A kernel runs the config of whichever job tuned it first, which a job without the cache may not pick. The trainer warns about this when cached autotuning is on with
Not on GPUs at this commit. The warm-up never saves a set: the first one is saved after step 1, so it holds the real shapes as well as the warm-up's, and a later job compiles any dim that varied across them as dynamic from the start. The default warm-up packs two microbatches of different sizes, so torch.compile meets its second shape there rather than in step 1. |
a5e6469 to
1d8741f
Compare
|
/ok to test 1d8741f |
960af81 to
dc19a26
Compare
|
/ok to test dc19a26 |
1 similar comment
|
/ok to test dc19a26 |
Signed-off-by: sarichardson <[email protected]>
Head branch was pushed to by a user without write access
dc19a26 to
47785ee
Compare
|
47785ee is dc19a26 rebased onto current main, plus a test fix for the Megatron policy unit tests. |
|
/ok to test 47785ee |
…ting Resolve one conflict with NVIDIA-NeMo#5001 in validate_dataset_agent_coverage: keep main's precomputed agent names and pass multi_harness when a split is scanned here. Taskset rows are always scanned here, since main's precomputed scan skips them. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Zeyu Zhou <[email protected]>
What does this PR do ?
Shortens single-controller startup and the first training step: two opt-in config keys, cached Megatron autotuning, and an early route scan that is always on.
async_rl.early_trainer_build: true, off by default): builds the trainer while setup creates the vLLM workers, not after. Needs NeMo-Gym, non-colocated vLLM, no resume andcluster.segment_size; otherwise setup warns and ignores it.NRL_MEGATRON_TRITON_CACHE_AUTOTUNING=1,NRL_MEGATRON_TORCH_COMPILE_JOB_ID=<id>): keeps Triton autotune results and torch.compile shape profiles in the perf: Dblanaru/persistent compile caches #4715 Megatron compile cache, so later jobs skip the autotuning and the fixed-shape compiles. Needs the same id in every run and the Megatron inductor and Triton caches under${NRL_LOCAL_COMPILE_CACHE}/megatron; kernels with an autotunepre_hookare still benchmarked in every process.async_rl.trainer_warmup.enabled: true, off by default; optionalasync_rl.trainer_warmup.seqlens): each Megatron rank runs one logprob pass and one forward/backward on a synthetic batch while generation starts or the first rollouts run, then resets the state a real step reads. The optimizer step is not warmed; unsupported setups, listed indocs/guides/single-controller.md, skip it and log why.Other
_apply_vllm_generation_config, andClippedPGLossFnis built before the setup tasks.Issues
Builds on #4715 (merged).
Usage
The early trainer build and the warm-up are config keys, both off by default:
The compile-cache settings stay environment variables, next to the rest of the #4715 compile cache. Set them in the driver's environment before launching:
Before your PR is "Ready for review"
Pre checks: