Developer Tools

PyTorch fixes MPS bias drop bug for vector inputs on macOS

A silent bias drop in F.linear for 1D inputs on Apple Silicon is now patched.

Deep Dive

PyTorch has patched a subtle but critical bug in its Metal Performance Shaders (MPS) backend that caused the `F.linear` function to silently drop the bias term when processing vector-shaped inputs on certain macOS versions. The issue, tracked as GitHub issue #188438, specifically affected macOS 26 (likely an internal build or early version of macOS 14 Sonoma). The matmul (matrix multiplication) portion of the linear operation worked correctly, but the subsequent bias addition was silently skipped, leading to incorrect outputs without any error message.

The fix, submitted by contributor jhavukainen in PR #188619, decomposes the fused matmul+bias addition operation on the problematic macOS 26 platform. This separation ensures the bias is correctly added regardless of input shape. The maintainers verified that the underlying issue is resolved in the macOS 27 beta. To prevent regression, the PR also includes a dedicated test case for vector-shaped inputs.

This bug could have silently corrupted model outputs for any PyTorch user on Apple Silicon Macs running the affected macOS version, particularly during inference or training with single-sample batches. The fix is now merged into PyTorch's trunk and will be included in the next stable release. Users on current builds should update their PyTorch or work around it by unsqueezing inputs to 2D.

Key Points
  • Bug caused F.linear to drop bias for vector (1D) inputs on MPS backend with macOS 26.
  • Fix decomposes matmul+bias add on affected macOS version; macOS 27 beta has the correct behavior.
  • Regression test added to prevent future breakage of the bias handling.

Why It Matters

Silent bias corruption in PyTorch's MPS backend could break models on Apple Silicon — now fixed.

📬 Get the top 10 AI stories daily