Skip to content

feat(sc): add ready-first staleness sampler - #3582

Merged
terrykong merged 7 commits into
NVIDIA-NeMo:mainfrom
haitian-nvidia:haitianj/areal-admission-sampler
Aug 18, 2026
Merged

terrykong merged 7 commits into
NVIDIA-NeMo:mainfrom
haitian-nvidia:haitianj/areal-admission-sampler

Conversation

@haitian-nvidia

@haitian-nvidia haitian-nvidia commented Aug 11, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do ?

Ports the staleness-admission policy from #2940 (AReaL) onto the current
SingleController sampler interface as a new built-in ReadyFirstSampler
(name="ready_first").

  • Admission gates dispatch to at most max_staleness_versions (eta) batches
    ahead of the trainer version, reusing the shared _GatedSampler dispatch
    counter; the controller keeps no duplicate staleness state.
  • Selection is ready-first across weight versions (mixed-version batches)
    instead of draining one version at a time.
  • The sampler never evicts: every admitted group stays selectable until it is
    trained on, so late stragglers remain usable and no rollout is discarded.
  • ReadyFirstSamplerConfig joins the discriminated SamplerConfig union,
    create_sampler(), and required_buffer_capacity_for_config()
    (capacity = num_prompts_per_step * (eta + 1)).
  • validate_single_controller_config() rejects ready_first unless
    loss_fn.use_importance_sampling_correction=true and
    loss_fn.force_on_policy_ratio=false, so prev_logprobs are real and used
    as the behavior-policy correction. The check fails before any setup factory
    allocates resources.

Issues

Related: #2940 (original AReaL PR this admission policy is ported from).

Usage

loss_fn:
  use_importance_sampling_correction: true
  force_on_policy_ratio: false

async_rl:
  sampler:
    name: ready_first
    max_staleness_versions: 1   # eta: at most 1 batch ahead of the trainer
  max_buffered_rollouts: 128    # >= num_prompts_per_step * (eta + 1)

See the full runnable recipe at
examples/configs/recipes/llm/grpo-llama3.1-8b-instruct-2n8g-ready-first-single-controller.yaml.

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

  • Covered by sampler-interface unit tests (admission gating, mixed-version
    selection, no-eviction straggler handling, config parsing/capacity) and a
    setup test for the new validator guard. Both affected unit-test files pass
    on this branch.
  • Verified e2e: a 10-step M=1 run (Llama-3.1-8B, Megatron TP2 + non-colocated
    vLLM) under ready_first completes with finite losses.

Port the AReaL decoupled-PPO admission policy from PR NVIDIA-NeMo#2940 onto the
current SingleController sampler interface as a new built-in
ArealAdmissionSampler (name="areal_admission"):

- admission gates dispatch to at most `max_staleness_versions` (eta)
  batches ahead of the trainer version, reusing the shared _GatedSampler
  dispatch counter; the controller keeps no duplicate staleness state
- selection is ready-first across weight versions (mixed-version
  batches) instead of draining one version at a time
- a typed `evict_stale_samples` knob (default false) controls both the
  selection lower bound and eviction together: false keeps late
  stragglers trainable and never evicts; true applies the hard window
  [v - eta, v] to selection and evicts ready groups below it, skipping
  uncommitted slots to avoid racing commit()
- ArealAdmissionSamplerConfig joins the discriminated SamplerConfig
  union, create_sampler(), and required_buffer_capacity_for_config()
  (capacity = num_prompts_per_step * (eta + 1))
- validate_single_controller_config() rejects areal_admission unless
  loss_fn.use_importance_sampling_correction=true and
  loss_fn.force_on_policy_ratio=false, so prev_logprobs are real and
  used as the behavior-policy correction (decoupled PPO), and fails
  before any setup factory allocates resources

Covered by sampler-interface unit tests (admission gating, mixed-version
selection, both eviction modes, config parsing/capacity) and setup
tests for the new validator guards. Verified e2e: 10-step M=1 run
(Llama-3.1-8B, Megatron TP2 + non-colocated vLLM) under
areal_admission completes with finite losses.

Signed-off-by: haitian-nvidia <[email protected]>
@haitian-nvidia
haitian-nvidia requested review from a team as code owners August 11, 2026 18:09
@copy-pr-bot

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

@haitian-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 869f9ca

Address review feedback on NVIDIA-NeMo#3582: samplers should not be named after a
framework. The distinguishing behavior is the selection policy --
whichever group is ready first gets trained, across weight versions --
so rename ArealAdmissionSampler / areal_admission to ReadyFirstSampler /
ready_first (class, config union literal, validator messages, tests) and
drop the AReaL framing from the sampler docstring. No functional change.

Signed-off-by: haitian-nvidia <[email protected]>
@haitian-nvidia haitian-nvidia changed the title feat(sc): add areal admission sampler feat(sc): add ready-first staleness sampler Aug 11, 2026
@haitian-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 3ed8a5f

The ready_first sampler never discards a rollout: every admitted group
stays selectable until trained, so the evict_stale_samples knob and its
hard-window selection/eviction mode are removed. evict() is now an
unconditional no-op, select() keeps every ready group at or below the
trainer version, and the hard-window unit tests are dropped.

Also add a runnable example recipe,
grpo-llama3.1-8b-instruct-2n8g-ready-first-single-controller.yaml,
showing the sampler with the loss configuration its validator requires
(use_importance_sampling_correction=true, force_on_policy_ratio=false).

Signed-off-by: haitian-nvidia <[email protected]>
@haitian-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 4873a61

@haitian-nvidia haitian-nvidia added CI:L0 Run doctests and unit tests 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 Aug 13, 2026
…ssion-sampler

# Conflicts:
#	nemo_rl/algorithms/single_controller_utils/config.py
#	tests/unit/single_controller/test_single_controller_setup.py
@haitian-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 76a65d8

Every recipe YAML must have a same-named tests/test_suites driver
script listed in a suite file (enforced by
test_all_recipe_yamls_accounted_for_in_test_suites, which failed in CI
as 235 recipe YAMLs vs 234 suite entries). Add the
grpo-llama3.1-8b-instruct-2n8g-ready-first-single-controller.sh driver
(same 10-step run and metric checks as the streaming2 base recipe) and
register it in nightly.txt under the Single Controller section.

Signed-off-by: haitian-nvidia <[email protected]>
@haitian-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test ed3c3d5

The driver script only exists to satisfy the recipe/suite pairing check
for the example recipe; it was not meant to consume nightly compute.
Every .sh under tests/test_suites must be listed in a suite file, so
register it in disabled.txt (zero nightly cost, the same pattern the
circle_click recipe uses) instead of nightly.txt, whose 3928 GPU-hour
budget the entry pushed to 3949.

Signed-off-by: haitian-nvidia <[email protected]>
@haitian-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test f58772895b1968e4e37124a9e13212328f13b09c

@copy-pr-bot

copy-pr-bot Bot commented Aug 18, 2026

Copy link
Copy Markdown

/ok to test f58772895b1968e4e37124a9e13212328f13b09c

@haitian-nvidia, there was an error processing your request: E2

See the following link for more information: https://docs.gha-runners.nvidia.com/cpr/e/2/

@haitian-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test f587728

…ssion-sampler

# Conflicts:
#	tests/test_suites/disabled.txt
@haitian-nvidia

Copy link
Copy Markdown
Contributor Author

/ok to test 1c0b047

@terrykong
terrykong merged commit fe8a7fa into NVIDIA-NeMo:main Aug 18, 2026
82 checks passed
saumishr added a commit to saumishr/RL that referenced this pull request Aug 19, 2026
Every part of the dropped-prompt path is keyed on target_step, and InOrderSampler
is the only built-in that stamps one: _GatedSampler._stamp returns None, neither
WeightFifoSampler nor ReadyFirstSampler overrides it, and WindowedSampler.admit
returns None outright. _credit_shortfall, _take_replacement and _promote_into_step
all early-return on None, so under any of those a prompt that is given up on is
never subtracted from the step waiting for it. The step's target stays at the full
num_prompts_per_step and min_step_batch_fraction is never consulted.

The consequence is not an inert knob. Under weight_fifo the run stalls with no
error at all: select always takes min(in_window) and _finalize_selection returns
(None, 0) below min_prompt_groups, while the default evict only drops weights
strictly below the window, so the short version is never cleared. The same
admit() gate that stops the rollout pump running ahead also stops it reaching
exhaustion, so _rollout_exhausted never sets, the train pump sleeps 5ms and
re-asks forever, and the job holds its GPUs until the wall clock kills it. Under
windowed and ready_first it is bounded but late -- the hole migrates batch to
batch and the final step has none left to borrow from, failing hours in with
"rollout exhausted before a complete training step was assembled".

Rejected rather than warned about, unlike its neighbours in this function: those
each describe a coherent thing to have asked for, whereas there is no run that
wants a tolerance setting to convert a recoverable prompt failure into a stall.
A zero budget stays exempt and keeps the existing warning, because no drop is
tolerated then and the shortfall path is unreachable regardless of sampler.

The guard names the exempt samplers rather than the affected ones, so a sampler
added later is covered by default. That is not hypothetical: ready_first (NVIDIA-NeMo#3582)
landed between this branch's base and this rebase, inheriting the None stamp like
the rest, and an allow-list -- along with a test restating the same list -- would
have let it through silently. The test reads the sampler names off the
discriminated union for the same reason.

Signed-off-by: Saurabh Mishra <[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.

4 participants