serve icon indicating copy to clipboard operation
serve copied to clipboard

Torchserve M1 support detailed plan

Open msaroufim opened this issue 2 years ago • 4 comments

🚀 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.py installs the right binaries for M1
  • [x] Ensure setup.py works 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 binaries still work for M1 for both pip and conda
  • [ ] In our official-release.yaml github 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

msaroufim avatar Aug 30 '23 18:08 msaroufim

did it ok?i am waiting ....

Talbot3 avatar Feb 27 '24 07:02 Talbot3

Hi @Talbot3 What issues are you still facing?

udaij12 avatar Mar 15 '24 20:03 udaij12

Hi, just FYI, ./build_image.sh builds a working docker image just fine on Macbook Air M2 running Asahi Linux (Ubuntu 23.10)

VladimirKadlec avatar Mar 19 '24 09:03 VladimirKadlec

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

Talbot3 avatar Mar 21 '24 02:03 Talbot3