Repository navigation
fix(nemo-gym): read env.nemo_gym.spinup_timeout for sharded startup - #4751
Open
Thanatos9404 wants to merge 3 commits into
Open
Thanatos9404 wants to merge 3 commits into
Thanatos9404 wants to merge 3 commits into
Conversation
Sharded NeMo Gym startup had a fixed 1800s budget. The timeout error told users to raise env.nemo_gym.spinup_timeout, but nothing read that key, and no caller passed build_nemo_gym_actors' spinup_timeout argument. A job whose external vLLM pools took longer than 30 minutes to load (the pool startup timeout defaults to 3600s) failed with ShardSetupError while the external_service_readiness gate would still have waited. spinup_timeout is now a sharding setting like placement_strategy: parse_shard_plan reads it onto ShardPlan (default 1800s, null reads as unset), rejects a value that is not a positive, finite number of seconds, and SHARDING_CONFIG_KEYS keeps it out of the config every actor sends to Gym. As with the other sharding keys, setting it without a shards block is an error. The unused keyword argument is removed. Setup also rejects a budget shorter than any shard's external_service_readiness.timeout_seconds, before any bundle is placed, and a sharding key set inside common_overrides or a shard's overrides, where it used to be merged in and then silently dropped. A _spinup that runs out of the budget now says so and points at the setting, and a TimeoutError raised inside _spinup (such as the readiness gate giving up) is reported as a timeout. Both used to get the message for a missing config_paths entry. Fixes NVIDIA-NeMo#4565 Signed-off-by: Yashvardhan Thanvi <yashvt9404@gmail.com>
Signed-off-by: Yashvardhan Thanvi <yashvt9404@gmail.com>
The contributing references on main now ask for no comment blocks of three or more lines inside function bodies. Signed-off-by: Yashvardhan Thanvi <yashvt9404@gmail.com>
This branch has not been deployed
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.
What does this PR do ?
Make
env.nemo_gym.spinup_timeoutset the sharded NeMo Gym startup budget, and reject at setup a budget shorter thanexternal_service_readiness.timeout_seconds.Issues
Fixes #4565
Usage
or
++env.nemo_gym.spinup_timeout=4200on the command line.Change
spinup_timeoutis now a sharding setting handled likeplacement_strategy.parse_shard_planreads it ontoShardPlan(defaultDEFAULT_SHARD_SPINUP_TIMEOUT_SECONDS, 1800s, moved intonemo_gym_shards.py; a null reads as unset), andSHARDING_CONFIG_KEYSkeeps it out of the config every actor sends to Gym._build_sharded_gym_actorsusesplan.spinup_timeout, and the unusedspinup_timeoutkeyword argument ofbuild_nemo_gym_actorsis removed.0, negative,inf,nan, a bool or a string) raisesShardConfigError, the same checkactor_cpusgets.shardsblock raisesShardConfigError.external_service_readiness, setup raisesShardConfigErrorifspinup_timeoutis shorter than itstimeout_seconds. This runs per shard after the overlays are applied, before any bundle is placed, so a shard that overrides the readiness block is checked against its own deadline. The message names the shard and the minimum, and points at Gym'sserver_spinup_timeout_secondsfor the server startup that comes first.common_overridesand a shard'soverridescan no longer set a sharding key. Those layers are merged into a shard's Gym config, from which the sharding keys are dropped, so aspinup_timeout(orplacement_strategy) set there was silently ignored.ray.geton_spinupruns out of budget (GetTimeoutError), theShardSetupErrorsays so and points atenv.nemo_gym.spinup_timeout. ATimeoutErrorraised inside_spinup, such as the readiness gate giving up, arrives as aRayTaskErrorand is now reported as "timed out while starting", with the original message. Both used to get the config-fault message ("A reference to an entry that is not in this shard's config_paths is the usual cause"). Gym's own server-startup timeout raisesRuntimeError, so it still gets that generic message, which carries Gym's hint aboutserver_spinup_timeout_seconds.docs/design-docs/nemo-gym-integration.md, and a note intools/external_gym_vllm/README.mdthat a sharded job should pass++env.nemo_gym.spinup_timeoutlarger than the pool startup timeout.The readiness check compares against
timeout_secondsalone. The budget also covers the shard's Gym server startup before the readiness wait and the tokenizer install after it, so the docs and the error message ask for extra time on top.Tests
tests/unit/environments/test_nemo_gym_shards.py:test_spinup_timeout_is_read_into_the_plan[default|null|configured]test_an_invalid_spinup_timeout_is_rejected:0,-1,inf,nan,True,"7200".test_unsharded_config_rejects_stray_sharding_keys[spinup_timeout]test_override_layers_cannot_set_sharding_keys[common|shard]tests/unit/environments/test_nemo_gym_utils.py:test_sharded_spinup_uses_the_configured_spinup_timeout[default|configured]: each_spinupwait gets 1800s by default and 7200s when configured, and no actor's Gym config contains the key.test_spinup_timeout_without_shards_is_rejected[actors|config]: throughbuild_nemo_gym_actorsandbuild_nemo_gym_config.test_a_spinup_timeout_shorter_than_external_readiness_fails_at_setup[default-budget|configured-budget|shard-override]andtest_a_spinup_timeout_that_covers_external_readiness_starts_the_shards.test_a_shard_out_of_startup_budget_points_at_spinup_timeoutandtest_a_timeout_inside_spinup_is_reported_as_a_timeout.GetTimeoutErrorfor timed-outray.getcalls, as Ray does, so the drained and wedged startup tests now match the startup-budget message instead of only "failed to start".test_tokenizer_timeout_reports_exhausted_shared_startup_budgetsets its 1s budget through the config.With
nemo_gym.pyandnemo_gym_shards.pyreverted tomain, 23 of these fail (11 intest_nemo_gym_utils.py, 12 intest_nemo_gym_shards.py). The rest pin behavior that does not change, such as the default budget. With the change, both files pass in full.Commands and results (WSL, CPU only, Python 3.13, Ray 2.59.0; not the CI container)
Compatibility
spinup_timeoutkeep the 1800s budget.timeout_secondsis abovespinup_timeout(1800s by default) now fail at setup, including jobs whose pools would have come up in time. With the external vLLM launcher's default pool timeout of 3600s, every sharded job that uses the launcher has to setspinup_timeout. The issue called this check optional; if you'd rather have a warning than an error here, I can change it.examples/nemo_gym/grpo_sharded_gym_smoke.yaml, has no readiness gate, and the recipes that userun_in_allocation.share unsharded.spinup_timeoutin an unsharded config is now an error; the key was never read before. Setting any sharding key (for exampleplacement_strategy) insidecommon_overridesor a shard'soverridesis now an error too; it was silently ignored before.build_nemo_gym_actors(..., spinup_timeout=...)is no longer accepted. No caller in the repo passed it.external_service_readinessblock in a sharded job now fails before the placement group is created, with the same pydanticValidationError, instead of during actor creation.Before your PR is "Ready for review"
Pre checks:
Additional Information
CI:L0(bug fix).++env.nemo_gym.spinup_timeoutitself, but it does not know whether the job is sharded, and setting the key on an unsharded job is now an error; it would also have to stay below a user's own override inCOMMAND. So this PR documents the override instead.env.nemo_gym.spinup_timeout(norexternal_service_readiness), so raising it on a restart rejects the bootstrap anchor unless the key is listed inrollout_checkpointing.extra_fingerprint_excluded_paths. Adding it to the built-in list would invalidate existing anchors, so I left it for a separate change.