Skip to content

fix(grpo): improve non-colocated refit handling - #2672

Merged
yfw merged 1 commit into
mainfrom
amahishi/offload-before-refit
Jun 5, 2026
Merged

yfw merged 1 commit into
mainfrom
amahishi/offload-before-refit

Conversation

@macandro96

Copy link
Copy Markdown
Contributor

What does this PR do ?

Offload policy optimizer state before NCCL refit and restore training state after weight sync. Also skip reference policy logprobs when KL is disabled.

Issues

Closes #1978

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

  • ...

@macandro96
macandro96 requested review from a team as code owners June 2, 2026 20:56
@macandro96 macandro96 added super-v3 CI:Lfast Runs a fast test suite and re-use nightly `main` container (but sync dependencies to PRs version) labels Jun 2, 2026
@copy-pr-bot

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

@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test 7f01b8d

@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test 93dc3c5

@macandro96
macandro96 force-pushed the amahishi/offload-before-refit branch from 93dc3c5 to 2e3d3fe Compare June 4, 2026 20:06
@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test 2e3d3fe

@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test 4abd6ba

Offload policy optimizer state before NCCL refit and restore training state after weight sync. Also skip reference policy logprobs when KL is disabled.

Signed-off-by: Anish Mahishi <[email protected]>
@macandro96
macandro96 force-pushed the amahishi/offload-before-refit branch from 4abd6ba to 3be115c Compare June 4, 2026 23:26
@macandro96

Copy link
Copy Markdown
Contributor Author

/ok to test 3be115c

@yfw
yfw merged commit 458548d into main Jun 5, 2026
130 of 132 checks passed
@yfw
yfw deleted the amahishi/offload-before-refit branch June 5, 2026 17:43
@youngeunkwon0405

Copy link
Copy Markdown
Contributor

@macandro96 @yfw, why are we offloading optimizer states in the non-colocated case? This PR is creating a huge performance regression in the non-colocated grpo case.

raise NotImplementedError(
"SGLang haven't implemented non-colocated inference mode. "
)
policy.offload_before_refit()

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.

This line and the following policy.prepare_for_training() have to be reverted.
@macandro96 @yfw

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@youngeunkwon0405 this change was part of upstreaming efforts for super (and even ultra i think). It was done to reduce memory overhead incurred during weight transfer (by offloading optimizer states) which otherwise could result in oom.

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.

I understand what this is doing, but it doesn't make sense to offload the optimizer state in the non-colocated case. For the non-colocated case, the peak memory usage should always happen at training time, right before the backprop starts.
At that time, the major components in the memory are: [weights, optimizer state, stored activations].

At the refit time, the peak memory consumption without the optimizer state offloading is:
[weights, optimizer state, refit buffer]

And except for the extreme case, refit buffer (which is 2% of total GPU memory) is smaller than the stored activations. So it doesn't make sense to do this optimization offloading. This will only cause additional performance overheads (usually 10-15s per step for fine-grained MoE models).

This branch was previously deployed

2 inactive deployments
public — 3be115cd Deployed Jun 4, 2026 by copy-pr-bot[bot] via release / finalize / publish-docs #701
test — 3be115cd Deployed Jun 4, 2026 by copy-pr-bot[bot] via Wait in test approval queue #11965
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) super-v3

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[super-pr] dependency bump + skip log probs + add OMP_NUM_THREADS + offload before refit + mtp ckpt fix

3 participants