Skip to content

Commit

Permalink
fix dpo&kto oom (#9390)
Browse files Browse the repository at this point in the history
  • Loading branch information
lugimzzz authored Nov 7, 2024
1 parent a3c3800 commit d02c406
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions paddlenlp/trl/dpo_criterion.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,10 @@ def forward(
)
loss = dpo_loss + sft_loss
if self.use_infohub:
infohub.policy_chosen_logps.append(policy_chosen_logps)
infohub.policy_rejected_logps.append(policy_rejected_logps)
infohub.sft_loss.append(sft_loss)
infohub.dpo_loss.append(dpo_loss)
infohub.policy_chosen_logps.append(policy_chosen_logps.detach())
infohub.policy_rejected_logps.append(policy_rejected_logps.detach())
infohub.sft_loss.append(sft_loss.detach())
infohub.dpo_loss.append(dpo_loss.detach())
return loss
else:
return policy_chosen_logps, policy_rejected_logps, sft_loss, dpo_loss, loss
8 changes: 4 additions & 4 deletions paddlenlp/trl/kto_criterion.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,10 @@ def forward(
reference_kl_logps,
)
if self.use_infohub:
infohub.policy_chosen_logps.append(policy_chosen_logps)
infohub.policy_rejected_logps.append(policy_rejected_logps)
infohub.policy_kl_logps.append(policy_kl_logps)
infohub.kl.append(kl)
infohub.policy_chosen_logps.append(policy_chosen_logps.detach())
infohub.policy_rejected_logps.append(policy_rejected_logps.detach())
infohub.policy_kl_logps.append(policy_kl_logps.detach())
infohub.kl.append(kl.detach())
return loss
else:
return (
Expand Down

0 comments on commit d02c406

Please sign in to comment.