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

In case of MPS device also copy batch to CPU #3105

Merged
merged 16 commits into from
Mar 22, 2024

Conversation

hyenal
Copy link
Contributor

@hyenal hyenal commented Mar 11, 2024

What does this PR do?

This PR fixes an issue when using MPS device and composer's classifier. When computing metrics, outputs is copied to the cpu but not batch which creates some downstream error.

What issue(s) does this change relate to?

Fixes #3094

Before submitting

  • Have you read the contributor guidelines?
  • Is this change a documentation change or typo fix? If so, skip the rest of this checklist.
  • Was this change discussed/approved in a GitHub issue first? It is much more likely to be merged if so.
  • Did you update any related docs and document your change?
  • Did you update any related tests and add any new tests related to your change? (see testing)
  • Did you run the tests locally to make sure they pass?
  • Did you run pre-commit on your change? (see the pre-commit section of prerequisites)

Copy link
Contributor

@mvpatel2000 mvpatel2000 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR!

I think there's a minor error -- once fixed looks good to me! Please feel free to rerequest when this is merged

composer/trainer/trainer.py Outdated Show resolved Hide resolved
@hyenal hyenal requested a review from a team as a code owner March 14, 2024 16:38
@mvpatel2000
Copy link
Contributor

Hm... labels can be a complex type so directly calling to seems to fail tests

@hyenal
Copy link
Contributor Author

hyenal commented Mar 15, 2024

To ensure compatibility with HuggingFaceModel I had to create a new method to shift labels outside of eval_forward.

I hope this is not a breaking change, it felt a bit more natural to modify the labels outside of this method as well but there may be reasons for doing it there that I am unaware of.

In addition update_metric will be slightly less efficient although the shift label operation should be very cheap

@dakinggg dakinggg enabled auto-merge (squash) March 22, 2024 18:36
@dakinggg dakinggg merged commit f925ef0 into mosaicml:dev Mar 22, 2024
14 checks passed
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.

Different device error when running evaluation_loop on "mps" device with ComposeClassifier
3 participants