Migrating to PyTorch v2.9.0
Version v2.9.0 introduces 6 breaking changes. This guide details how to update your code.
Released: 10/15/2025
⚠️ Check Your Code
If you use any of these symbols, you need to read this guide:
torch.libraryTORCH_LIBRARYtorch.cattorch.onnx.exporttorch.utils.dlpackDLDeviceTypetorch.compiletorch.export.exportexported_program.moduletorch.library.opcheckBreaking Changes
●Issue #1
The minimum supported Python version has been raised to 3.10.
✓Solution
Ensure your environment uses Python 3.10 or newer to run PyTorch 2.9.0.
●Issue #2
Custom operators registered via torch.library or TORCH_LIBRARY are no longer allowed to return Tensors that share storage with input tensors, which previously resulted in undefined behavior.
✓Solution
For custom operators where the output shares storage with an input, add a .clone() to the output tensor before returning it. If you have dynamic behavior (sometimes in-place, sometimes out-of-place), split the logic into two distinct custom operators.
●Issue #3
PyTorch MPS (Metal Performance Shaders) support now requires macOS 14 or later.
✓Solution
If you are using MPS on macOS Ventura (pre-14), you must avoid updating to PyTorch 2.9.0 or newer, or upgrade your operating system to macOS 14+.
●Issue #4
The `torch.utils.dlpack` API has been updated following the DLPack 1.0 upgrade, affecting objects like `DLDeviceType`.
✓Solution
Review the specific changes in the DLPack 1.0 release notes and update any usage of `torch.utils.dlpack` objects accordingly.
●Issue #5
`torch.cat` now raises specific errors (`ValueError`, `IndexError`, or `TypeError`) instead of a generic `RuntimeError` for invalid operations.
✓Solution
If your code was catching generic `RuntimeError` for `torch.cat` failures, update your exception handling to catch the more specific error types if necessary.
●Issue #6
The default behavior for `torch.onnx.export(...)` has changed to use the `torch.export` pipeline (`dynamo=True`) instead of the legacy TorchScript exporter.
✓Solution
If you rely on the legacy exporter behavior or encounter graph capture errors with the new exporter, explicitly set `dynamo=False` in your `torch.onnx.export` call. Otherwise, no action is required to benefit from the improved fidelity.
Migration Steps
- 1Verify that your Python environment is running version 3.10 or higher. If not, upgrade Python.
- 2If you are using custom operators registered with torch.library, audit them to ensure no output tensor shares storage with an input tensor. Add .clone() to any offending outputs.
- 3If you are using PyTorch MPS, confirm your macOS version is 14 or later. If on an older version, you must remain on PyTorch < 2.9.0 or upgrade macOS.
- 4If you utilize `torch.utils.dlpack`, check for necessary updates based on the DLPack 1.0 specification.
- 5Review any exception handling around calls to `torch.cat` and update caught error types from generic `RuntimeError` to specific types like `ValueError` if needed.
- 6If you use `torch.onnx.export` without specifying the `dynamo` argument, test your exports, as they now default to using the Dynamo-based exporter. Add `dynamo=False` if you need to force the legacy behavior.
Release Summary
PyTorch 2.9.0 introduces Python 3.10 as the minimum requirement, defaults the ONNX exporter to the Dynamo-based pipeline, and adds support for symmetric memory and FlexAttention on new hardware.
Need More Details?
View the full release notes and all changes for PyTorch v2.9.0.
View Full Changelog