Skip to content

added iw - #1

Open
lhleohuang wants to merge 7 commits into
mainfrom
iw
Open

added iw#1
lhleohuang wants to merge 7 commits into
mainfrom
iw

Conversation

@lhleohuang

Copy link
Copy Markdown
Collaborator

No description provided.

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:

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

@@ -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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

moved to later

@@ -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())

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

extra logging - nothing to do with iw

@@ -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())

@lhleohuang lhleohuang Jul 24, 2025

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

in this version, gradient_filtering is done in this method rather than in compute_loss

nothing to do with iw

prompt_ids = prompt_ids[valid]
prompt_mask = prompt_mask[valid]


Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the following if with self.iw is key

"prompt_mask": prompt_mask,
"completion_ids": completion_ids,
"completion_mask": completion_mask,
"advantages": advantages,

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

the original rewards need to be returned for importance weighted advantage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant