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

Fix failing fp16 evaluation #124

Merged
merged 4 commits into from
Jul 8, 2024
Merged

Conversation

lorenzomammana
Copy link
Contributor

Summary

Currently for finetuning and anomaly the evaluation tasks don't work properly when the model is trained with fp16 precision. This pr fixes the wrong dtype used for inputs.

Type of Change

  • Bug fix (non-breaking change that solves an issue)

Checklist

Please confirm that the following tasks have been completed:

  • I have tested my changes locally and they work as expected. (Please describe the tests you performed.)
  • I have added unit tests for my changes, or updated existing tests if necessary.
  • I have updated the documentation, if applicable.
  • I have installed pre-commit and run locally for my code changes.

@@ -386,10 +386,11 @@ def test(self) -> None:
batch_labels = batch_item["label"]
image_labels.extend(batch_labels.tolist())
image_paths.extend(batch_item["image_path"])
batch_images = batch_images.to(self.device).to(self.deployment_model.model_dtype)
Copy link
Collaborator

Choose a reason for hiding this comment

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

It should be possible to pass both the device and the dtype with single .to() call according to the documentation. https://pytorch.org/docs/2.1/generated/torch.Tensor.to.html#torch-tensor-to

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Crazy 🤯

@lorenzomammana lorenzomammana merged commit 8a2ab23 into main Jul 8, 2024
2 checks passed
@lorenzomammana lorenzomammana deleted the hotfix/fix-failing-fp16-evaluation branch July 8, 2024 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants