added iw - #1
Open
lhleohuang wants to merge 7 commits into
Open
Conversation
lhleohuang
commented
Jul 24, 2025
| self.ref_model = prepare_deepspeed(self.ref_model, self.accelerator) | ||
| else: | ||
| self.ref_model = self.accelerator.prepare_model(self.ref_model, evaluation_mode=True) | ||
| else: |
Collaborator
Author
There was a problem hiding this comment.
I checked source code (https://github.com/huggingface/trl/blob/822653824bf084bc6c042cf0e759f86187c92569/trl/trainer/grpo_trainer.py), I think mine is correct here. Idk why the identation was different.
lhleohuang
commented
Jul 24, 2025
| @@ -871,28 +923,6 @@ def _generate_and_score_completions( | |||
|
|
|||
| logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens | |||
|
|
|||
lhleohuang
commented
Jul 24, 2025
| @@ -985,6 +1015,21 @@ def _generate_and_score_completions( | |||
| self._metrics[mode]["completions/min_length"].append(agg_completion_mask.float().min().item()) | |||
| self._metrics[mode]["completions/max_length"].append(agg_completion_mask.float().max().item()) | |||
|
|
|||
Collaborator
Author
There was a problem hiding this comment.
extra logging - nothing to do with iw
lhleohuang
commented
Jul 24, 2025
| @@ -1021,12 +1066,117 @@ def _generate_and_score_completions( | |||
| for i, name in enumerate(reward_func_names): | |||
| self._textual_logs["rewards"][name].extend(rewards_per_func[:, i].tolist()) | |||
|
|
|||
Collaborator
Author
There was a problem hiding this comment.
in this version, gradient_filtering is done in this method rather than in compute_loss
nothing to do with iw
lhleohuang
commented
Jul 24, 2025
| prompt_ids = prompt_ids[valid] | ||
| prompt_mask = prompt_mask[valid] | ||
|
|
||
|
|
Collaborator
Author
There was a problem hiding this comment.
the following if with self.iw is key
lhleohuang
commented
Jul 24, 2025
| "prompt_mask": prompt_mask, | ||
| "completion_ids": completion_ids, | ||
| "completion_mask": completion_mask, | ||
| "advantages": advantages, |
Collaborator
Author
There was a problem hiding this comment.
the original rewards need to be returned for importance weighted advantage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.