-
Notifications
You must be signed in to change notification settings - Fork 2.2k
[GRPO]: Sample from a Replay Buffer To Substitute Groups with 0 std. #4060
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[GRPO]: Sample from a Replay Buffer To Substitute Groups with 0 std. #4060
Conversation
I'm still mulling over the multi-gpu scenario, I'm wondering if we should have the same buffer used on all gpus/processes or if its okay for each gpu/process to have its own buffer. Happy to hear your views on this @qgallouedec Also still need to add an e2e test for training with the ReplayBuffer. |
I should probably break the
Also need to add new test cases to confirm that the code works when the seq lengths in the buffer are different from the current batch. |
can you migrate this into |
Yes will do. |
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
class GRPOWithReplayBufferConfig(GRPOConfig): | ||
""" | ||
New Parameters: | ||
replay_buffer_size (`int`, *optional*, defaults to `0`): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replay_buffer_size (`int`, *optional*, defaults to `0`): | |
replay_buffer_size (`int`, *optional*, defaults to `64`): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
What does this PR do?
Introduces the idea of a
ReplayBuffer
to GRPO. Implementation detailsReplayBuffer
is implemented as a heap/priority queue. The buffer stores ascore
and a dict with the same keys as_generate_and_score_completions
.ReplayBuffer
stores entire groups and all the keys associated with a group that'd be needed for computing the loss. Storing the old/ref_log_probs ensures that we don't run any extra forward passes through models._generate_and_score_completions
is called we check if 1. There are any groups with non-zero variance, these are candidates to be added to the ReplayBuffer. 2. There are any groups with 0 variance, these need to be substituted out with values from the replay buffer.Before submitting
Pull Request section?
to it if that's the case.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.