Torchserve M1 support detailed plan
🚀 The feature
Update Jan 31 2024 - we should speed this up PyTorch on MacOS x86 is being deprecated https://github.com/pytorch/pytorch/issues/114602
Officially support torchserve on M1-M2 mac hardware. A bunch of people have asked for this, if you're interested please either upvote or volunteer to do this work, would be happy to review
We have 6 issues of people asking for M1 support https://github.com/pytorch/serve/labels/m1
Motivation, pitch
I've seen a bunch of issues asking for this but we haven't managed to prioritize it yet so thought I'd highlight what needs to be done to support this. There's two components to this work, most of this work is parallelizable with the exception of the official release script so feel free to pick up an issue and work on it
Code changes
- [ ] In our base handler check if mps is available and if it is push the model and its inputs to an mps device for added hardware acceleration https://github.com/pytorch/serve/blob/master/ts/torch_handler/base_handler.py
- [ ] There will be many cases where mps might have some unsupported feature in which case it should be possible to also hardwire in config cpu fallback by putting in a flag in a model config like this one as an example https://github.com/pytorch/serve/blob/master/examples/large_models/inferentia2/model-config.yaml check out how this config is read and parsed in the
base_handler.py - [ ] Showcase an example of running llama2 at bs=1
Build changes
- [x] Ensure
ts_scripts/install_dependencies.pyinstalls the right binaries for M1 - [x] Ensure
setup.pyworks on M1 - [x] Ensure that conda binaries work with osx-arm64
- [x] Change our CI job to run tests on M1 and deprecate the x86 version (Not deprecated yet simply added M1 compatibility)
- [x] Ensure build scripts in
binariesstill work for M1 for both pip and conda - [ ] In our
official-release.yamlgithub action we should deprecate pushing regular mac binaries and instead move to using ARM M1 binaries - [ ] Update our docker build scripts to also work with M1 https://github.com/pytorch/serve/issues/1363#issuecomment-1112769676
cc @agunapal @mreso @malfet
Alternatives
No response
Additional context
No response
did it ok?i am waiting ....
Hi @Talbot3 What issues are you still facing?
Hi, just FYI, ./build_image.sh builds a working docker image just fine on Macbook Air M2 running Asahi Linux (Ubuntu 23.10)
Hi @Talbot3 What issues are you still facing?
https://github.com/pytorch/serve/issues/1363 I just want check pytorch serve container on my device (mac m1) can run