Update rl_replacements.py
This commit is contained in:
parent
2cb0ebc47e
commit
3fa2f1436a
1 changed files with 5 additions and 1 deletions
|
|
@ -320,12 +320,16 @@ def grpo_trainer_compute_loss(function_name, function):
|
|||
# _prepare_inputs doesn't return reference log probs anymore. We need to calculate it ourselves.
|
||||
# https://github.com/huggingface/trl/blob/05bc43e960396581e458195b8388efe6b82cae1f/trl/trainer/grpo_trainer.py#L1328
|
||||
if self.beta != 0.0:
|
||||
print("!!!!!!!!!!")
|
||||
print("!!!!!!!!!!")
|
||||
with torch.inference_mode(), model.disable_adapter():
|
||||
ref_per_token_logps = self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep)
|
||||
else:
|
||||
ref_per_token_logps = None
|
||||
# per_token_kl = torch.exp(ref_per_token_logps - per_token_logps) - (ref_per_token_logps - per_token_logps) - 1
|
||||
|
||||
print("!!!!!!!!!!")
|
||||
print("!!!!!!!!!!")
|
||||
print(ref_per_token_logps)
|
||||
# x - x.detach() allows for preserving gradients from x
|
||||
advantages = inputs["advantages"]
|
||||
# per_token_loss = torch.exp(per_token_logps - per_token_logps.detach()) * advantages.unsqueeze(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue