Skip to content

Commit

Permalink
Move loss metric to same device as inputs (#3522)
Browse files Browse the repository at this point in the history
  • Loading branch information
Infernaught authored and arnavgarg1 committed Aug 11, 2023
1 parent c545285 commit 007c261
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ludwig/models/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,11 @@ def update_metrics(self, targets, predictions):
continue
of_obj.update_metrics(targets[of_name], predictions[of_name])

# HACK (Tim): get the device of the targets to transfer self.eval_loss_metric to the same device
target_device = list(targets.values())[0].device

eval_loss, additional_losses = self.eval_loss(targets, predictions)
self.eval_loss_metric = self.eval_loss_metric.to(target_device)
self.eval_loss_metric.update(eval_loss)
self.eval_additional_losses_metrics.update(additional_losses)

Expand Down

0 comments on commit 007c261

Please sign in to comment.