Repository navigation
fix(grpo): improve non-colocated refit handling - #2672
Conversation
|
/ok to test 7f01b8d |
6f9f934 to
93dc3c5
Compare
|
/ok to test 93dc3c5 |
93dc3c5 to
2e3d3fe
Compare
|
/ok to test 2e3d3fe |
2e3d3fe to
4abd6ba
Compare
|
/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]>
4abd6ba to
3be115c
Compare
|
/ok to test 3be115c |
|
@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() |
There was a problem hiding this comment.
This line and the following policy.prepare_for_training() have to be reverted.
@macandro96 @yfw
There was a problem hiding this comment.
@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.
There was a problem hiding this comment.
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).
Signed-off-by: Anish Mahishi <[email protected]> Co-authored-by: Anish Mahishi <[email protected]>
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
# Add a code snippet demonstrating how to use thisBefore your PR is "Ready for review"
Pre checks:
Additional Information