Update rl_replacements.py
This commit is contained in:
parent
4038dcca3e
commit
2a26cdc184
1 changed files with 4 additions and 3 deletions
|
|
@ -216,7 +216,8 @@ def grpo_trainer_compute_loss(function_name, function):
|
|||
# attention_mask = torch.cat([prompt_mask, completion_mask], dim=1)
|
||||
attention_mask = None
|
||||
logits_to_keep = completion_ids.size(1) # we only need to compute the logits for the completion tokens
|
||||
|
||||
_input_ids = input_ids
|
||||
_logits_to_keep = logits_to_keep
|
||||
per_token_logps = self._get_per_token_logps(model, input_ids, attention_mask, logits_to_keep)
|
||||
|
||||
# Compute the KL divergence between the model and the reference model
|
||||
|
|
@ -238,8 +239,8 @@ def grpo_trainer_compute_loss(function_name, function):
|
|||
if RL_REPLACEMENTS["count"] == 10: raise
|
||||
else: RL_REPLACEMENTS["count"] = 1
|
||||
RL_REPLACEMENTS["data"] = (
|
||||
ref_per_token_logps, per_token_logps, input_ids, completion_mask, self.beta, advantages,
|
||||
loss, completion_length, mean_kl, completion_ids,
|
||||
ref_per_token_logps, per_token_logps, _input_ids, completion_mask, self.beta, advantages,
|
||||
loss, completion_length, mean_kl, completion_ids, _logits_to_keep,
|
||||
)
|
||||
# Log the metrics
|
||||
# completion_length = self.accelerator.gather_for_metrics(completion_mask.sum(1)).float().mean().item()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue