Skip to content

perf(cispo): support single-forward training - #4670

Merged
terrykong merged 4 commits into
NVIDIA-NeMo:mainfrom
semitable:cispo-single-forward
Oct 17, 2026
Merged

terrykong merged 4 commits into
NVIDIA-NeMo:mainfrom
semitable:cispo-single-forward

Conversation

@semitable

@semitable semitable commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Allow CISPO to skip the extra policy forward using force_on_policy_ratio=true, while retaining per-token clipped importance weights.

Issues

None.

Usage

For one optimizer update per rollout batch:

loss_fn:
  use_cispo: true
  force_on_policy_ratio: true
  use_importance_sampling_correction: true
  truncated_importance_sampling_type: tis
  truncated_importance_sampling_ratio: 5.0
  ratio_clip_min: 1.0
  ratio_clip_max: 4.0

Improvements

Tested on an agentic coding workload with a 128K context limit, using 16 GB300 training GPUs and separate rollout workers. Each optimizer update uses 256 trajectories (16 prompts × 16 generations), with sequence packing and approximately 48–61 accumulated microbatches in the baseline.

On this setting, observed non-wait optim step time was 21% lower, or approximately 14% lower when normalized by token count.

Before your PR is "Ready for review"

  • Read and followed contributor guidelines
  • Added necessary tests
  • Ran unit and functional tests locally
  • Updated documentation

@copy-pr-bot

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

@github-actions github-actions Bot added the Documentation Improvements or additions to documentation label Oct 12, 2026
@semitable
semitable force-pushed the cispo-single-forward branch from 0b0c50b to a67cc3e Compare October 12, 2026 12:32
@semitable
semitable marked this pull request as ready for review October 12, 2026 12:35
@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-maintainers Waiting on maintainers to respond label Oct 14, 2026

@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. Reusing the existing knobs (force_on_policy_ratio + TIS) instead of adding a new config key keeps the config small. The new loss test runs on CPU (its CISPO siblings need CUDA), so it actually runs in CPU CI. The new SingleController test case fails if the validator change is reverted, so it tests the right thing. The math checks out: for one update per rollout, single-forward CISPO gives the same loss and gradient as two-forward CISPO with the same TIS bounds. This holds numerically on CPU, including with torch.compile.

Once the loss-function branches go back to the base code, what this PR really changes is: allow CISPO + force_on_policy_ratio (guarded by the IS + TIS assert), allow it with the SingleController ready_first sampler, and add docs.

Perf numbers (not blocking). The title says perf(...). Please add one before/after step-time line on any one-update CISPO config: total step time and logprob-inference time, mean over at least 10 steps after warm-up, with GPU SKU and node count.

No action needed. The ready_first force_on_policy_ratio=false guard from #3582 (#3582) looks stricter than needed when SingleController runs one optimizer step per RL step. The CISPO carve-out in this PR is fine as is; widening it to other losses is out of scope here.

Visual explainer: https://terrykong.github.io/gh-pages-poc/terryk/pr-4670-single-forward-cispo.html

Generated by Claude Code

Comment thread nemo_rl/algorithms/loss/clipped_pg.py Resolved
Comment thread docs/guides/cispo.md Resolved
Comment thread docs/guides/cispo.md Resolved
@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-customer Waiting on the original author to respond and removed waiting-on-maintainers Waiting on maintainers to respond labels Oct 15, 2026
@semitable

Copy link
Copy Markdown
Contributor Author

Thank you @terrykong -- I addressed the comments. Also, I added some numbers in the main PR description; for my workload I am seeing ~15-20% faster step time (excluding waiting for trajectories).

@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-customer Waiting on the original author to respond label Oct 16, 2026
@terrykong terrykong added the CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) label Oct 16, 2026
@terrykong
terrykong enabled auto-merge (squash) October 16, 2026 17:46
@terrykong

Copy link
Copy Markdown
Collaborator

/ok to test dd5a038

@svcnvidia-nemo-ci svcnvidia-nemo-ci added the waiting-on-customer Waiting on the original author to respond label Oct 16, 2026
@semitable

Copy link
Copy Markdown
Contributor Author

AssertionError: Server timed out in the IPC weight-transfer test seems unrelated? Flaky?

@terrykong

terrykong commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

@semitable yea, it appears to be a flaky test/infra issue

there was a babysitting agent that would've restarted the flaky test so we don't have to wait for everything, just need to wait for the next "tick" of its check

since you merged in main we'll need to kick off another run, but for future ref if you suspect flaky, then you can click on the test and click this:
image

rerun failed jobs, to only rerun the flaky

@terrykong

Copy link
Copy Markdown
Collaborator

/ok to test 10927f6

@terrykong
terrykong merged commit 512e608 into NVIDIA-NeMo:main Oct 17, 2026
163 of 165 checks passed
@svcnvidia-nemo-ci svcnvidia-nemo-ci removed the waiting-on-customer Waiting on the original author to respond label Oct 17, 2026
alexandery-nvidia added a commit that referenced this pull request Oct 17, 2026
…failures-and-redispatch

main gained #4481, #4771, #4458, #4770, #4640, #4765, #4525 and #4670 since the
previous merge. #4640 (rubric-mean and fixed-baseline GenRM scoring) rewrote the
metric assertions in tests/unit/experience/test_rollouts.py that this branch also
edits for nemo_gym_infra_redispatches: the resolution keeps main's per-key
assertions and adds the redispatch count beside them, and the expected
rollout_metrics dict carries both sides' new keys. test_rollouts.py,
test_rollout_manager.py and test_nemo_gym.py pass locally on the merged tree.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: alexandery <[email protected]>
alexandery-nvidia added a commit that referenced this pull request Oct 17, 2026
…andery/gym-health-check-during-collection

Carries the stack root's merge of main (8338530: #4481, #4771, #4458, #4770,
#4640, #4765, #4525 and #4670) forward so this head stays current with main.
No conflicts; test_rollouts.py, test_rollout_manager.py and test_nemo_gym.py
pass locally on the merged tree.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: alexandery <[email protected]>
alexandery-nvidia added a commit that referenced this pull request Oct 17, 2026
…xandery/gym-rollout-metrics-hook

Carries the stack's merge of main (8338530: #4481, #4771, #4458, #4770, #4640,
#4765, #4525 and #4670) forward. #4640 (rubric-mean and fixed-baseline GenRM
scoring) reports the shared GenRM fields once per group through
_nemo_gym_group_metrics and skips them in both per-agent loops, which this
branch had replaced with per_agent_result_metrics: the resolution keeps the
helper on both paths and adds the same _SHARED_GENRM_METRICS skip inside it,
so the manager no longer imports the constant. test_rollouts.py,
test_rollout_manager.py and test_nemo_gym.py pass locally on the merged tree.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Signed-off-by: alexandery <[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) Documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants