Repository navigation
feat: Overlap external vLLM and NeMo RL startup - #4381
Conversation
Upstream of #3832 from super-v3.5-posttraining. The external vLLM launcher now starts ray.sub while the external pools are still loading and injects an env.nemo_gym.external_service_readiness block. The NeMo Gym actor starts its local servers, then waits for every external load balancer to report the required healthy backend count under one shared deadline before it exposes rollout collection. Adapted to main: - The readiness block is extracted in _build_gym_actor_config, which every entrypoint (run_grpo.py, distillation, and the SingleController path in run_grpo_single_controller.py) reaches through build_nemo_gym_actors. The distillation.py call-site hunk is therefore unnecessary and dropped. - external_service_readiness is registered in NEMO_RL_DICT_CONFIG_KEYS so sharded Gym treats it as a NeMo RL setting rather than an unclaimed Gym server overlay, and every shard receives it. - The timeout cleanup clears self.rh before calling RunHelper.shutdown(), matching NemoGym.shutdown(), since the caller's teardown calls shutdown() again and RunHelper.shutdown() is not idempotent. (cherry picked from commit d96ae88) Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test 4b80f15 |
1 similar comment
|
/ok to test 4b80f15 |
yfw
left a comment
There was a problem hiding this comment.
The overlap is a clean port of #3832: the launcher's override round-trips through ray.sub and Hydra into ExternalServiceReadinessConfig, every entrypoint strips the block before it reaches Gym, sharded configs propagate it, and the teardown paths hold.
Inline: one timeout-diagnostics fix (source plus a paired test edit), an optional test for the _spinup gate wiring, and two out-of-date guides.
Generated by Claude Code
- _wait_for_external_services raises right after its final sleep instead of starting a round at the deadline. That round could not probe and overwrote every observation with "startup deadline expired before probe", hiding the real cause (connection refused, a backend short). - The timeout test now lets sleep drive the clock, so its last sleep ends at the deadline, as it does in a real run. It fails on the old loop. - New test runs NemoGym._spinup with the readiness gate set and pins the order: RunHelper.start, the wait, then RunHelper.shutdown with self.rh cleared first. - Both Nemotron 3 Ultra guides now describe the overlapped startup. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
/ok to test d61fd40 |
terrykong
left a comment
There was a problem hiding this comment.
The overlap is a clean change. The gate is set up in the one place every Gym entrypoint goes through (nemo_gym.py#L1793), sharded configs carry it to every shard (nemo_gym_shards.py#L40-L41), and the launcher still stops the job if a pool dies (run_in_allocation.sh#L671). Thanks for applying all four self-review fixes.
Three inline comments, all low severity: make the launcher's readiness override work no matter how COMMAND ends, say in the probe's docstring which /health it expects, and add a test that ties the probe to the load balancer's real reply.
Two asks not tied to a line:
- The description says this hasn't run end to end with external pools on
mainyet. Could you share one run with the Ultra or Lightning launcher that reaches the first rollout step, plus its time to first step compared with the old wait-then-start order? That number is the point of the PR. - Please file the follow-up for the 1800s sharded-spinup limit you listed under "Known limitation", and link it here.
Generated by Claude Code
Appending the external_service_readiness override to COMMAND bound it to whatever ended the command: with a trailing `| tee log`, `; echo done`, or `# comment` the gate was silently dropped and rollouts could start against pools that were still loading. - run_in_allocation.sh substitutes __EXTERNAL_SERVICE_READINESS__, the same way it substitutes pool URLs, and refuses to start without it. - validate_external_vllm_submission rejects a command without the token. - The Ultra and Lightning launchers add the token to TRAIN_CMD only when external pools are configured, so ray.sub-only runs never see it. - The probe docstrings state that the URL must be a vllm_pool_lb /health endpoint; a plain vLLM /health never reads as ready. - New test feeds LoadBalancer.handle_health's real reply into _probe_external_service, so a field rename on either side fails CI. Co-Authored-By: Claude Opus 5.5 <[email protected]> Signed-off-by: Yi-Fu Wu <[email protected]>
|
Thanks @terrykong. All three inline comments are addressed in e25db89. Answers to the two other asks: Follow-up for the sharded spinup limit: #4565. Before/after startup. Both runs used the Lightning 3.5 launcher with the same topology: 26 NeMo RL nodes plus 6 external nodes (GenRM 2× TP=8, NL2Bash 2× TP=4). Both were 2-step runs and completed both steps.
Elapsed from Slurm allocation start:
There's no wall-clock stamp on the start of step 1 itself. Setup completion and run end both come out about 8 minutes earlier, and the step times match, so time to first step drops by about the same 8 minutes. Setup completion is bracketed from vLLM log timestamps, so it's only accurate to about a minute. In the overlap run the Gym actor logged Caveats:
|
|
Additional startup A/B measurements using this PR's main-branch base ( Both arms used the same recipe, dependencies, container, and resource topology, with policy MTP disabled in both. Elapsed from Slurm allocation start, excluding queue time:
Allocation-to-setup time decreased by approximately 7m20s (31%). The logs confirm that the overlap arm starts Ray while external judge pools are loading, rather than waiting for them first. Driver-side RL initialization was similar: 517.4s before versus 534.7s with overlap; the improvement comes from overlapping the pre-driver startup work. The setup-completion estimates combine the timestamped driver launch, logged Python/import startup time, and |
|
/ok to test 4e73fad |
What does this PR do ?
Upstreams #3832 from
super-v3.5-posttraining: overlap external vLLM model loading with NeMo RL startup, gated by a readiness check in the NeMo Gym actor. Works on all Gym entrypoints, including the SingleController path (examples/run_grpo_single_controller.py).Previously
tools/external_gym_vllm/run_in_allocation.shwaited for every external vLLM pool to become healthy before startingray.sub. Now it:ray.subon hetgroup 0 while the external pools are still loading;__EXTERNAL_SERVICE_READINESS__token inCOMMANDwith++env.nemo_gym.external_service_readiness=..., carrying each pool's load-balancer/healthURL and its replica count; andray.subduring startup.The NeMo Gym actor starts its local Gym servers, then polls every external load balancer until
/healthreportsstatus: okandhealthy_backends/total_backendsat or above the replica count. All pools share one deadline. On timeout the actor stops its local servers and raises. Ray, policy/trainer, and local Gym initialization now overlap with external model loading, and rollout collection still can't start early.Adapted to main
_build_gym_actor_config.run_grpo.py, distillation, and the SingleController path all reach it throughbuild_nemo_gym_actors. The source PR'sdistillation.pycall-site change is therefore unnecessary and dropped. On the SC path, Gym spinup already runs in its ownThreadPoolExecutortask next to generation and trainer init, so the readiness wait blocks only that task.external_service_readinessis added toNEMO_RL_DICT_CONFIG_KEYS. Otherwisefind_gym_config_entriestreats this dict-valued key as a Gym server overlay. A multi-shard plan then rejects it ("have no owner"), and a single-shard plan passes it through to Gym silently. With the fix, every shard gets the block.self.rhbefore callingRunHelper.shutdown(), the same wayNemoGym.shutdown()does. The caller's teardown callsshutdown()again, andRunHelper.shutdown()is not idempotent.Issues
N/A (upstream of #3832)
Usage
COMMANDmust include__EXTERNAL_SERVICE_READINESS__among the training script's arguments.run_in_allocation.shandvalidate_external_vllm_submissionrefuse to start without it, and the Ultra and Lightning launchers add it when external pools are configured. The wrapper replaces the token with the block below. To set it by hand:New launcher knobs:
EXTERNAL_VLLM_READINESS_POLL_INTERVAL_SECONDS(default5) andEXTERNAL_VLLM_READINESS_REQUEST_TIMEOUT_SECONDS(default10).Before your PR is "Ready for review"
Pre checks:
Additional Information
Testing
test_nemo_gym.py,test_nemo_gym_utils.py,test_nemo_gym_shards.py,test_external_gym_vllm.py, andsingle_controller/test_setup.py(-m "not nemo_gym"; the 3 tests that need thenemo_gymextra were not run locally).main. Thesuper-v3.5-posttrainingbefore/after runs from feat: Overlap external vLLM and NeMo RL startup #3832 are summarized in the PR comments: about 8 minutes less from allocation to setup complete and to the end of a 2-step run.Known limitation (pre-existing, not changed here). Sharded Gym spinup has a fixed 1800s budget (
DEFAULT_SHARD_SPINUP_TIMEOUT_SECONDS) that no caller can override. The readiness deadline is the largest poolPOOL_STARTUP_TIMEOUT(default 3600s). With sharded Gym and an external pool that takes more than 30 min to load, shard spinup fails before the readiness deadline. Unsharded Gym has no such cap. The shard timeout error also suggestsenv.nemo_gym.spinup_timeout, which isn't wired to anything yet. Tracked in #4565.🤖 Generated with Claude Code