Migrating to PyTorch v2.7.1
Version v2.7.1 introduces 2 breaking changes. This guide details how to update your code.
Released: 6/4/2025
⚠️ Check Your Code
If you use any of these symbols, you need to read this guide:
torch.compiletorch.autocastflex_attentiontorch.distributed.barriertorch.mkldnn_max_pool2dtorch.nn.functional.grid_sampletorch.profilertensor.viewCompositeImplicitAutogradBreaking Changes
●Issue #1
If you were relying on specific error logging behavior within `torch.compile`, the logging implementation has been improved, which might change the format or verbosity of logged errors.
✓Solution
Review any custom error handling or logging configurations around `torch.compile` calls and adjust them if necessary based on the new logging output.
●Issue #2
If you were using mutable custom operators with `torch.compile`, they are now marked as cacheable, which could potentially alter caching behavior if the mutability was previously causing issues or unexpected re-compilations.
✓Solution
Verify that marking mutable custom operators as cacheable does not introduce correctness issues in your compiled graphs. If issues arise, you might need to refactor the custom operator to be immutable or use alternative compilation strategies.
Migration Steps
- 1Update your PyTorch installation to the new version.
- 2If you are using HuggingFace LLM models with `torch.compile`, test your workloads thoroughly to benefit from reduced cudagraph re-recording and improved compatibility.
- 3If you encounter crashes when using `torch.autocast` alongside `torch.compile`, ensure your environment is updated, as a fix for exceptions raised inside `autocast` has been implemented.
- 4If you use `einops`, ensure you are using a version compatible with this release, or be aware that a workaround for older versions has been implemented.
- 5If you are using distributed training, monitor for hangs or unexpected behavior, especially when using non-blocking APIs with NCCL 2.26, as workarounds have been added.
- 6If you are developing on macOS with Clang 17, ensure your build environment is correctly configured, as compilation errors have been resolved.
- 7If you observe incorrect results on MPS devices when using binary operations involving wrapped scalars, test your MPS workloads.
- 8If you are using ONNX export/import, verify that CompositeImplicitAutograd ops are correctly preserved during decomposition.
Release Summary
This maintenance release focuses on fixing regressions and silent correctness issues across torch.compile, Distributed, and Flex Attention, while also improving wheel sizes and platform-specific compatibility for MacOS, Windows, and XPU.
Need More Details?
View the full release notes and all changes for PyTorch v2.7.1.
View Full Changelog