MPS in PyTorch 2.15
PyTorch 2.15 adds FP8 (float8_e4m3fn) tensors and scaled_mm on Apple's MPS backend and replaces many MPSGraph paths with dedicated Metal kernels. A native GPU grouped matmul with a small-group decode kernel makes MoE decoding 5–6.5× faster than 2.14 (Qwen3.6-35B-A3B goes from 9.4 to 61.3 tokens/s on an M3 Ultra). GEMV-backed F.linear gives a 1.23× geomean speedup on decode shapes, and Metal softmax is about 8× faster over large vocabularies. Moving constant padding to Metal cuts Wan2.2 tiled VAE decode peak driver memory from 270 GiB to 8 GiB and fixes Qwen-Image VAE corruption. The release also adds complex LU and triangular solves, Python-level MPS streams, and requires macOS 15 and Python 3.11. Previewed 2.16 work includes all-Metal attention and periodic command-buffer commits that add up to 19% decode throughput.
Related posts
- Hugging Face ❤️ TorchTPU: TPUs, Natively
Hugging Face mediumAdeptTorchTPU is a native PyTorch backend that makes TPU an ordinary device, replacing the lazy-tensor torch_xla path and making Optimum TPU unnecessary for running Hugging Face models. Transformers loads models with device_map="tpu", and Diffusers pipelines run with pipe.to("tpu"), optionally with torch.compile and tensor parallelism across chips. Pallas kernels from the Kernels Hub, such as a Tokamax ragged-dot MoE kernel, speed up batch-64 decoding by 21.5× on Qwen3-30B-A3B and 12.8× on Gemma 4 26B-A4B. Of the Transformers tests that run on TPU, 96.5% pass, and 34 TorchTPU issues have been reported so far, 19 of them fixed.
- Introducing 🤗 Accelerate
Hugging Face mediumAdept🤗 Accelerate lets PyTorch users keep their own training loops while running the same script on CPU, single or multi-GPU, multi-node, TPU, and with mixed precision, by adding about five lines: an Accelerator object, accelerator.prepare() for model/optimizer/dataloader, and accelerator.backward(). prepare() wraps the model in the right container such as DistributedDataParallel, wraps the optimizer for mixed precision, and shards any sampler's indices per process using synchronized RNGs instead of requiring DistributedSampler. Distributed evaluation uses accelerator.gather plus truncation of padded batches. An `accelerate config` / `accelerate launch` CLI replaces torch.distributed.launch arguments and can target SageMaker.
- Profiling in PyTorch (Part 3): Attention is all you profile
Hugging Face mediumAdeptProfiling attention variants in PyTorch on an A100 shows how each implementation appears in profiler traces. Naive attention launches matmul, mul, masking, softmax and matmul kernels plus a hidden Memcpy from out-of-place masked_fill; switching to in-place masked_fill_ removes that kernel under no_grad. SDPA's math backend turns out 3.7x slower than the naive version: it launches 20 kernels, upcasts to FP32 sgemm on CUDA cores instead of bf16 Tensor Cores, rebuilds the causal mask every call, and uses a NaN-safe softmax. Fused backends such as the efficient (CUTLASS fmha) backend collapse attention into a single kernel, and kernel names can be read to tell which hardware path each backend takes.
- Accelerate 1.0.0
Hugging Face mediumAdeptHugging Face has published the first release candidates for Accelerate 1.0.0. The library has grown from a thin multi-GPU/TPU training-loop wrapper into the base layer for transformers, diffusers, peft and trl, covering six accelerator types, a launch CLI and big-model inference via device_map="auto". Before 1.0 the team added FP8 support through MS-AMP and TransformerEngine, multi-model DeepSpeed orchestration, torch.compile for big model inference, torch.distributed.pipelining and StatefulDataLoader. Migration notes list the breaking deprecations, such as moving dataloader flags into DataLoaderConfiguration, using AutocastKwargs and renaming is_tpu_available to is_torch_xla_available.
- Learn the Hugging Face Kernel Hub in 5 Minutes
Hugging Face mediumAdeptHugging Face's Kernel Hub and `kernels` library let PyTorch code download pre-compiled, optimized GPU kernels such as FlashAttention, activations, RMSNorm and quantization kernels with a single `get_kernel` call. The library matches the binary to the installed Python, PyTorch and CUDA versions, which avoids source builds that for FlashAttention can need about 96 GB of RAM and hours of compilation. The walkthrough checks a fast GELU kernel against PyTorch and swaps a Triton LlamaRMSNorm into a simple model with the `use_kernel_forward_from_hub` decorator. It then benchmarks the kernel against a plain PyTorch RMSNorm using CUDA events.