-
Notifications
You must be signed in to change notification settings - Fork 2.2k
↔️ Fix CB in GRPO #3722
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
↔️ Fix CB in GRPO #3722
Conversation
prompt_ids = [torch.tensor(ids, device=device) for ids in prompt_inputs.input_ids] | ||
prompt_ids = pad(prompt_ids, padding_value=self.processing_class.pad_token_id) | ||
prompt_ids = pad(prompt_ids, padding_value=self.processing_class.pad_token_id, padding_side="left") |
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.
Padding side must be "left"
for prompts, otherwise you'd get (incorrect):
[[P01, P01, P03, PAD, PAD, C01, C02, C03, C04],
[P11, P11, P13, P14, P15, C11, C12, PAD, PAD]]
instead of (correct)
[[PAD, PAD, P01, P01, P03, C01, C02, C03, C04],
[P11, P11, P13, P14, P15, C11, C12, PAD, PAD]]
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.
then how we got reasonable output till now? 🧐
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.
the error is only when using CB, introduced in #3471
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. |
with ( | ||
profiling_context(self, "transformers.generate"), | ||
unwrap_model_for_generation( | ||
self.model_wrapped, self.accelerator, gather_deepspeed3_params=self.args.ds3_gather_for_generation | ||
) as unwrapped_model, | ||
torch.no_grad(), | ||
FSDP.summon_full_params(self.model_wrapped, recurse=False) if self.is_fsdp_enabled else nullcontext(), | ||
): |
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.
simplification, using
with c1, c2:
instead of
with c1:
with c2:
good catch! lets also pin the transformer to the latest patch for the generation length fix? |
can you kindly test with |
done in 17157c4 |
Co-authored-by: Shirin Yamani <75791599+shirinyamani@users.noreply.github.com>
Co-authored-by: Shirin Yamani <75791599+shirinyamani@users.noreply.github.com>
Co-authored-by: Shirin Yamani <75791599+shirinyamani@users.noreply.github.com>
Padding side was wrong, this PR is a fix
A few cleanup, late review for #3471
cc @ArthurZucker for viz