feat(nemo-gym): create one gym actor per shard on its own node - #3371
Draft
ananthsub wants to merge 1 commit into
Draft
feat(nemo-gym): create one gym actor per shard on its own node#3371ananthsub wants to merge 1 commit into
ananthsub wants to merge 1 commit into
Conversation
A single gym actor puts every environment in the job on one node, so a run is capped by what that node can host. build_nemo_gym_actors() reads the shard plan and creates one actor per replica, each pinned by a STRICT_SPREAD placement group to a distinct node with its own complete Gym stack. Distinct nodes are what make identical per-shard port ranges safe, so no port-offset machinery is needed. Actors are spun up concurrently, so startup costs roughly the slowest shard rather than the sum. Config faults surface inside _spinup rather than at health-check time -- a server ref pointing outside its shard's slice raises there -- so each spinup is awaited individually and the shard name is added to the error, which Gym cannot do since it has no concept of a shard. Startup then asks one replica per shard what it spawned and checks the names: an agent in two shards is always an error because rows naming it would have no single destination, and any other duplicate must be allowlisted, since a shared YAML dropped into two path lists quietly doubles a judge's GPU claim. Failure at any of these points tears down the actors already created and releases the bundles. A ray.get timeout does not cancel the actor-side work, so a half-started stack would otherwise keep running with nothing left to stop it. Unsharded configs keep the old path exactly: one actor, no placement group, and no discovery, whose cross-shard checks would have nothing to compare. Entrypoints that dispatch to a single handle now reject sharded configs outright until the rollout router lands. Signed-off-by: Ananth Subramaniam <ansubramania@nvidia.com>
|
Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually. Contributors can view more details about this message here. |
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 ?
Builds the actors. Given the shard plan parsed in PR 3 of this stack, this PR creates one
NemoGymactor per shard instance, each on its own node, each holding a complete and self-contained Gym stack.build_nemo_gym_actors(...)innemo_rl/environments/nemo_gym.py:replicas: 3becomes three actors. The total instance count is the sum ofreplicasacross shards.STRICT_SPREADbundle per instance and wait for it to be ready.STRICT_SPREADis what makes each actor land on a distinct node, which is the point of sharding — without it the shards would share a node's CPUs and RAM and nothing would be isolated. If the allocation has fewer eligible nodes than instances, this fails here, before any actor is created, with a message naming the shortfall._spinupon all of them at once so wall-clock time is roughly the slowest shard rather than their sum. Config faults surface inside the actor — a server reference pointing at an entry that is not in this shard's slice raises Gym'sServerRefNotFoundErrorthere. Gym names the entry and field but has no concept of a shard, so the shard and replica are attached here.list_entries(), build the agent-to-shard map, and reject any entry name hosted by more than one shard unless it is inallowed_duplicate_entries. That check is what catches a judge model accidentally defined in two shards, which would claim its GPUs twice.Any failure or timeout tears down every handle and removes the placement group. This matters more than it looks:
ray.get(..., timeout=)does not cancel the actor-side work it stopped waiting for, so without an explicit teardown a half-started stack keeps running with nothing left to stop it.NemoGymShardSetholds the resulting handles keyed by shard name, the placement group, and the agent-to-shard map, and owns teardown of all three.The unsharded path is preserved: with no
shardskey the plan is a single implicit shard with one replica, andspinup_nemo_gym_actorreturns that one handle as before.Issues
None.
Usage
No user-facing change yet — nothing calls
build_nemo_gym_actorsuntil PR 7 of the stack.Before your PR is "Ready for review"
Pre checks:
Additional Information
port_range_low/port_range_highper shard (PR 3) exists for that case.