Skip to content

fix(grpo): accept grpo.max_num_epochs: null as "no epoch limit" - #4975

Merged
yuki-97 merged 1 commit into
NVIDIA-NeMo:mainfrom
mikhailshilkov:mshilkov/grpo-null-max-num-epochs
Oct 29, 2026
Merged

yuki-97 merged 1 commit into
NVIDIA-NeMo:mainfrom
mikhailshilkov:mshilkov/grpo-null-max-num-epochs

Conversation

@mikhailshilkov

Copy link
Copy Markdown
Contributor

What does this PR do ?

Lets grpo.max_num_epochs be null, meaning "train until max_num_steps, cycling the dataset as needed", in every GRPO trainer.

The single controller (single_controller.py, _clamp_max_num_steps, the epoch check in single_controller_utils/config.py) and async_grpo_train already treat None that way. But GRPOConfig declares max_num_epochs: int = 1, so a config that uses null fails validation before any of that code runs. This PR:

  • types the field int | None (the default stays 1);
  • makes the sync trainers (grpo_train, grpo_train_sync) and the Megatron train_iters computation in grpo.setup honor None. Without this they would raise TypeError on current_epoch < None and None * train_sample_count.

Issues

None filed.

Usage

grpo:
  max_num_epochs: null   # no epoch limit; max_num_steps bounds the run
  max_num_steps: 500

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

  • New test test_grpo_train_without_epoch_limit_cycles_until_max_num_steps: with max_num_epochs=None and a one-batch dataloader, grpo_train runs exactly max_num_steps (3) steps. It fails without the fix; all of tests/unit/algorithms/test_grpo.py passes with it (486 tests).
  • The epoch banner prints Epoch N/None when there is no limit. This is cosmetic and left as is.

The single controller and async_grpo_train already treat a null max_num_epochs as training until max_num_steps, but GRPOConfig rejected null. Type the field int | None and honor None in the sync trainers and the Megatron train_iters computation.

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

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

@yuki-97 yuki-97 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.

LGTM, thanks @mikhailshilkov for adding this!

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

yuki-97 commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

/ok to test 883b34c

@yuki-97
yuki-97 enabled auto-merge (squash) October 29, 2026 11:17
@yuki-97
yuki-97 merged commit e9bfd9f into NVIDIA-NeMo:main Oct 29, 2026
93 checks passed
RayenTian added a commit that referenced this pull request Oct 30, 2026
…pool guidance

The functional recovery hook took replacement_index to match the signature but
dropped it when delegating, so every delegated call recorded as a first attempt
and would have falsified first_attempt_reward for anyone asserting on it there.
Inert today -- the scripts that use the hook do not enable dynamic sampling --
but wrong, and the delegate defaults the kwarg so it failed silently.

Three wording fixes in the spare-pool guidance:

- The guide stated the refill condition twice in consecutive clauses. Fold them
  into one sentence that also carries the check-frequency fact, which was the
  only new information the second clause added.
- "covers any drop rate below 50%; below that the pool can empty" read as
  "below 50% the pool can empty" -- the nearest antecedent is the percentage,
  not the mark. Say "set it lower".
- A test helper's default-argument comment still carried "anything smaller
  reaches 0 in between", the claim the previous commit retired everywhere else.

Also note grpo.max_num_epochs: null in the shorter-epoch paragraph. Accepting
null landed on main in #4975; the SingleController clamp already returned early
for it, so the paragraph's advice now has a second option.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: ruit <[email protected]>
RayenTian added a commit that referenced this pull request Nov 2, 2026
…pool guidance

The functional recovery hook took replacement_index to match the signature but
dropped it when delegating, so every delegated call recorded as a first attempt
and would have falsified first_attempt_reward for anyone asserting on it there.
Inert today -- the scripts that use the hook do not enable dynamic sampling --
but wrong, and the delegate defaults the kwarg so it failed silently.

Three wording fixes in the spare-pool guidance:

- The guide stated the refill condition twice in consecutive clauses. Fold them
  into one sentence that also carries the check-frequency fact, which was the
  only new information the second clause added.
