Add MPS fallback for INT8 linear - #107
Conversation
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
🎉 Thank you for your contribution, we really appreciate it! 🎉 Like many open source projects, we require contributors to sign our Contributor License Agreement (CLA). A CLA makes the ownership of contributions explicit, so contributors and the project share a clear understanding of how the code can be used. By signing, you:
CLAs are standard practice across major open source projects including those under the Apache Software Foundation and the Linux Foundation. Ours is based on the Apache Software Foundation's CLA. Most importantly, it would enable us to relicense the project under a more permissive license in the future, giving the project and its community greater flexibility. ✍ To sign, please post a new comment on this PR with exactly the following text: ✍ I have read and agree to the Contributor License Agreement You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
Tested this branch on two Apple Silicon generations. It works on both, including the
Workload: MiniMax H3, Baseline without this PR, same machines, same workload: Fails in ~5 s at the first quantized linear. So this PR is the difference between "H3 INT8 To make sure nothing else was supplying an INT8 path, The M1 Max number is probably the interesting one, since it exercises the fallback rather Repro script (self-contained; backs up Separately, the two environment gotchas that cost us time and may explain other Mac reports: |
Summary
int8_linearon MPS through a floating-point fallback instead ofaten::_int_mmtorch._int_mmortorch.int8_mmWhy
PyTorch does not currently implement
aten::_int_mmfor MPS. The eager backend advertisesint8_linearon MPS, so Apple Silicon fails at the first quantized linear layer. This is the failure reported in #92.Handling the fallback at the
int8_linearlevel allows ComfyUI's normal BF16 execution path to remain on MPS. CPU and CUDA behavior are unchanged.Validation
PYTHONPATH=. .venv/bin/pytest tests/test_int8_mps.py— 6 passed on Apple M5 Max / MPSPYTHONPATH=. .venv/bin/pytest tests/test_int8.py tests/test_int8_mps.py— 42 passed, 64 skippedNotImplementedError: aten::_int_mm