PyTorch's MPSProfiler fix restores torchvision builds with optional stream arg
A one-line tweak to MPSProfiler unblocks torchvision on Apple Silicon.
PyTorch's MPSProfiler just got a critical backward-compatibility fix via PR #193611, authored by kurtamohler and co-authored by Claude (Anthropic's AI). The issue: PR #192525 introduced a new `stream` argument to MPSProfiler functions without making it optional. That breaking change caused torchvision to fail building against PyTorch, as seen in their CI logs (job 94712872538). Most libraries that call profiler APIs didn't pass the new argument, so the non-optional parameter broke compilation.
The fix works by adding overloads to the profiler functions that omit the `stream` argument entirely. When callers don't specify a stream, PyTorch now automatically uses the current stream. Additionally, the `begin*` profiler functions (like `beginProfile` and `beginEvent`) will raise a warning if `stream` is not explicitly provided, nudging developers to be explicit while still maintaining backward compatibility. The PR was approved by Skylion007 and merged directly to the trunk branch of the pytorch/pytorch repo (which currently has 102k stars and 28.9k forks). This ensures that the massive ecosystem of libraries built on top of PyTorch—especially those targeting Apple's Metal Performance Shaders on macOS and iOS—can continue to compile without requiring immediate upstream changes.
- PR #193611 makes MPSProfiler's `stream` argument optional via new overloads
- Fixes build failures for torchvision and other libraries caused by PR #192525
- Default behavior uses the current stream; `begin*` functions warn if stream is omitted
Why It Matters
Prevents breaking the PyTorch ecosystem on Apple Silicon, keeping torchvision and other libraries buildable.