Unclaimed project
Are you a maintainer of pytorch? Claim this project to take control of your public changelog and roadmap.
Changelog
Tensors and Dynamic neural networks in Python with strong GPU acceleration
Last updated 27 days ago
A feature-rich command-line audio/video downloader
Python tool for converting files and office documents to Markdown.
:octocat: 分享 GitHub 上有趣、入门级的开源项目。Share interesting, entry-level open source projects on GitHub.
AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.
| Unstable (API-Unstable) |
| Updates to the stable libtorch ABI for third-party C++/CUDA extensions |
| Symmetric memory that enables easy programming of multi-GPU kernels |
| The ability to arbitrarily toggle error or resume on graph breaks in torch.compile |
| Expanded wheel variant support to include ROCm, XPU and CUDA 13 |
| FlexAttention enablement on Intel GPUs |
| Flash decoding optimization based on FlexAttention on X86 CPU |
| ARM Platform improvements and optimizations |
| Enablement of Linux aarch64 binary wheel builds across all supported CUDA versions |
For more details about these highlighted features, you can look at the release blogpost. Below are the full release notes for this release.
The minimum version of Python required for PyTorch 2.9.0 is 3.10. We also have 3.14 and 3.14t available as preview with this release.
This is a reminder that outputs of PyTorch custom operators (that are registered using the torch.library or TORCH_LIBRARY APIs) are not allowed to return Tensors that share storage with input tensors. The violation of this condition leads to undefined behavior: sometimes the result will be correct, sometimes it will be garbage.
After #163227, custom operators that violated this condition that previously returned correct results under torch.compile may now return silently incorrect results under torch.compile. Because this is changing the behavior of undefined behavior, we do not consider this to be a bug, but we are still documenting it in this section as a "potentially unexpected behavior change".
This is one of the conditions checked for by torch.library.opcheck and is mentioned in The Custom Operators Manual
Outputs of PyTorch custom operators are not allowed to return Tensors that share storage with input tensors
For example, the following two custom operators are not valid custom operators:
@torch.library.custom_op("mylib::foo", mutates_args=())
def foo(x: torch.Tensor) -> torch.Tensor:
# the result of `foo` must not directly be an input to foo.
return x
@torch.library.custom_op("mylib::bar", mutates_args=())
def bar(x: torch.Tensor) -> torch.Tensor:
# the result of bar must not be a view of an input of bar
return x.view(-1)
The easiest workaround is to add an extra .clone() to the outputs:
@torch.library.custom_op("mylib::foo", mutates_args=())
def foo(x: torch.Tensor) -> torch.Tensor:
return x.clone()
@torch.library.custom_op("mylib::bar", mutates_args=())
def bar(x: torch.Tensor) -> torch.Tensor:
return x.view(-1).clone()
A common way to get into this situation is for a user to want to create a custom operator that sometimes mutates the input in-place and sometimes returns a new Tensor, like in the following example.
@torch.library.custom_op("mylib::baz", mutates_args=["x"])
def baz(x: torch.Tensor) -> torch.Tensor:
if inplace:
x.sin_()
return x
else:
return x.sin()
This dynamism is not supported and leads to undefined behavior. The workaround is to split the custom operator into two custom operators, one that always mutates the input in-place, and another that always returns a new Tensor.
@torch.library.custom_op("mylib::baz_outplace", mutates_args=())
def baz_outplace(x: torch.Tensor) -> torch.Tensor:
return x.sin()
@torch.library.custom_op("mylib::baz_inplace", mutates_args=["x"])
def baz_inplace(x: torch.Tensor) -> torch.Tensor:
x.sin_()
def baz(x):
if inplace:
baz_inplace(x)
return x
else:
return baz_outplace(x)
PyTorch MPS is only supported on MacOS-14 or later. If you need to use MPS on MacOS Ventura, please avoid updating to Python-3.9 or above
This upgrade is doing the same BC-breaking changes as the DLPack release. Objects in torch.utils.dlpack have been updated to reflect these changes, such as DLDeviceType.
See the PR for details on the exact changes and how to update your code.
torch.cat (#158249)torch.cat now raises ValueError, IndexError or TypeError where appropriate instead of the generic RuntimeError. If you code was catching these errors, you can update to catch the new error type.
dynamo=True for ONNX exporter (#159646, #162726)Previously torch.onnx.export(...) used the legacy TorchScript exporter if no arguments were provied. The ONNX exporter now uses the newer torch.export.export pipeline by default (dynamo=True). This change improves graph fidelity and future-proofs exports, but may surface graph capture errors that were previously masked or handled differently.
Previously in torch 2.8.0:
# API calls the legacy exporter with dynamo=False
torch.onnx.export(...)
Now in torch 2.9.0:
# To preserve the original behavior
torch.onnx.export(..., dynamo=False)
# Export onnx model through torch.export.export
torch.onnx.export(...)
Recommendation: first try the new default; only fall back if you hit blocking issues and report them upstream. Long term solution: fix the root cause instead of relying on fallback or TorchScript exporter.
To enable runtime asserts, use export(..., prefer_deferred_runtime_asserts_over_guards=True). Also kills the allow_complex_guards_as_runtime_asserts flag, merging it into the former option.
Additionally, exported_program.module() will generate a call to a _guards_fn submodule that will run additional checks on inputs. Users who do not want this behavior can either remove this call in the graph, or do exported_program.module(check_guards=False) to avoid the generation.
Opset 20 enables newer operator definitions. If your tooling or downstream runtime only supports opset 18, pin it explicitly. For the latest ONNX operators, you can experiment with opset 23.
Previously in torch 2.8.0:
# opset_version=18
torch.onnx.export(...)
Now in torch 2.9.0:
# To preserve the original behavior
torch.onnx.export(..., opset_version=18)
# New: opset_version=20
torch.onnx.export(...)
# Use the latest supported opset: opset_version=23
torch.onnx.export(..., opset_version=23)
draft_export in exporter API (#161454, #162225)Remove implicit draft tracing from the default exporter path, achieving clearer behaviour and faster failures.
The expensive torch.export.draft_export diagnostic path is no longer auto-invoked (which could take hours on large models). You can still opt in for deep diagnostics:
Previously in torch 2.8.0:
# If both torch.export.export(..., strict=False) and
# torch.export.export(..., strict=True) fail to capture
# the model graph, torch.export.draft_export(...) will be triggered,
# and uses real tensor to trace/export the model.
#
# Inside export_to_onnx.py:
# ... torch.onnx.export(..., dynamo=True)
python export_to_onnx.py
Now in torch 2.9.0:
# To trigger torch.export.draft_export once
# torch.export.export strict=False/True both
# fail:
TORCH_ONNX_ENABLE_DRAFT_EXPORT=True python export_to_onnx.py
torch.onnx.dynamo_export and the onnxrt torch compile backend (#158130, #158258)torch.onnx.dynamo_export is removed. Please use torch.onnx.export instead.
The experimental ONNX Runtime compile backend (torch.compile(backend="onnxrt")) is no longer supported.
torch.onnx.enable_fake_mode (#161222)The dynamo=True mode uses FakeTensors by default which is memory efficient.
Deprecated members in torch.onnx.verification are removed. Previously private torch.onnx.symbolic_opsets* functions will no longer be accessible. Consider making a copy of the source code if you need to access any private functions for compatibility with the TorchScript based exporter.
torch.onnx.symbolic_caffe2 (#157102)Support for caffe2 in the ONNX exporter has ended and is removed.
/d2implyavx512upperregs flag that slows build (#159431)Re-introduced AVX512 optimizations for Windows VS2022 builds, may cause issues with specific versions of VS2022, see #145702
ScalarType to shim conversion and stable::Tensor.scalar_type (#160557)Before, user extensions could only in abstract pass around obfuscated dtypes appearing as int32_ts. Now, users can confidently use torch::headeronly::ScalarType in their extensions for major scalar types. This PR enables ABI stability by adding a translation layer through the shim, so that even if the ScalarType enum values change in the future, user extensions need not fear.
This change adds ScalarType support for user extensions and is only narrowly BC breaking for unpopular dtypes: quint*s, qint*s, Bits*, dummy_uint*s, dummy_int*s, Float8_e8m0fnu, and Float4_e2m1fn_x2 in the use case where an extension retrieves a Tensor dtype of the above and passes it into aoti_torch_call_dispatcher.
pin_memory_device param in torch.utils.data.DataLoader (#158323)We move enabling pin_memory back inside BaseDataLoaderIter. This is required for StatefulDataloader which leveraged BaseDataLoaderIter direclty rather than the Dataloader class init
torch.export.export_for_training API in favor of equivalent torch.export.export API (#158203)torch.export.export_for_training exists because we couldn't migrate internal usages of export to the final IR. Now that we have completed the migration, we deprecated and deleted this API.
__torch_function__ handler to be triggered by elements within a list (#160256)torch.hash_tensor reduction function (#154149)is_fx_symbolic_tracing flag (#161385)Introduces an API for annotating dynamic integer inputs & attributes for torch.compile, by wrapping plain ints with DynamicInt().
DynamicInt objects also work in eager mode, acting as their underlying values when passed as scalar inputs.
a = DynamicInt(4)
y = a + 2 # DynamicInt(6)
z = torch.ones(a) # torch.ones(4)
fn = torch.compile(torch.ones)
fn(a) # compiled fn takes a dynamic integer input
fn(2) # returns torch.ones(2) without recompiling
torch/csrc/stable/ops.h: amax, narrow, new_empty + new_zeros dtype variant, pad, (#159328, #158974, #159508, #161597, #160214)torch::stable::Tensor() default constructor, is_cpu, and get_device_index(#159507, #160212, #160143)torch::stable::accelerator with support for DeviceGuard and Stream (#159679, #160453)torch/headeronly: c10 Macros, STD_TORCH_CHECK, ScalarTypes (like BFloat16 and Half, #158035, #158365, #157912, #158377, #159302, #159414, #159412, #159415, #159411, #159911)TORCH_ERROR_CODE_CHECK in headeronly from AOTI (#159604)wheel from build requirements (#158027)TORCH_STABLE_ONLY is defined in TensorBase.h (#161658)torch/csrc/stable (#158160)zero_() and empty_like(t) to torch/csrc/stable/ops.h (#158866)Add support for CUDA 13.0 in CI/CD builds. Enable CUDA compression mode for binary size reduction for CUDA 13.0 builds (#160956, #161073, #161257, #161663, #161316, #160201, #160770, #161013, #161916, #162268, #162322, #162383, #161833)
Enable CUDA 12.6, 12.8 and 13.0 support for Linux ARM64 CD builds (#162364, #160720, #159481)
Add support for Python 3.14 in CI/CD builds (#156889, #157559, #159261, #159869, #160593, #160788, #161255, #159725)
Enable NVSHMEM integration (#151261, #153010, #154538, #155506, #156685, #158938, #161321, #160778, #159907, #160465)
cudnn_batch_norm_out kernel to replace the autogen approach (#123020)avg_pool3d, max_unpool1d/2d/3d, max_pool3d, max_pool3d bwd pass, and avg_pool3d bwd pass for MPS (#158877,#159789, #156467, #157498, #159089)FlexAttention on Intel GPU (#143553)torch.load under FakeTensorMode by reducing random reads (#157931)torch.utils.benchmark.utils.timer accelerator agnostic (#157131)register_buffer with Tensor-like objects (#159455)NLLLoss (#161412)requires_grad=True to a scalar (#160389)SequentialLR deprecation warning about invoking step(epoch) (#149392)torch.nn.Upsample mode="trilinear" backward (#154239)ProcessGroupNCCL (#156748)ProcessGroupNCCL (#156790)ProcessGroupGloo (#158128)TCPStore (#159165)all_gather (#149913)unsafe_get_ptr for dist.ProcessGroupNCCL.NCCLConfig (#161136)send/recv_object_list (#160342)ProcessGroupGloo (#156633)work.isStarted (#160398)device_mesh argument constraint in local_map (#157049)DTensor slice (#157953)histc op (#158298)propagate_tensor_meta function that skips cache if _are_we_tracing (#161334)local_map as a decorator (#161353)init_device_mesh (#159371)all_gather and reduce_scatter comms (#155189)set_allocate_memory_from_process_group if used together with custom comm hooks (#157487)reduceOpSum when world size is 1 (#157529)allgather when world size is 1 (#160135)post_reduce_stream.record_event() on hsdp+cpuoffload (#160481)parallelize_module API to support more cases (#157182)torchrun (#149334)eval() API to schedule (#157795)OVERLAP_F_B computation type (#158978)DualPipeV schedule (#159591)is_impure() (#151524, #157981)self.module_stack in ModuleStackTracer (#159956)node_name_match to subgraph rewriter (#157574)lists (e.g. #153969)sets (e.g. #153150)dicts (e.g. #154794)iter (e.g. #156371)itertools (e.g. #159693)collections (e.g. #159365)collections.NamedTuple (#159367)dataclasses.dataclass (#159529)TorchDispatchMode to ignore torch.compile internals (#161648){non-inf, > int32_max} upper bound is provided (#159433)None & ellipsis slicing/select in non-strict (#157821)triton_kernel_wrapper_functional HOP (#161314)while_loop HOP subgraphs (#158467)aot_export_joint_with_descriptors and aot_compile_joint_with_descriptors (#158715)prepare_aot_module_simplified for use in next PR (#158319)aot_export_joint_with_descriptors (#159814)aten.add.Scalar (#161332)aten.expand_copy decomp (#161688)aten.linalg_vector_norm (#155111)aten.complex (#160894)HistogramObserver (#156457)bias=None for fbgemm_linear_fp16_weight CPU op (#158535)wrapped_fbgemm_linear_fp16_weight for Sigmoid (#160451)log_softmax() support (#159662)vector.reserve() consistently for non-inplace foreach operations (#161128)has_integral_tensor() (#161042)torch.tensor warning in ONNX symbolic_opset10 export (#158835)AllocatorConfig to be device-agnostic via new AcceleratorAllocatorConfig (#149601, #150312)Scalar::isUnsigned() method (#159877)ModelRunner from nativert as public (#159989)torch.binomial enforcing float inputs (#157658)Dependencies.cmake (#159702)libtorch without NVSHMEM (#160910)repeat_interleave kernel (#157996)kernelLaunchCheck to print help string (#158896)Wunused-but-set-variable (#159276)libc++ (#161101)shifted_chebyshev_polynomial_[tuvw], igamma/igammac,grid_sampler_3d, native_dropout/native_dropout_backward (#157488, #161927, #160541, #162108)index_put to complex types (#160159)addmm to integral types (#160270)kthvalue (#161817)logcumsumexp metal kernel (#156858)dlpack integration (#158888)avg_pool2d to use Metal kernel when ceil_mode=True (#161011)composable_kernel (CK) backend user interface to improve user experience (#152951)rocSOLVER for Cholesky inversion. (#157154)torch.backends.miopen.immediate to toggle MIOpen Immediate Mode instead of relying on deterministic=True and benchmark=False (#158951)reshape_ or unexpectedly change memory formats (#161687)device_id to Intel GPU properties to distinguish iGPUs with identical names (#156481)torch.utils.cpp_extension.load_inline to override gencode (#156850)max_width computation in Tensor printing (#126859)pin_memory error message on CPU-only systems (#159994)F.embedding DTensor-aware (#162117)torch.autograd.Function memory leak due to torch.utils.checkpiont early stopping (#161171)torch.autograd.graph.GradientEdge for torch.autograd.Function (#160098)setGroupName and setGroupDesc in group_split and merge_remote_group (#159429)batch_isend_irecv with 2D tensor views by making P2P tensors dense (#163719)allgather/reducescatter inputs (#163712)DDPOptimizer and donated buffers (#160745)OpSchema equality check (#161231)grouped_mm strategy for invalid stride cases (#158245)F.one_hot in DTensor (#162307)ShardingPropagation cache if compiling (#156868)pin_memory (#157147)NO_SHARD correctly by flattening tensors before copying (#154369)fsdp_pre_all_gather (#160817)set_reduce_scatter_divide_factor errors and MixedPrecisionPolicy (#155964)no_grad() (#159293)eval() (#159475)import torch if compiled without TensorPipe (#159461)torch.distributed.elastic.multiprocessing.start_processes() (#160396)split_module with symint (#160093)getattr_recursive with ModuleList (#161204)torch.Tensor (#162224)torch.compiler.reset() (#156527)FlexAttention (#163677)return_lse warning message in FlexAttention (#163578)FlexAttention head broadcast (#163426)constant_pad_nd (#159878)MutationOutput Buffer (#162020)NaN behavior (#159308)dtype consistency (#160851)FallbackKernel alias function to avoid incorrect aliasing for custom ops (#163227)load_constants (#161887)gen_aoti_c_shim (#159904)aoti_torch_as_strided (#162118)wait_tensor returned tensor (#159502)all_reduce (#159818)from_node provenance in unlift pass (#157943)NaN serialization (#155359)nn_module_stack for assert_tensor_metadata nodes (#159625)move_to_device_pass (#159992, #160528, #162301)dynamo.disables in unflattening (#161306).contiguous() when saving weights to raw bytes to preserve original storage size of tensor (#163587)NaN in fp8 output of CPU qlinear and qconv ops (#160957)choose_qparams_optimized (#161966)chunk_size should always be int64_t for Foreach functors (#156872)rotary_embedding_23 implementation (#162865)None as output (#160200)dynamo=True (#161056)index_put_ usage (#161263)TORCH_CUDA_ARCH_LIST to only log when running on non-distributed or on rank 0 (#162764)torch.utils.cpp_extension parser for clang version 20.1.7+libcxx (#157666)MakeTensor::computeStorageSize() calculation (#158690)AllocatorConfig (#159629)BUILD_BUNDLEPTXAS=1 to allow compile on newer GPUs(#163988)torch.backends.cuda.matmul.fp32_precision (#161102)cudaErrorNotSupported (#162412)__syncthreads in MultiMarginLoss backward (#158994)kernel size != 1 for cuDNN 9.8+ (#163581)MKLDNN path (#162168)tensor dim > INT_MAX (#158824)exponential_ for MPS (#159386)ConvTranspose3d (#160345)conv3d autocast bias dtype mismatch (#160423)torch.var on scalar (#160889)index_add for complex + int64, int64 input + zerodim index (#160926, #161511)constant_pad_nd_mps bug when pad is empty (#161149)index_select for scalar_types (#161206)index_copy for scalars and index_copy for strided indices (#161267, #161333)NaNs if SDPA is called with all values masked from query (#157727)scaled_dot_product_attention using MPS (#163598)fillBuffer into 4Gb slices to avoid regression on MacOS 26 (#164108)hip:0 device error (#161221)cpp_extension.py on Windows (#159790)logsumexp needs scaling back to natural base (#156903)memcpy_and_sync inline function (#158165)cpp_extension compatibility with intel-deep-learning-essentials-2025.2 (#161012)ErrorReport::CallStack thread-safe (#160386)RemoveProfileNodesAndSpecializeTypes handling for Tensor? that is resolved to None (#161538)addmm to improve Newton–Schulz orthogonalization in Muon (#161379)AveragedModel.update_parameters() (#157705)dict tag optimization for faster guard evaluation (#159183)GEMM template (#159127, #161148)fmod.Scalar and scale_gradient (#160654, #160454)torch.full for 1-byte types (#158874)argmax/argmin (#159524)max_pool3d (#157875)max_pool3d impl (#157874)max_pool2d to Metal for stride != 1 (#157876)hipblaslt is used by default on gfx908 for ROCm >= 6.3 (#159092)tensor.item() (#158486)fbgemm_gpu genai sources for grouped GEMM support (#160676)torch.lobpcg, torch.clone, torch.matmul, torch.max, torch.gather, torch.Tensor.scatter_, torch.empty_like, torch.randint, torch.mul, torch.min, torch.max. torch.sort, torch.full_like, torch.histogramdd, torch.hamming_window (#156139, #157007, #161424, #156153, #157929, #157920, #158050, #158731, #160312, #161539, #162051, #158275, #152682)torch.set_float32_matmul_precision docs (#158191)torch.nn.utils.clip_grads_with_norm_ to reflect clamping behavior (#158200)torch.gradient (#159130)torch.segment_reduce docs (#154352)torch.is_floating_point and torch.is_complex docs (#161951)padding for avg_poolnd (#159142)CrossEntropyLoss docs with example of incorrect target specification (#155649)scaled_dot_product_attention example (#161613)torch.optim.adam.Adam, properly (#158483, #158669, #160194)zero_grad description (#161239)torch.inference_mode docs and error message (#161164)device_id (#159389)distributed_c10d.py (#162158)TupleStrategy (#158132)redistribute_costs (#158495)torch/ (torch/fx/, #156604)torch/fx/experimental/migrate_gradual_types/util.py (#157236)symbolic_multi_out (#160702)onnx.md to simplify deprecated entities (#159312)fallback=False by default (#162622, #162726)waitcounter for watchdog and heartbeat monitoring thread (#157480)torch.distributed.breakpoint set a long timeout (#158481)check_rng_sync util (#160283)FlightRecorder support for ProcessGroupXCCL (#158568)early_stop kwarg to torch.utils.checkpoint (#160781)register_foward_pre_hook not supported on ScriptModule error (#156904)__eq__ function to NodeSource (#158170)__hash__ function to NodeSource (#158322)tlparse error (#158469)expanded_def option for FX printing, render descriptor, update tests (#158708)co_lnotab in favor of co_linetable (#159227)CompiledFxGraph (#159311)allow_tf32 in tl.dot(..., allow_tf32=...), use tl.dot(..., input_precision=...) (#160711)jit_post_compile_hook within Inductor Triton Kernel compile path (#161443)torch.backends.cuda.matmul.allow_tf32 in Inductor cache key (#159480)guard_size_oblivious on data dependent errors (#160510)torch.utils.data samplers benchmark script (#156974)torch.utils.data.Dataloader benchmark script (#159432)setup.py develop with pip install -e for development builds (#155998, #156027, #156710) (#156709)