Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move loss metric to same device as inputs #3522

Merged
merged 1 commit into from
Aug 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ludwig/models/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,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
arnavgarg1 marked this conversation as resolved.
Show resolved Hide resolved

eval_loss, additional_losses = self.eval_loss(targets, predictions)
self.eval_loss_metric = self.eval_loss_metric.to(target_device)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Could you also do this for self.eval_additional_losses_metrics? I assume that may also require being moved to the right device (once we support multi-feature outputs for LLM model types, but might as well do it now)

self.eval_loss_metric.update(eval_loss)
self.eval_additional_losses_metrics.update(additional_losses)

Expand Down