Skip to content

perf: pool IsolatedWorkerInitializer per node instead of per worker - #2739

Merged
yfw merged 1 commit into
NVIDIA-NeMo:mainfrom
ananthsub:ananthsub/pool-initializers
Jun 9, 2026
Merged

yfw merged 1 commit into
NVIDIA-NeMo:mainfrom
ananthsub:ananthsub/pool-initializers

Conversation

@ananthsub

Copy link
Copy Markdown
Contributor

What does this PR do ?

Create one IsolatedWorkerInitializer actor per unique placement-group index (node) instead of one per worker. All workers on a node share a py_executable, so the initializer only needs that in its runtime_env; per-worker env_vars are passed through create_worker().

This reduces GCS actor registrations from N_workers to N_nodes (|num_gpus/node| reduction for Megatron, |TP size| for vLLM), cutting RPC traffic to Ray's single-threaded GCS so large-scale runs don't overload it.

Cleanup is simplified: pooled initializers are killed after workers in shutdown, and the per-worker _RAY_INITIALIZER_ACTOR_REF_TO_AVOID_GC attribute is no longer needed.

Issues

List issues that this PR closes (syntax):

Usage

  • You can potentially add a usage example below
# Add a code snippet demonstrating how to use this

Before your PR is "Ready for review"

Pre checks:

  • Make sure you read and followed Contributor guidelines
  • Did you write any new necessary tests?
  • Did you run the unit tests and functional tests locally? Visit our Testing Guide for how to run tests
  • Did you add or update any necessary documentation? Visit our Document Development Guide for how to write, build and test the docs.

Additional Information

  • ...

@ananthsub
ananthsub requested review from a team as code owners June 8, 2026 16:40
@copy-pr-bot

copy-pr-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

Auto-sync is disabled for ready for review pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@ananthsub
ananthsub requested review from macandro96 and yfw June 8, 2026 16:41
@ananthsub
ananthsub force-pushed the ananthsub/pool-initializers branch from 0b31bc4 to 868f9f0 Compare June 8, 2026 16:52
@ananthsub
ananthsub requested a review from a team as a code owner June 8, 2026 16:52
@ananthsub

Copy link
Copy Markdown
Contributor Author

/ok to test 868f9f0

@ananthsub ananthsub added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Jun 8, 2026
@ananthsub

Copy link
Copy Markdown
Contributor Author

/ok to test 868f9f0

Create one IsolatedWorkerInitializer actor per unique placement-group
index (node) instead of one per worker. All workers on a node share a
py_executable, so the initializer only needs that in its runtime_env;
per-worker env_vars are passed through create_worker().

This reduces GCS actor registrations from N_workers to N_nodes
(|num_gpus/node| reduction for Megatron/Gym, |TP size| for vLLM),
cutting RPC traffic to Ray's single-threaded GCS so large-scale runs
don't overload it.

Cleanup is simplified: pooled initializers are killed after workers in
shutdown, and the per-worker _RAY_INITIALIZER_ACTOR_REF_TO_AVOID_GC
attribute is no longer needed.

Because pooled init means multiple workers on a node apply the vLLM
file patches concurrently, serialize those patches with an
fcntl.flock-based _locked_file_patch() context manager so one worker's
truncating open() can't race another worker's read.

Ported from nemo-rl-internal!197 and !208; validated with 1K-GPU runs.

Signed-off-by: Ananth Subramaniam <[email protected]>
@ananthsub
ananthsub force-pushed the ananthsub/pool-initializers branch from 868f9f0 to 1bf5a74 Compare June 8, 2026 17:48
@copy-pr-bot

copy-pr-bot Bot commented Jun 8, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@ananthsub

Copy link
Copy Markdown
Contributor Author

/ok to test 1bf5a74

yfw added a commit that referenced this pull request Jun 8, 2026
- setup() returns an 11-tuple (the NeMo-Gym actor is at index 2). Update the
  three non-gym callers (run_grpo, run_grpo_sliding_puzzle, run_vlm_grpo) to
  unpack the extra element so they don't fail with a ValueError, and fix the
  setup() docstring, which listed a stale tuple.
- Drop the dead ray_namespace / ray_num_gpus_per_node gym config fields: the
  pinned Gym (9b52dc8) has zero references to them, so they were set into the
  gym global config but silently ignored. Keep ray_head_node_address, which the
  Gym does consume.

The _apply_vllm_patches() non-owner write race is handled separately by #2739,
which lands before this PR.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Signed-off-by: Yi-Fu Wu <[email protected]>
yfw added a commit that referenced this pull request Jun 9, 2026
- setup() returns an 11-tuple (the NeMo-Gym actor is at index 2). Update the
  three non-gym callers (run_grpo, run_grpo_sliding_puzzle, run_vlm_grpo) to
  unpack the extra element so they don't fail with a ValueError, and fix the
  setup() docstring, which listed a stale tuple.
- Drop the dead ray_namespace / ray_num_gpus_per_node gym config fields: the
  pinned Gym (9b52dc8) has zero references to them, so they were set into the
  gym global config but silently ignored. Keep ray_head_node_address, which the
  Gym does consume.

The _apply_vllm_patches() non-owner write race is handled separately by #2739,
which lands before this PR.

Signed-off-by: Yi-Fu Wu <[email protected]>
@yfw
yfw merged commit d9ba460 into NVIDIA-NeMo:main Jun 9, 2026
74 checks passed
@ananthsub
ananthsub deleted the ananthsub/pool-initializers branch June 9, 2026 09:28
pengdurice pushed a commit to pengdurice/RL that referenced this pull request Jun 12, 2026

This branch was previously deployed

2 inactive deployments
public — 1bf5a74c Deployed Jun 8, 2026 by copy-pr-bot[bot] via release / finalize / publish-docs #801
test — 1bf5a74c Deployed Jun 8, 2026 by copy-pr-bot[bot] via Wait in test approval queue #12069
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants