Change8

Migrating to PyTorch v2.6.0

Version v2.6.0 introduces 1 breaking change. This guide details how to update your code.

Released: 1/29/2025

1
Breaking Changes
4
Migration Steps
6
Affected Symbols

⚠️ Check Your Code

If you use any of these symbols, you need to read this guide:

torch.loadtorch.compiletorch.compiler.set_stancetorch.library.triton_opAOTInductorDim.AUTO

Breaking Changes

Issue #1

The default value for the `weights_only` parameter in `torch.load` has been changed to `True` for security reasons, which breaks backward compatibility if you relied on the previous default.

Solution

If you intend to load tensors/models that contain non-weight data (like optimizer states or arbitrary Python objects), you must explicitly set `weights_only=False` when calling `torch.load`.

Migration Steps

  1. 1
    Review your usage of `torch.load`. If you are loading models or checkpoints that contain non-weight data (e.g., optimizer states, custom objects) and were relying on the previous default behavior, you must update your code.
  2. 2
    If you are using custom C++ or CUDA extensions and are building PyTorch binaries on Linux, ensure your build environment is configured to use CXX11_ABI=1 to align with the new standard binaries (Manylinux 2.28).
  3. 3
    If you are using PyTorch nightly builds or plan to upgrade to 2.6, be aware that official PyTorch packages will no longer be published on Conda channels. Plan to switch to alternative installation methods (e.g., pip, custom channels).
  4. 4
    Explore the new features like `torch.compiler.set_stance` if you need fine-grained control over `torch.compile` recompilation behavior, or the new AOTInductor packaging APIs if you use AOTInductor for deployment.

Release Summary

PyTorch 2.6 introduces Python 3.13 support for torch.compile, FP16 support for X86 CPUs, and new AOTInductor packaging APIs. It includes a significant security change making torch.load use weights_only=True by default and deprecates the official Anaconda channel.

Need More Details?

View the full release notes and all changes for PyTorch v2.6.0.

View Full Changelog