PyTorch migrates upsampling ops to Metal kernels, fixes MPS bug
Metal kernels replace MPSGraph for nearest upsampling, fixing a latent correctness issue...
PyTorch's latest commit to its MPS (Metal Performance Shaders) backend replaces the MPSGraph implementation of 1D/2D nearest and nearest-exact forward upsampling with custom Metal kernels. This migration fixes a latent correctness bug in the MPSGraph path and unifies the host-side dispatch logic: a single templated launcher now drives every Metal upsample kernel, while a new UpsampleParams struct supplies geometry for all ranks. The change collapses previously duplicated per-rank dispatch overloads, streamlining the codebase. The linear, bilinear, bicubic, and 3D forward paths were already running on Metal, so this completes the transition for all forward upsampling operations.
Interestingly, the backward pass remains on MPSGraph. The developers intentionally kept it there because MPSGraph's fused gradient kernel performs several times faster than a naive Metal gather implementation. This decision preserves performance where it matters most. The pull request (#186989) was approved by PyTorch maintainers and co-authored by Claude, Anthropic's AI coding assistant. For developers using PyTorch on Apple Silicon, this means more reliable and potentially faster upsampling during model inference, while training gradients still benefit from MPSGraph's optimised backward kernels.
- Migrates 1D/2D nearest and nearest-exact forward upsampling from MPSGraph to custom Metal kernels
- Fixes a latent MPSGraph correctness bug in the upsampling path
- Unifies host-side dispatch with a single templated launcher and UpsampleParams, eliminating duplicated per-rank overloads
- Backward gradient is left on MPSGraph because its fused kernel is several times faster than a naive Metal gather
Why It Matters
Improves correctness and performance of upsampling on Apple Silicon for PyTorch inference workloads.