# pytorch/pytorch v2.13.0: PyTorch 2.13.0 Release — retained record

> Retained github record from github:pytorch/pytorch.

Canonical: https://highsignal.app/data/records/33fdacb1df13f811

[← sources](https://highsignal.app/data)


source: [github](https://highsignal.app/data/github) (github:pytorch/pytorch)  published 2026-07-08 17:39 ingested 2026-07-09 09:28

[original source ↗](https://github.com/pytorch/pytorch/releases/tag/v2.13.0)

## extract

# PyTorch 2.13.0 Release Notes

- [Highlights](https://highsignal.app/data/records/33fdacb1df13f811#highlights)
- [Backwards Incompatible Changes](https://highsignal.app/data/records/33fdacb1df13f811#backwards-incompatible-changes)
- [Deprecations](https://highsignal.app/data/records/33fdacb1df13f811#deprecations)
- [New Features](https://highsignal.app/data/records/33fdacb1df13f811#new-features)
- [Improvements](https://highsignal.app/data/records/33fdacb1df13f811#improvements)
- [Bug fixes](https://highsignal.app/data/records/33fdacb1df13f811#bug-fixes)
- [Performance](https://highsignal.app/data/records/33fdacb1df13f811#performance)
- [Documentation](https://highsignal.app/data/records/33fdacb1df13f811#documentation)
- [Developers](https://highsignal.app/data/records/33fdacb1df13f811#developers)

# Highlights

<table>
  <tr><td><strong>FlexAttention</strong> lands on Apple Silicon (MPS), with up to ~12x speedup over SDPA on sparse patterns, and gains a deterministic backward path on CUDA for reproducible gradient computation.</td></tr>
  <tr><td><strong>CuTeDSL "Native DSL" backend</strong> gives Inductor a second high-performance code path (alongside Triton) for key GPU operations, with faster compilation. [Prototype]</td></tr>
  <tr><td><strong><code>nn.LinearCrossEntropyLoss</code></strong> combines the final prediction and loss computation to cut peak GPU memory by up to 4x for large-vocabulary language model training.</td></tr>
  <tr><td><strong>torchcomms</strong>, a new communications backend for PyTorch Distributed, improves fault tolerance, scalability, and debuggability for large-cluster training.</td></tr>
  <tr><td><strong>FSDP2</strong> now overlaps reduce-scatter and all-gather communications via a dedicated process group (opt-in), increasing distributed training throughput.</td></tr>
  <tr><td><strong>Python 3.15 wheel support</strong> for PyTorch on Linux via the pytorch repository index, including builds compatible with free-threaded 3.15t.</td></tr>
  <tr><td><strong>Broader platform support</strong>: ROCm gains AOTriton 0.12b with native HIP CMake, Arm adds Armv9-A <code>torch.compile</code> targeting, and Intel XPU exposes new device telemetry APIs.</td></tr>
</table>

For more details about these highlighted features, you can look at the release blogpost. Below are the full release notes for this release.

# Tracked Regressions

### ROCm wheels break `torch.compile` on CPU in environments without a GPU

Running a `torch==2.13.0+rocm7.2` wheel in an environment where no GPU is available (`torch.cuda.is_available()` is `False`) breaks `torch.compile` on the CPU path: the first compile raises `RuntimeError: Can't detect vectorized ISA for CPU` ([#189194](https://github.com/pytorch/pytorch/issues/189194)). This is a regression from `torch==2.12.1+rocm7.2`, which compiles CPU code fine (detecting e.g. `VecAVX2`) in the same setup. The 2.13 ROCm wheel appears to rely on something present in the ROCm builder image to detect the CPU vectorized ISA, so it works when run on a ROCm image but fails on a plain CPU-only image.

Workaround: run the `+rocm` wheel on a ROCm image, or install a standard CPU/CUDA build for GPU-less environments.

# Backwards Incompatible Changes

- Stop building CPython 3.13t (free-threaded) binaries (#182951)

  Upstream `pypa/manylinux` removed CPython 3.13t (free-threaded) on 2026-05-07, because 3.13t
  was experimental and has been superseded by the now-non-experimental CPython 3.14t. As a result,
  PyTorch 2.13 no longer ships `cp313t` wheels (Linux, Triton, and related artifacts). Users on the
  free-threaded interpreter should move to Python 3.14t.

  PyTorch 2.12:
  ```bash
  # cp313t (free-threaded 3.13) wheels were available
  python3.13t -m pip install torch
  ```

  PyTorch 2.13:
  ```bash
  # Use free-threaded Python 3.14t instead
  python3.14t -m pip install torch
  ```

- Bare `PyObject` is no longer allowed in operator schemas (#184209)

  Bare `PyObject` was accidentally accepted in operator schema strings in
  PyTorch 2.12. This was undocumented and is now rejected, since `torch.compile`
  does not support arbitrary `PyObject` inputs to custom ops. If
  you parse or register a schema with a bare `PyObject` argument or return type,
  you will now get a schema parse error.

  PyTorch 2.12:
  ```python
  >>> from torch._C import parse_schema
  >>> parse_schema("foo(PyObject x) -> ()")  # accepted
  ```

  PyTorch 2.13:
  ```python
  >>> from torch._C import parse_schema
  >>> parse_schema("foo(PyObject x) -> ()")  # raises a schema parse error
  ```

- Remove Bazel build support (#180883)

  The Bazel build was never broadly adopted and still depended on the antiquated Bazel 6,
  while the wider ecosystem has since moved to Bazel 9. All Bazel build files and CI jobs have
  been removed. Users building PyTorch with Bazel should migrate to the supported CMake/`pip install`
  build flow.

  PyTorch 2.12:
  ```bash
  # Build PyTorch with Bazel
  bazel build //:torch
  ```

  PyTorch 2.13:
  ```bash
  # Bazel build files have been removed; build from source with pip instead
  pip install --no-build-isolation -e .
  ```

- Enforce C++20 minimum in header guards (#178150). In PyTorch 2.13, C++20 is now required to import PyTorch headers.

- `StorageImpl`'s built-in copy-on-write (COW) materialization is replaced by a pluggable materializer hook (#179063)

  `StorageImpl` no longer knows about COW directly. Its internal COW entry points
  `StorageImpl::is_cow()`, `StorageImpl::maybe_materialize_cow()`, and the friend
  `cow::materialize_cow_storage()` have been removed in favor of a single pluggable
  `MaterializeFn` hook (`void(*)(StorageImpl*)`) that a backend registers to run once,
  on the first mutable data-pointer access. COW is now just one consumer of this hook
  (`c10::impl::cow::materialize_cow`), and all COW behavior (lazy clone, refcounted
  shared data, copy-on-write) is unchanged. This also gives accelerator backends and
  eager-mode graph compilers a zero-fast-path-cost place to commit deferred allocations
  or materialize symbolic buffers on first mutation.

  This is a C++-only change. It affects out-of-tree backends/extensions that called the
  removed `StorageImpl` COW symbols directly; they will fail to compile against 2.13
  with errors such as `no member named 'is_cow' in 'c10::StorageImpl'`. Migrate to the
  new hook API (`set_materializer()` / `has_materializer()` / `clear_materializer()`).

  PyTorch 2.12:
  ```cpp
  // Detect a COW storage and force it to materialize.
  if (storage.is_cow()) {
    storage.maybe_materialize_cow();
  }
  ```

  PyTorch 2.13:
  ```cpp
  // Register a one-shot materializer; it runs on the next mutable-data access
  // and then clears itself. COW registers c10::impl::cow::materialize_cow this way.
  storage.set_materializer(&my_backend_materialize);  // void(StorageImpl*)

  // `has_materializer()` replaces `is_cow()` for "is a deferred materialization pending?"
  if (storage.has_materializer()) { /* ... */ }
  ```

- Convert `shared_ptr<Node>` to `intrusive_ptr<Node>` (#181139). This changes the signature of `Tensor::grad_fn`. Accesses to `Tensor.grad_fn()` should change from `std::shared_ptr<Node>` to `c10::intrusive_ptr<Node>`. Similarly, construction of a C++ autograd function should change:

  PyTorch 2.12:
  ```cpp
  std::shared_ptr<CustomCppNode> node(new CustomCppNode(), torch::autograd::deleteNode);
  ```

  PyTorch 2.13:
  ```cpp
  auto node = c10::make_intrusive<CustomCppNode>();
  ```

- The minimum supported NCCL version when building from source is now 2.23 (#186292)

  PyTorch now requires NCCL >= 2.23 at compile time, and the preprocessor/runtime gates that guarded NCCL features introduced in 2.23 or earlier have been removed. Users who build PyTorch from source against a system NCCL older than 2.23 will hit compile errors against the dropped gates. Upgrade the NCCL installation to >= 2.23 to build. The prebuilt PyTorch wheels already bundle a compatible NCCL, so pip/conda users are unaffected.

- Remove named tensors (#173895)

  The named tensor feature (a long-deprecated prototype) has been fully removed to reduce overhead and code bloat. All associated Python and C++ APIs are gone, including `Tensor.names`, `Tensor.rename()`, `Tensor.refine_names()`, `Tensor.align_to()`, `Tensor.align_as()`, `torch.align_tensors()`, the `names=` keyword on factory functions (e.g. `torch.zeros`, `torch.empty`, `torch.ones`), and the C++ `Dimname` / `DimnameList` APIs. Code that previously relied on named dimensions must track dimension order positionally and avoid usage of any of these now-removed APIs or op overloads.

- The `onednn::qconv2d_pointwise.binary` and `.binary_tensor` operators no longer alias their input but rather return fresh tensors. Previously these ops mutated the `qaccum` input buffer and returned it directly, violating the PyTorch invariant that custom operator outputs must not alias inputs. This silently bypassed aliasing checks via the old `-> Tensor(a!)` schema and would become a hard error in a future PyTorch version (as mentioned in #182063), so the schema and implementation were corrected to return a fresh output. Most users are unaffected, only code that calls these ops directly and relies on the in-place mutation of qaccum must now read the returned tensor instead. (#177171)

# Deprecations

- Custom operators that return an output aliasing one of their inputs are deprecated (#182063)

  When a custom operator returns an output that is the same tensor as (or otherwise aliases) one of its inputs under `torch.compile`, PyTorch now emits a `UserWarning` stating that this is deprecated and will become an error in a future version of PyTorch. Previously the warning stated the change would land in PyTorch 2.12; that timeline has been pushed back. To update your code, return a clone of the offending output instead of the input, or refactor the operator so it does not return the aliased tensor.

  Deprecated:
  ```python
  @torch.library.custom_op("mylib::foo", mutates_args=())
  def foo(x: torch.Tensor) -> torch.Tensor:
      return x  # output aliases the input -- deprecated
  ```

  Updated:
  ```python
  @torch.library.custom_op("mylib::foo", mutates_args=())
  def foo(x: torch.Tensor) -> torch.Tensor:
      return x.clone()  # return a clone instead
  ```

- Creating tensors with the quantized dtypes `quint8`, `qint8`, and `qint32` is now deprecated and emits a warning. This covers both Python and C++ call sites; see [#184982](https://github.com/pytorch/pytorch/issues/184982) for migration guidance (#184984)

  PyTorch 2.12:
  ```python
  >>> x = torch.quantize_per_tensor(torch.randn(3), 0.1, 0, torch.quint8)
  ```

  PyTorch 2.13:
  ```python
  >>> x = torch.quantize_per_tensor(torch.randn(3), 0.1, 0, torch.quint8)
  UserWarning: Creating tensors with quantized dtypes (quint8, qint8, qint32) is deprecated
  ```

- Rename distributed collective ops to the `_single` naming scheme and deprecate the old names (#186123, #186124, #186125, #186134, #186135, #186144)

  To align the public `torch.distributed` collective APIs with the naming used by torchcomms' `TorchCommBackend`, `all_gather_into_tensor` is renamed to `all_gather_single` and `reduce_scatter_tensor` to `reduce_scatter_single`. The previous names continue to work as thin wrappers that delegate to the new functions, but now emit a `FutureWarning`.

  PyTorch 2.12:
  ```python
  dist.all_gather_into_tensor(output, input)
  dist.reduce_scatter_tensor(output, input)
  ```

  PyTorch 2.13:
  ```python
  dist.all_gather_single(output, input)
  dist.reduce_scatter_single(output, input)
  ```

# New Features

## Python Frontend

- Add two new operator tags, `torch.Tag.inplace` and `torch.Tag.out`, that let an operator declare how it writes its result: `inplace` means it mutates a tensor in place, and `out` means it writes into a caller-provided output tensor. Native PyTorch operators are tagged automatically, and custom operators defined with `torch.library` can opt in by adding the tag. To be tagged `inplace`, an operator must take the tensor it mutates as its first positional argument (declared as `Tensor(a!)`, and the only mutable argument) and return that same tensor. Tagging a custom operator this way improves its behavior under `torch.compile`: `inplace` ops now go through `auto_functionalize`, so the reinplacing pass can analyze clones and skip unnecessary copies, and both `inplace` and `out` ops get their fake/meta kernels generated for free. See the [Python custom operators tutorial](https://docs.pytorch.org/tutorials/advanced/python_custom_ops.html) for how to author and tag custom operators. (#181100, #181099, #184199, #184200, #184201, #184202, #184203, #180851, #180852)
- Add `const_data_ptr()` Python binding to `torch.Tensor` for read-only data pointer access (#180382)
- Add an `abbr` property to `torch.dtype` that returns a dtype's short string abbreviation (e.g. `torch.float32.abbr` returns `"f32"`) (#177296)
- Allow positional arguments to be passed as keyword arguments to autograd custom `Function`s (#182206)
- Expose `rearrange` in the `torch.func` namespace for einops-style tensor reshaping (#173183)

## torch.nn

- Add `nn.LinearCrossEntropyLoss`, a fused linear-projection plus cross-entropy loss module that avoids materializing the full logits tensor (#181573, #185852, #172286, #186113)

## Autograd

- Add `torch.autograd.graph.region_activation_memory_budget` (#185979)
- Support passing gradient inputs as a `dict` to `torch.autograd.grad` and `torch.autograd.backward` (#178140)

## Distributed

- Add a registration API for symmetric memory arguments (`lib.register_symm_mem_args()`), letting operators (including out-of-tree ops) declare which arguments require symmetric-memory allocation (#173513)
- Remove `NCCLSymmetricMemory`'s explicit dependency on `ProcessGroupNCCL`, enabling symmetric memory to work with out-of-tree backends such as torchcomms (#184260)
- Support accessing the `ReduceOp.PREMUL_SUM` factor from Python when implementing process group backends in Python (#185863)
- Expose the NCCL 2.30 `maxP2pPeers` config binding (#181686)
- Add rocSHMEM Triton integration for symmetric memory on ROCm (#178658)

- Support passing extra keyword arguments to the loss function in pipeline schedules via a new `loss_kwargs` parameter to `step()`, enabling loss functions that require arguments beyond `(output, target)` (such as chunked cross-entropy needing token counts for scaling) (#181057)

## Distributed FSDP2

- Add `FSDPModule.set_separate_reduce_scatter_group` to give reduce-scatter its own NCCL communicator, enabling opt-in overlap of all-gather and reduce-scatter (#186335)
- Add `set_reduce_scatter_max_input_buffers` to keep multiple reduce-scatter input buffers in flight, so backward compute no longer stalls waiting to recycle a single reduce-scatter buffer (#186000)

## Profiler

- Profiler/Kineto now emits channel metadata on CUDA backends (#185968)

## Dynamo

- Add `torch.compiler.set_default_backend` to override the default `torch.compile` backend globally, so out-of-tree backend authors don't need to pass `backend=` at every call site (following the pattern of `torch.set_default_dtype`/`torch.set_default_device`). Explicit `backend=` arguments still take precedence (#178944)
- Add `torch.compile(f, isolate_recompiles=True)` to give each `torch.compile` call its own isolated cache bucket, preventing cross-compile interference in cache lookups and recompile-limit checks when multiple `torch.compile` calls target the same function (#178351)
- Add `register_multi_grad_hook` support to `@leaf_function`, allowing a backward hook to fire once per backward pass when all `requires_grad` inputs have their gradients computed (#179609)

## Inductor

- Add flash-decoding support to the CPU `FlexAttention` template (chosen when query length is 1) with a new configurable `PARTITION_SIZE` kernel option (#159835)
- Add Triton convolution backward kernels (input and weight gradients) as an autotuning backend in place of the ATen-only fallback (#178945)
- Add an Inductor FX pass (`decomp_comms`) that eliminates `all_gather` for Gram-matrix optimizer patterns (Muon/Shampoo) under FSDP, gated by `config.aten_distributed_optimizations.allow_comms_decompositions`, yielding 1.25-1.95x training speedups (#184370)

## Ahead-Of-Time Inductor (AOTI)

- Generated C shims for the AOTI stable ABI are now versioned and gated by `TORCH_TARGET_VERSION`, so shims introduced in newer releases are only exposed when the target version supports them (#181916)
- Triton CPU AOTI models now work end-to-end through the public `torch._inductor.aoti_compile_and_package` / `aoti_load_package` API, including packaging and loading of the multiple `.so` files emitted per kernel (#182251)
- Added stable C shim functions (`torch_exception_get_what`, `torch_exception_get_what_without_backtrace`, and `STABLE_TORCH_ERROR_CODE_CHECK`) so extensions built against the stable ABI can retrieve the original error message across the C API boundary (target version 2.13+) (#180135)
- Added a stable AOTI stream shim `aoti_torch_stream_native_handle` and `torch::stable::accelerator::Stream::nativeHandle()`, gated behind `TORCH_FEATURE_VERSION >= 2.13`, for retrieving a native stream handle from the stable ABI (#183930)

## Release Engineering

- Add Python 3.15 wheel builds across Linux (CPU/CUDA), Triton, ROCm, and XPU (#182954, #184600, #185409, #184829, #184891, #184906, #185094)

## CUDA

- Add `CUDAGraph.get_graph_data()` for graph topology introspection (#183165)
- Lightweight API to get private pool reserved memory bytes (#178240)

## MPS

- Add FlexAttention support for MPS (#182552, #186215)
- Add support for `torch.distributions.Dirichlet` on MPS by adding `_sample_dirichlet` and `_dirichlet_grad` Metal implementations (#185458, #185854)
- Add `grid_sampler_2d` backward support on MPS (#179756)
- Add `grid_sampler_3d` backward support on MPS (#179388)
- Add `lcm` support on MPS via a new Metal kernel (#186279)
- Add complex support to `c10/metal/reduction_utils.h` (#180708) and a complex->bool specialization (#185938)

## ROCm

- Enable external events in CUDA graphs (#178264)
- Enable GPU Address Sanitizer build (#183792, #176461)
- Improve Inductor GEMM search space performance using the Origami project (#172512)
- Use CMake native HIP language support, `enable_language(HIP)` (#180485)
- New Inductor benchmarker based on Torch Profiler (#175097)

## XPU

- Add XPU device telemetry APIs for temperature, frequency, power draw, engine utilization, memory bandwidth usage, and used device memory through `torch.xpu.*` (#181082, #183427, #183428, #183429, #183430, #183431)
- Add FP8 blockwise scaling support for `scaled_mm` on XPU (#173630, #176043)

# Improvements

## Python Frontend

- Make it possible to load safetensors with `torch.load` (#170592)
- Make `Storage.pin_memory` / `Storage.is_pinned` device-agnostic (#186223)
- Add `op_overloads` to `OpOverloadPacket` to enumerate an operator's overloads (#182993)

## torch.nn

- Expose `num_splits` in FlashAttention-2 and bump the flash-attention submodule (#179760)
- Support `linear_bias` in `linear_cross_entropy` on the reference and chunked paths (#185129, #185276)

## Optimizer

- Fix `SequentialLR` wrong learning rate initialization when `milestones` contain 0 (#185986)

## Autograd

- Implement autograd derivatives for `torch.nextafter` (#148820)
- Add `torch.autograd.enforce_grad_layout_policy` to control the memory layout policy for accumulated gradients (#180552)

## Distributed

- When TorchComms is enabled, route `new_group` through `split_group` for subgroup creation, raising `NotImplementedError` for arguments `split_group` cannot honor (e.g. `use_local_synchronization=True`, `sort_ranks=False`) instead of silently falling back (#185416)
- Delegate `dist.new_group` to custom process group subclasses (#184262)
- Surface started-work metadata in NCCL watchdog timeouts (#183656)
- Add a health check endpoint to the distributed debug server (#17932

## retained text (truncated)



```
# PyTorch 2.13.0 Release Notes

- [Highlights](#highlights)
- [Backwards Incompatible Changes](#backwards-incompatible-changes)
- [Deprecations](#deprecations)
- [New Features](#new-features)
- [Improvements](#improvements)
- [Bug fixes](#bug-fixes)
- [Performance](#performance)
- [Documentation](#documentation)
- [Developers](#developers)

# Highlights

<table>
  <tr><td><strong>FlexAttention</strong> lands on Apple Silicon (MPS), with up to ~12x speedup over SDPA on sparse patterns, and gains a deterministic backward path on CUDA for reproducible gradient computation.</td></tr>
  <tr><td><strong>CuTeDSL "Native DSL" backend</strong> gives Inductor a second high-performance code path (alongside Triton) for key GPU operations, with faster compilation. [Prototype]</td></tr>
  <tr><td><strong><code>nn.LinearCrossEntropyLoss</code></strong> combines the final prediction and loss computation to cut peak GPU memory by up to 4x for large-vocabulary language model training.</td></tr>
  <tr><td><strong>torchcomms</strong>, a new communications backend for PyTorch Distributed, improves fault tolerance, scalability, and debuggability for large-cluster training.</td></tr>
  <tr><td><strong>FSDP2</strong> now overlaps reduce-scatter and all-gather communications via a dedicated process group (opt-in), increasing distributed training throughput.</td></tr>
  <tr><td><strong>Python 3.15 wheel support</strong> for PyTorch on Linux via the pytorch repository index, including builds compatible with free-threaded 3.15t.</td></tr>
  <tr><td><strong>Broader platform support</strong>: ROCm gains AOTriton 0.12b with native HIP CMake, Arm adds Armv9-A <code>torch.compile</code> targeting, and Intel XPU exposes new device telemetry APIs.</td></tr>
</table>

For more details about these highlighted features, you can look at the release blogpost. Below are the full release notes for this release.

# Tracked Regressions

### ROCm wheels break `torch.compile` on CPU in environments without a GPU

Running a `torch==2.13.0+rocm7.2` wheel in an environment where no GPU is available (`torch.cuda.is_available()` is `False`) breaks `torch.compile` on the CPU path: the first compile raises `RuntimeError: Can't detect vectorized ISA for CPU` ([#189194](https://github.com/pytorch/pytorch/issues/189194)). This is a regression from `torch==2.12.1+rocm7.2`, which compiles CPU code fine (detecting e.g. `VecAVX2`) in the same setup. The 2.13 ROCm wheel appears to rely on something present in the ROCm builder image to detect the CPU vectorized ISA, so it works when run on a ROCm image but fails on a plain CPU-only image.

Workaround: run the `+rocm` wheel on a ROCm image, or install a standard CPU/CUDA build for GPU-less environments.

# Backwards Incompatible Changes

- Stop building CPython 3.13t (free-threaded) binaries (#182951)

  Upstream `pypa/manylinux` removed CPython 3.13t (free-threaded) on 2026-05-07, because 3.13t
  was experimental and has been superseded by the now-non-experimental CPython 3.14t. As a result,
  PyTorch 2.13 no longer ships `cp313t` wheels (Linux, Triton, and related artifacts). Users on the
  free-threaded interpreter should move to Python 3.14t.

  PyTorch 2.12:
  ```bash
  # cp313t (free-threaded 3.13) wheels were available
  python3.13t -m pip install torch
  ```

  PyTorch 2.13:
  ```bash
  # Use free-threaded Python 3.14t instead
  python3.14t -m pip install torch
  ```

- Bare `PyObject` is no longer allowed in operator schemas (#184209)

  Bare `PyObject` was accidentally accepted in operator schema strings in
  PyTorch 2.12. This was undocumented and is now rejected, since `torch.compile`
  does not support arbitrary `PyObject` inputs to custom ops. If
  you parse or register a schema with a bare `PyObject` argument or return type,
  you will now get a schema parse error.

  PyTorch 2.12:
  ```python
  >>> from torch._C import parse_schema
  >>> parse_schema("foo(PyObject x) -> ()")  # accepted
  ```

  PyTorch 2.13:
  ```python
  >>> from torch._C import parse_schema
  >>> parse_schema("foo(PyObject x) -> ()")  # raises a schema parse error
  ```

- Remove Bazel build support (#180883)

  The Bazel build was never broadly adopted and still depended on the antiquated Bazel 6,
  while the wider ecosystem has since moved to Bazel 9. All Bazel build files and CI jobs have
  been removed. Users building PyTorch with Bazel should migrate to the supported CMake/`pip install`
  build flow.

  PyTorch 2.12:
  ```bash
  # Build PyTorch with Bazel
  bazel build //:torch
  ```

  PyTorch 2.13:
  ```bash
  # Bazel build files have been removed; build from source with pip instead
  pip install --no-build-isolation -e .
  ```

- Enforce C++20 minimum in header guards (#178150). In PyTorch 2.13, C++20 is now required to import PyTorch headers.

- `StorageImpl`'s built-in copy-on-write (COW) materialization is replaced by a pluggable materializer hook (#179063)

  `StorageImpl` no longer knows about COW directly. Its internal COW entry points
  `StorageImpl::is_cow()`, `StorageImpl::maybe_materialize_cow()`, and the friend
  `cow::materialize_cow_storage()` have been removed in favor of a single pluggable
  `MaterializeFn` hook (`void(*)(StorageImpl*)`) that a backend registers to run once,
  on the first mutable data-pointer access. COW is now just one consumer of this hook
  (`c10::impl::cow::materialize_cow`), and all COW behavior (lazy clone, refcounted
  shared data, copy-on-write) is unchanged. This also gives accelerator backends and
  eager-mode graph compilers a zero-fast-path-cost place to commit deferred allocations
  or materialize symbolic buffers on first mutation.

  This is a C++-only change. It affects out-of-tree backends/extensions that called the
  removed `StorageImpl` COW symbols directly; they will fail to compile against 2.13
  with errors such as `no member named 'is_cow' in 'c10::StorageImpl'`. Migrate to the
  new hook API (`set_materializer()` / `has_materializer()` / `clear_materializer()`).

  PyTorch 2.12:
  ```cpp
  // Detect a COW storage and force it to materialize.
  if (storage.is_cow()) {
    storage.maybe_materialize_cow();
  }
  ```

  PyTorch 2.13:
  ```cpp
  // Register a one-shot materializer; it runs on the next mutable-data access
  // and then clears itself. COW registers c10::impl::cow::materialize_cow this way.
  storage.set_materializer(&my_backend_materialize);  // void(StorageImpl*)

  // `has_materializer()` replaces `is_cow()` for "is a deferred materialization pending?"
  if (storage.has_materializer()) { /* ... */ }
  ```

- Convert `shared_ptr<Node>` to `intrusive_ptr<Node>` (#181139). This changes the signature of `Tensor::grad_fn`. Accesses to `Tensor.grad_fn()` should change from `std::shared_ptr<Node>` to `c10::intrusive_ptr<Node>`. Similarly, construction of a C++ autograd function should change:

  PyTorch 2.12:
  ```cpp
  std::shared_ptr<CustomCppNode> node(new CustomCppNode(), torch::autograd::deleteNode);
  ```

  PyTorch 2.13:
  ```cpp
  auto node = c10::make_intrusive<CustomCppNode>();
  ```

- The minimum supported NCCL version when building from source is now 2.23 (#186292)

  PyTorch now requires NCCL >= 2.23 at compile time, and the preprocessor/runtime gates that guarded NCCL features introduced in 2.23 or earlier have been removed. Users who build PyTorch from source against a system NCCL older than 2.23 will hit compile errors against the dropped gates. Upgrade the NCCL installation to >= 2.23 to build. The prebuilt PyTorch wheels already bundle a compatible NCCL, so pip/conda users are unaffected.

- Remove named tensors (#173895)

  The named tensor feature (a long-deprecated prototype) has been fully removed to reduce overhead and code bloat. All associated Python and C++ APIs are gone, including `Tensor.names`, `Tensor.rename()`, `Tensor.refine_names()`, `Tensor.align_to()`, `Tensor.align_as()`, `torch.align_tensors()`, the `names=` keyword on factory functions (e.g. `torch.zeros`, `torch.empty`, `torch.ones`), and the C++ `Dimname` / `DimnameList` APIs. Code that previously relied on named dimensions must track dimension order positionally and avoid usage of any of these now-removed APIs or op overloads.

- The `onednn::qconv2d_pointwise.binary` and `.binary_tensor` operators no longer alias their input but rather return fresh tensors. Previously these ops mutated the `qaccum` input buffer and returned it directly, violating the PyTorch invariant that custom operator outputs must not alias inputs. This silently bypassed aliasing checks via the old `-> Tensor(a!)` schema and would become a hard error in a future PyTorch version (as mentioned in #182063), so the schema and implementation were corrected to return a fresh output. Most users are unaffected, only code that calls these ops directly and relies on the in-place mutation of qaccum must now read the returned tensor instead. (#177171)

# Deprecations

- Custom operators that return an output aliasing one of their inputs are deprecated (#182063)

  When a custom operator returns an output that is the same tensor as (or otherwise aliases) one of its inputs under `torch.compile`, PyTorch now emits a `UserWarning` stating that this is deprecated and will become an error in a future version of PyTorch. Previously the warning stated the change would land in PyTorch 2.12; that timeline has been pushed back. To update your code, return a clone of the offending output instead of the input, or refactor the operator so it does not return the aliased tensor.

  Deprecated:
  ```python
  @torch.library.custom_op("mylib::foo", mutates_args=())
  def foo(x: torch.Tensor) -> torch.Tensor:
      return x  # output aliases the input -- deprecated
  ```

  Updated:
  ```python
  @torch.library.custom_op("mylib::foo", mutates_args=())
  def foo(x: torch.Tensor) -> torch.Tensor:
      return x.clone()  # return a clone instead
  ```

- Creating tensors with the quantized dtypes `quint8`, `qint8`, and `qint32` is now deprecated and emits a warning. This covers both Python and C++ call sites; see [#184982](https://github.com/pytorch/pytorch/issues/184982) for migration guidance (#184984)

  PyTorch 2.12:
  ```python
  >>> x = torch.quantize_per_tensor(torch.randn(3), 0.1, 0, torch.quint8)
  ```

  PyTorch 2.13:
  ```python
  >>> x = torch.quantize_per_tensor(torch.randn(3), 0.1, 0, torch.quint8)
  UserWarning: Creating tensors with quantized dtypes (quint8, qint8, qint32) is deprecated
  ```

- Rename distributed collective ops to the `_single` naming scheme and deprecate the old names (#186123, #186124, #186125, #186134, #186135, #186144)

  To align the public `torch.distributed` collective APIs with the naming used by torchcomms' `TorchCommBackend`, `all_gather_into_tensor` is renamed to `all_gather_single` and `reduce_scatter_tensor` to `reduce_scatter_single`. The previous names continue to work as thin wrappers that delegate to the new functions, but now emit a `FutureWarning`.

  PyTorch 2.12:
  ```python
  dist.all_gather_into_tensor(output, input)
  dist.reduce_scatter_tensor(output, input)
  ```

  PyTorch 2.13:
  ```python
  dist.all_gather_single(output, input)
  dist.reduce_scatter_single(output, input)
  ```

# New Features

## Python Frontend

- Add two new operator tags, `torch.Tag.inplace` and `torch.Tag.out`, that let an operator declare how it writes its result: `inplace` means it mutates a tensor in place, and `out` means it writes into a caller-provided output tensor. Native PyTorch operators are tagged automatically, and custom operators defined with `torch.library` can opt in by adding the tag. To be tagged `inplace`, an operator must take the tensor it mutates as its first positional argument (declared as `Tensor(a!)`, and the only mutable argument) and re
```



document fetched 2026-07-15 07:55
