Apple's New Chips Can Now Run a Faster Type of AI
This could make AI on your Mac faster and more efficient.
Compiling anything that touched fp8 on MPS used to fail with a KeyError: torch.float8_e4m3fn — because DTYPE_TO_METAL had no fp8 entries at all. This PR fixes that by mapping fp8 types to the existing c10::metal fp8 structs and computing in float32, just like half/bf16.
Two Metal quirks needed special handling: the structs' operator float() can't be called on constant inputs, so loads go through c10::metal::cast_to<float>, and as_type<> rejects the structs, so bitcasts use the detail encoders. The change enables TestFP8Types and TestE8M0ToFloat on MPS, while skipping e5m2 (which eager MPS lacks) and _scaled_mm v1.
Authored with Claude Code. Pull Request resolved: #206056, approved by Isalia20, with ghstack dependencies #205864, #205690, #205758, and #205759.
- Apple's M-series chips now support float8, a compressed number format that speeds up AI calculations.
- This means AI apps on Macs can run faster and use less battery, but only on newer models.
- Some advanced AI features still won't work, so it's not a complete solution.
Why It Matters
Faster, more efficient AI on Macs means better performance and longer battery life for everyday tasks.