Fix eval_accumulation_steps leading to incorrect metrics (#24756)

Fix eval steps
This commit is contained in:
Zach Mueller 2023-07-12 05:49:12 -04:00 committed by GitHub
parent 45025d92f8
commit 7edc33ac7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3154,7 +3154,7 @@ class Trainer:
self.control = self.callback_handler.on_prediction_step(args, self.state, self.control)
# Gather all tensors and put them back on the CPU if we have done enough accumulation steps.
if args.eval_accumulation_steps is not None and (step + 1) % args.eval_accumulation_steps == 0:
if args.eval_accumulation_steps is not None and self.accelerator.sync_gradients:
if losses_host is not None:
losses = nested_numpify(losses_host)
all_losses = losses if all_losses is None else np.concatenate((all_losses, losses), axis=0)