Skip to content

Commit

Permalink
[CPO] fix memory leak due to retained value (huggingface#1531)
Browse files Browse the repository at this point in the history
  • Loading branch information
kashif authored and Andrew Lapp committed May 10, 2024
1 parent abf18db commit a966d01
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion trl/trainer/cpo_trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ def get_batch_loss_metrics(
metrics[f"{prefix}logps/chosen"] = policy_chosen_logps.detach().mean().cpu()
metrics[f"{prefix}logits/rejected"] = policy_rejected_logits.detach().mean().cpu()
metrics[f"{prefix}logits/chosen"] = policy_chosen_logits.detach().mean().cpu()
metrics[f"{prefix}nll_loss"] = policy_nll_loss.cpu().mean()
metrics[f"{prefix}nll_loss"] = policy_nll_loss.detach().mean().cpu()

return loss, metrics

Expand Down

0 comments on commit a966d01

Please sign in to comment.