Skip to content

fix(megatron): lift Ray's 1000-call cap on the Megatron policy worker - #5120

Merged
terrykong merged 5 commits into
NVIDIA-NeMo:mainfrom
wdykas:fix/megatron-worker-max-concurrency
Nov 17, 2026
Merged

terrykong merged 5 commits into
NVIDIA-NeMo:mainfrom
wdykas:fix/megatron-worker-max-concurrency

Conversation

@wdykas

@wdykas wdykas commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

What changes

Raise MegatronPolicyWorker's Ray actor concurrency to 2**16. Each rollout sample submits a suspended generate_async call to rank 0; Ray's default 1,000-call async-actor limit can otherwise cap admitted samples and prevent control calls such as finish_generation from running while those samples wait.

The MCore engine continues to enforce its own active-request capacity. This changes async coroutine admission, not the number of training threads or GPU request slots.

The regression test waits until all 1,500 generation calls have entered before checking that the control call completes. Its worker import is deferred until execution so Automodel and other non-MCore lanes can collect the module without optional Bridge dependencies.

Validation

  • CPU Ray protocol harness using the production decorator options and the regression test body: 1,500 admitted requests and control-call completion passed.
  • Negative control restoring the original 1,000-call limit: admission barrier times out as expected.
  • Test module collects without Megatron/Bridge installed.
  • Ruff lint/format, isort, and git diff --check passed.
  • Full MCore import/integration coverage is requested through CI:Lfast; no model forward pass was run locally.

Every rollout sample is one generate_async call on rank 0 of
MegatronPolicyWorker, which set no max_concurrency, so Ray's async-actor
default of 1000 applied. Calls past it wait in Ray's FIFO: the engine never
holds more than 1000 rows, however large its max_requests, and a control
call such as finish_generation (rank 0 sends the engine pause) waits until
earlier rows finish.

Set max_concurrency=2**16 so the engine, which queues requests past its own
capacity, is the only admission limit.

Signed-off-by: wdykas <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 7, 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.

@wdykas
wdykas marked this pull request as ready for review November 7, 2026 16:55
@wdykas

wdykas commented Nov 7, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 5c96b38

@svcnvidia-nemo-ci svcnvidia-nemo-ci left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One [BUG] finding needs correction before merging: C1 identifies a test-collection failure in non-MCore environments.

I inspected both changed files and their affected worker-creation, generation-control, and test-lane paths. Two child report bodies weren't delivered, so I covered those topics directly; the test-topic report was available for consolidation.

Validation was static only. I couldn't run pytest, Ray experiments, lint, or CI checks in this read-only environment.

Note: formal approval is not available for this request, so this review is posted as a comment only.

Review generated by codex. This was a full review. Request a full review with /review reset=true.

@wdykas wdykas added the CI:L0 Run doctests and unit tests label Nov 16, 2026
@wdykas

wdykas commented Nov 16, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 21c929a

@terrykong terrykong left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this fix. Megatron generation sends each rollout sample to rank 0 as its own generate_async call, so Ray's async default of 1,000 calls really does cap in-flight rows; the largest shipped async Megatron-generation recipes can reach about 2,560. The test reads the real decorator option instead of copying the number, so the two can't drift apart. A CPU-only copy of the test on Ray 2.58.0 (the pinned version) passes with 2**16 and times out with the default.

  1. (C1) Two comments in other files now wrongly say this worker has no max_concurrency; please reword them.

Checked and fine: the option reaches the real actor through RayWorkerBuilder. MegatronQuantPolicyWorker and SFTMegatronPolicyWorker don't need it: the quant worker rejects Megatron generation, and the SFT worker never generates. The bot's eager-import comment is fixed in 21c929a.

Generated by Claude Code

@wdykas wdykas added CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) and removed CI:L0 Run doctests and unit tests labels Nov 17, 2026
@wdykas

wdykas commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 27beb9b

@terrykong
terrykong enabled auto-merge (squash) November 17, 2026 15:21
@wdykas

wdykas commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

/ok to test 28f0258

@terrykong
terrykong merged commit a22b886 into NVIDIA-NeMo:main Nov 17, 2026
95 checks passed
jthomson04 added a commit to jthomson04/RL that referenced this pull request Nov 17, 2026
…ym rollout) into jthomson04/dynamo-1.7

Brings in NVIDIA-NeMo#4979's merge of main 89329fc (NVIDIA-NeMo#5030, NVIDIA-NeMo#5120, NVIDIA-NeMo#5007, NVIDIA-NeMo#5187, NVIDIA-NeMo#5265). Git merged the five files both sides changed without a conflict: the Dynamo guide, nemo_gym.py and three test files. pyproject.toml, uv.lock and the submodule pins are unchanged.

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Signed-off-by: jthomson04 <[email protected]>
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.

3 participants