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

Experimental macOS/MPS support #200

Merged

Conversation

ianbulovic
Copy link
Contributor

@ianbulovic ianbulovic commented Jun 27, 2024

This PR adds experimental MPS support, including updated package dependencies for macOS and MPS acceleration for models served by the API.

The following dependencies have been updated in setup.cfg:

  • PyRuSH: 1.0.3.61.0.8
    An issue with the build script in older versions of PyRuSH prevented the wheel from building on macOS
  • torch: ~=1.5>=1.5, <=2.3.1
    More current versions of torch have much improved mps support, with more operations supported by the backend.
    I realize this dependency now spans two major versions of pytorch... should we consider committing to 2.x?
  • transformers: ~=4.15>=4.15, <4.42
    transformers 4.42 seems to be causing the following error on mps when loading models:
    RuntimeError: Placeholder storage has not been allocated on MPS device!
    This error doesn't occur with transformers <4.42.

This PR also adds some checks to use the MPS device when possible, specifically for models served by the API. Training scripts already use MPS by default because we're using the HF Trainer class, which does this for us.

This implementation Works On My Machine™, but more testing is needed to make sure this definitively solves all the build dependency issues. I'm opening this on main rather than dev because all it should do is increase compatibility for macOS users—but let me know if adapting this for the latest dev version makes more sense.

@ianbulovic ianbulovic requested a review from tmills June 27, 2024 18:28
@ianbulovic
Copy link
Contributor Author

ianbulovic commented Jul 1, 2024

Potentially relevant information for why macOS tests aren't passing—looks like GitHub-hosted runners don't support MPS.

Update: It seems like transformers 4.42 was causing the issue, but I have no idea why.

@ianbulovic ianbulovic changed the title Experimental MPS support Experimental macOS/MPS support Jul 3, 2024
@ianbulovic ianbulovic marked this pull request as ready for review July 19, 2024 18:56
@tmills tmills merged commit 9f83b10 into Machine-Learning-for-Medical-Language:main Jul 23, 2024
9 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.

2 participants