- "covers any drop rate below 50%; below that the pool can empty" read as
  "below 50% the pool can empty" -- the nearest antecedent is the percentage,
  not the mark. Say "set it lower".
- A test helper's default-argument comment still carried "anything smaller
  reaches 0 in between", the claim the previous commit retired everywhere else.

Also note grpo.max_num_epochs: null in the shorter-epoch paragraph. Accepting
null landed on main in #4975; the SingleController clamp already returned early
for it, so the paragraph's advice now has a second option.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: ruit <[email protected]>
RayenTian added a commit that referenced this pull request Nov 3, 2026
…pool guidance

The functional recovery hook took replacement_index to match the signature but
dropped it when delegating, so every delegated call recorded as a first attempt
and would have falsified first_attempt_reward for anyone asserting on it there.
Inert today -- the scripts that use the hook do not enable dynamic sampling --
but wrong, and the delegate defaults the kwarg so it failed silently.

Three wording fixes in the spare-pool guidance:

- The guide stated the refill condition twice in consecutive clauses. Fold them
  into one sentence that also carries the check-frequency fact, which was the
  only new information the second clause added.
- "covers any drop rate below 50%; below that the pool can empty" read as
  "below 50% the pool can empty" -- the nearest antecedent is the percentage,
  not the mark. Say "set it lower".
- A test helper's default-argument comment still carried "anything smaller
  reaches 0 in between", the claim the previous commit retired everywhere else.

Also note grpo.max_num_epochs: null in the shorter-epoch paragraph. Accepting
null landed on main in #4975; the SingleController clamp already returned early
for it, so the paragraph's advice now has a second option.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: ruit <[email protected]>
RayenTian added a commit that referenced this pull request Nov 3, 2026
…pool guidance

The functional recovery hook took replacement_index to match the signature but
dropped it when delegating, so every delegated call recorded as a first attempt
and would have falsified first_attempt_reward for anyone asserting on it there.
Inert today -- the scripts that use the hook do not enable dynamic sampling --
but wrong, and the delegate defaults the kwarg so it failed silently.

Three wording fixes in the spare-pool guidance:

- The guide stated the refill condition twice in consecutive clauses. Fold them
  into one sentence that also carries the check-frequency fact, which was the
  only new information the second clause added.
- "covers any drop rate below 50%; below that the pool can empty" read as
  "below 50% the pool can empty" -- the nearest antecedent is the percentage,
  not the mark. Say "set it lower".
- A test helper's default-argument comment still carried "anything smaller
  reaches 0 in between", the claim the previous commit retired everywhere else.

Also note grpo.max_num_epochs: null in the shorter-epoch paragraph. Accepting
null landed on main in #4975; the SingleController clamp already returned early
for it, so the paragraph's advice now has a second option.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: ruit <[email protected]>
RayenTian added a commit that referenced this pull request Nov 4, 2026
…pool guidance

The functional recovery hook took replacement_index to match the signature but
dropped it when delegating, so every delegated call recorded as a first attempt
and would have falsified first_attempt_reward for anyone asserting on it there.
Inert today -- the scripts that use the hook do not enable dynamic sampling --
but wrong, and the delegate defaults the kwarg so it failed silently.

Three wording fixes in the spare-pool guidance:

- The guide stated the refill condition twice in consecutive clauses. Fold them
  into one sentence that also carries the check-frequency fact, which was the
  only new information the second clause added.
- "covers any drop rate below 50%; below that the pool can empty" read as
  "below 50% the pool can empty" -- the nearest antecedent is the percentage,
  not the mark. Say "set it lower".
- A test helper's default-argument comment still carried "anything smaller
  reaches 0 in between", the claim the previous commit retired everywhere else.

Also note grpo.max_num_epochs: null in the shorter-epoch paragraph. Accepting
null landed on main in #4975; the SingleController clamp already returned early
for it, so the paragraph's advice now has a second option.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Signed-off-by: ruit <[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) community-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants