Commit Graph

3348 Commits

Author SHA1 Message Date
Lakshay Garg 227bab2922 [Allocator] Make large segment size configurable (#172056)
The ability to configure segment sizes can be a useful performance tuning knob when large allocations are common.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/172056
Approved by: https://github.com/ngimel, https://github.com/eqy
2026-01-15 17:32:14 +00:00
sekyonda c22397c4ad Redirect setup (#172035)
Set up redirects for PyTorch docs

Pull Request resolved: https://github.com/pytorch/pytorch/pull/172035
Approved by: https://github.com/svekars, https://github.com/malfet
2026-01-14 22:23:46 +00:00
albanD a22552f98d Add Joe Spisak to Core maintainers list (#172355)
And Ivan for Docs per @svekars request
Pull Request resolved: https://github.com/pytorch/pytorch/pull/172355
Approved by: https://github.com/atalman
2026-01-13 19:44:08 +00:00
PyTorch MergeBot 1aa99d6064 Revert "[ROCm] SDPA fix mem fault when dropout is enabled (#154864)"
This reverts commit fd27eb7b00.

Reverted https://github.com/pytorch/pytorch/pull/154864 on behalf of https://github.com/yangw-dev due to already unland internally since it's broken internal tests, ticket: T251298521 ([comment](https://github.com/pytorch/pytorch/pull/154864#issuecomment-3745570638))
2026-01-13 17:36:20 +00:00
Ke Wen 31fadcbabe [SymmMem] Deprecate enable_symm_mem_for_group (#172163)
Resolves #171827

`enable_symm_mem_for_group` is for getting access to the store of a group.
But the store can be also retrieved by `ProcessGroup.getStore()` in C++.
Thus makes little sense to require users to call `enable_symm_mem_for_group`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/172163
Approved by: https://github.com/Skylion007
2026-01-11 01:17:47 +00:00
Yu, Guangye 74a4d3f741 [xpu][feature] [5/6] Introduce memory snapshot for XPU in frontend part (#169442)
# Motivation
This PR aims to introduce a new API `torch.xpu.memory_snapshot` to provide detailed information for each memory segment managed by the allocator, including its size, owning pool, associated stream, call stack traces, and other relevant attributes.

# Additional Context
We use the UT to verify the consistency of memory information between `torch.xpu.memory_snapshot` and `torch.xpu.memory_stats`.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/169442
Approved by: https://github.com/EikanWang, https://github.com/albanD, https://github.com/eellison
ghstack dependencies: #169296
2026-01-10 04:42:49 +00:00
Laith Sakka 7bec715e01 hint_int -> size_hint, support size_hint in user code. (#171944)
part of series of changes to size hinting:

1. rename hint_int to size_hint (to be consistent with sizevars similar to all other functions that we unified their names)
2. remove size_hint allow_none and add fallback argument instead same as size_hint.
3. add explicit check for common wrong usage of sizevars.size_hint with symint inputs to throw clear error message for better user experience. and found two bugs :
    a) a bug in estimate_flops and fix it !
    b) a bug in tune_kernel and fix it.
    C) bug in count_flops_fx.
4. support calling size_hint from traced code.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/171944
Approved by: https://github.com/bobrenjc93
ghstack dependencies: #171843
2026-01-09 22:47:15 +00:00
Andy Lugo fd27eb7b00 [ROCm] SDPA fix mem fault when dropout is enabled (#154864)
Fixes issue that exhibited a device side memory access fault due to incorrect tensor life management

Pull Request resolved: https://github.com/pytorch/pytorch/pull/154864
Approved by: https://github.com/atalman
2026-01-09 19:59:44 +00:00
Bipasha Biswas 9cda69a7db docs: clarify torch._dynamo.mark_dynamic usage with torch.compile (#171682)
Added a warning to the torch.compiler API docs clarifying that torch._dynamo.mark_dynamic() must not be called inside a model’s forward() method when using torch.compile().
Pull Request resolved: https://github.com/pytorch/pytorch/pull/171682
Approved by: https://github.com/zou3519
2026-01-09 18:04:34 +00:00
Chris Gottbrath e9d0797dde Update persons_of_interest.rst (#172031)
Updating in the RST from the Dec 5th core maintainers meeting.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/172031
Approved by: https://github.com/svekars, https://github.com/atalman
2026-01-09 01:26:14 +00:00
Justin Chu b8069e259c [ONNX] Exportable module (#170810)
This pull request introduces the new `ExportableModule` abstract interface for ONNX exportable modules, integrates it into the ONNX export workflow, and provides comprehensive unit tests for its functionality. The changes improve the extensibility and usability of ONNX export by allowing models to define example arguments, dynamic shapes, and input/output names. The most important changes are grouped below by theme.

Example:

```py
class Model(torch.nn.Module):
    def forward(self, x):
        return x * 2

class MyExportableModule(torch.onnx.ExportableModule):
    def __init__(self):
        super().__init__()
        self.model = Model()

    def forward(self, x):
        return self.model(x)

    def example_arguments(self):
        return (torch.randn(2, 3, 224, 224),), None

    def input_names(self):
        return ("input",)

    def output_names(self):
        return ("output",)

    def dynamic_shapes(self):
        return ({0: "batch_size"},)

exportable_module = MyExportableModule()
onnx_program = exportable_module.to_onnx()
# The model can also be supplied directly to torch.onnx.export
onnx_program = torch.onnx.export(exportable_module)
```

Fix https://github.com/pytorch/pytorch/issues/165354

Pull Request resolved: https://github.com/pytorch/pytorch/pull/170810
Approved by: https://github.com/titaiwangms
2026-01-08 21:18:27 +00:00
Qi Jia 8896f7e87e [Docs] Fix broken torch.compiler documentation URLs (#171696)
Fix outdated documentation links in torch.compile docs.

While reading the torch.compile documentation, I noticed several links pointing to
deprecated pytorch.org URLs. This PR updates them to the correct pages under
docs.pytorch.org to avoid broken references.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/171696
Approved by: https://github.com/Lucaskabela
2026-01-08 05:09:41 +00:00
Dzmitry Huba bcf6dcc4e5 Add LocalTensor tutorial with verifiable by CI examples (#171840)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/171840
Approved by: https://github.com/dolpm
2026-01-08 01:21:53 +00:00
Ke Wen d55b24fd53 Add doc about Copy Engine collectives (#171811)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/171811
Approved by: https://github.com/weifengpy
2026-01-06 22:25:56 +00:00
Paul de Supinski f5291ea9c4 Improve NUMA binding docs (#171543)
NUMA binding has now been in a stable state for a while, so I took the time to polish the docs! See issue #158775.

# Test Plan
```
$ make html
```
and viewed in browser.

Here is the section on the torchrun webpage:
<img width="1728" height="949" alt="Screenshot 2025-12-30 at 2 08 08 PM" src="https://github.com/user-attachments/assets/f41e5e0a-2516-4fcc-afbd-9fa414a8a605" />

Here is the NUMA binding page itself:
<img width="1728" height="952" alt="Screenshot 2025-12-30 at 2 08 36 PM" src="https://github.com/user-attachments/assets/970b158b-5109-4e43-8fbe-c5c43e575ff0" />
<img width="1728" height="952" alt="Screenshot 2025-12-30 at 2 08 56 PM" src="https://github.com/user-attachments/assets/01bf706f-02a6-4132-a74e-4b4b27d0aa6f" />
<img width="1728" height="957" alt="Screenshot 2025-12-30 at 2 08 49 PM" src="https://github.com/user-attachments/assets/22c03f74-98ab-48fa-9bb4-882e33985ef7" />

Pull Request resolved: https://github.com/pytorch/pytorch/pull/171543
Approved by: https://github.com/kiukchung
2026-01-06 21:52:08 +00:00
Mikayla Gawarecki ea4ae0910e Make FC/BC policy explicit in libtorch stable ABI doc (#171751)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/171751
Approved by: https://github.com/janeyx99
2026-01-06 21:22:39 +00:00
Ke Wen c260ae19a7 [SymmMem] Add doc for tiled operators (#171737)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/171737
Approved by: https://github.com/ngimel
ghstack dependencies: #171728
2026-01-06 02:11:53 +00:00
Yuanyuan Chen 2e795d969c Fix typos (#171042)
This PR fixes typos in function names, comments and variable names. No public API is touched.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/171042
Approved by: https://github.com/zou3519
2026-01-06 01:23:13 +00:00
Ke Wen 771830429a [SymmMem] Add doc for MemPool support (#171728)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/171728
Approved by: https://github.com/ngimel
2026-01-06 00:44:04 +00:00
Mikayla Gawarecki 095124ba68 Link to cpp doc in libtorch_stable_abi doc (#171626)
Link check fails because the other PR needs to be landed first

Pull Request resolved: https://github.com/pytorch/pytorch/pull/171626
Approved by: https://github.com/janeyx99
ghstack dependencies: #170912
2026-01-05 21:40:30 +00:00
Shangdi Yu ac7c239067 update doc for tlparse (#171339)
Update our documentation for tlparse

Pull Request resolved: https://github.com/pytorch/pytorch/pull/171339
Approved by: https://github.com/williamwen42, https://github.com/cyyever
2026-01-04 01:57:33 +00:00
albanD 1913ee1aec Assert in github, docs, setup and top (#170598)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/170598
Approved by: https://github.com/ezyang, https://github.com/cyyever
2026-01-01 05:27:53 +00:00
William Wen 32cb1dac89 [dynamo, docs] add torch.compiler.is_compiling and torch._dynamo.config.ignore_logging_functions to programming model docs (#169632)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/169632
Approved by: https://github.com/tugsbayasgalan, https://github.com/yushangdi
2025-12-26 22:23:10 +00:00
KarhouTam 044e60e8c1 [OpenReg][Docs] Add profiler integration documentation (#170276)
## Summary
This PR adds a new accelerator documentation chapter, `docs/source/accelerator/profiler.md`, and wires it into the accelerator guide index. The doc explains PyTorch’s profiler integration paths at a high level (legacy autograd vs Kineto) and then focuses on how `PrivateUse1` accelerators can integrate via the legacy autograd path. It uses OpenReg as the illustrative example in the Implementation section, without coupling Design/Background to any specific backend.

## Motivation
Third‑party accelerators integrating via `PrivateUse1` need a concise, device‑agnostic reference for profiler integration. Today, details are scattered across C++ stubs, Python control code, and tests. This documentation centralizes:
- Where an accelerator plugs into the profiler surface
- What hooks are required (record/elapsed/synchronize/onEachDevice/annotations)
- How to validate behavior with multi‑stream/device, shapes, and chrome trace export

## What’s changed
- Added `docs/source/accelerator/profiler.md`
  - Background: links to `torch/csrc/profiler/README.md` and outlines the two profiler paths
  - Design: backend‑agnostic control plane (Python, ProfilerStubs, backend runtime)
  - Implementation: introduces OpenReg as the example for `PrivateUse1` legacy path
  - Usage patterns: snippets for multi‑stream, training loops, and trace export
  - Validation and limitations: summarizes tested scenarios and current constraints
- Updated `docs/source/accelerator/index.md` to include `profiler` in the toctree
Pull Request resolved: https://github.com/pytorch/pytorch/pull/170276
Approved by: https://github.com/fffrog
2025-12-26 06:31:08 +00:00
Jerry Zhang 0e38e0291c Delete pt2e flow from pytorch/pytorch since it's migrated to torchao (#169151)
Summary:

Deleting pt2e flow for 2.10 as mentioned in https://docs.pytorch.org/docs/stable/quantization.html

Other flows still have internal users, we'll revisit later.

Test Plan:
CI

Reviewers:

Subscribers:

Tasks:

Tags:

Differential Revision: [D87958849](https://our.internmc.facebook.com/intern/diff/D87958849)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/169151
Approved by: https://github.com/andrewor14
2025-12-23 20:41:04 +00:00
Byron Wang 276a994ab3 Move non-tensor nodes on boundary after split (#163605)
Summary: See details in the attached doc
[AOTI Non-Tensor on Boundary Issue.pdf](https://github.com/user-attachments/files/22608882/AOTI.Non-Tensor.on.Boundary.Issue.pdf)

Meta internal post: https://fb.workplace.com/groups/aoti.productionization/permalink/743060011864813/

Test Plan: unit test

Bifferential Revision: D80903201

Steps to show how this feature works:
- checkout commit: 01eb5dd5c3dc3e5d62fc975da9bcfee4befbd421
- run this local lowering command: P2072906967
You will see error like below, this means there is a node on the boundary whose dtype is `torch.dtype`, the corresponding model code is [this line](https://www.internalfb.com/code/fbsource/[e9ae35402388]/fbcode/minimal_viable_ai/umia_v1/ig/omni/root_model.py?lines=2409)
```
Found <class 'torch.dtype'> in output, which is not a known type.
```
- Then search `move_non_tensor_nodes_on_boundary` in file `fbcode/caffe2/torch/fb/model_transform/lower_presets/aoti/ig_ss_t2i_retrieval_aot_inductor.py`, you will see it is commented, now set `move_non_tensor_nodes_on_boundary` to true, and rerun the command in last step, you will see the tracing is done and `_exported_run_on_acc_1_readable.txt` is generated. (although there is IMA error which is not related to this diff)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/163605
Approved by: https://github.com/ColinPeppler
2025-12-19 15:31:29 +00:00
Angel Li 20ea828dd2 [BE] documenting functions (#170581)
<img width="893" height="555" alt="Screenshot 2025-12-16 at 9 55 23 PM" src="https://github.com/user-attachments/assets/f9658715-6291-45d7-b9f3-f07c5ddfc4ff" />

Pull Request resolved: https://github.com/pytorch/pytorch/pull/170581
Approved by: https://github.com/albanD
2025-12-17 20:01:52 +00:00
zhxchen17 20badc5bad [precompile] Add an option to keep tensor, shape and global state guards. (#170082)
Creating a new guard filter for AOT precompile that only preserve the following 3 types of guards:
1. TENSOR_MATCH
2. SHAPE_ENV
3. GLOBAL_STATE

These are the guards that matter empirically in AOT use cases like large scale training.

Other types of dynamo guards are dropped from this policy because:
1. Serialization on those guards often require complex pickling behavior that brings additional implementation cost.
2. Those guards (global variable id matches, class matches, etc) usually doesn't change a lot in training.
3. More guards will introduce more overhead during runtime. By default we'd rather keep guards checking minimal at runtime if possible.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/170082
Approved by: https://github.com/bobrenjc93
ghstack dependencies: #170081
2025-12-17 16:23:20 +00:00
JessicaZhong 4c5fae2efd [BE] Rename MaskPartial back to _MaskPartial (#170423)
`MaskPartial` was made to a public class in https://github.com/pytorch/pytorch/pull/164414, this PR changes it back to a private class, as this class is [used internally](https://github.com/pytorch/pytorch/blob/95f7d70fbacf4bbdedec6912d614f4912d42d18d/torch/distributed/tensor/_ops/_embedding_ops.py#L52) to achieve vocab parallel.

Test:
```
python3 test/distributed/tensor/test_embedding_ops.py
python3 test/distributed/tensor/test_tensor_ops.py
```
Pull Request resolved: https://github.com/pytorch/pytorch/pull/170423
Approved by: https://github.com/tianyu-l
2025-12-16 23:33:43 +00:00
Divyansh Khanna 5e4df381f8 Update persons of interest list for torchdata, torchvision, torchcodec (#170275)
Following the same rules listed here https://github.com/pytorch/pytorch/pull/136672

Making TV, TC changes after consulting with Nicolas.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/170275
Approved by: https://github.com/ramanishsingh
2025-12-16 22:25:26 +00:00
Divyansh Khanna 045cd79633 Update docs/source/data.md (#170313)
Fixes #169252

Pull Request resolved: https://github.com/pytorch/pytorch/pull/170313
Approved by: https://github.com/aelavender, https://github.com/ramanishsingh
2025-12-16 19:29:25 +00:00
PyTorch MergeBot a4876af74a Revert "Move non-tensor nodes on boundary after split (#163605)"
This reverts commit f927e00362.

Reverted https://github.com/pytorch/pytorch/pull/163605 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](https://github.com/pytorch/pytorch/pull/163605#issuecomment-3661422614))
2025-12-16 16:37:21 +00:00
Byron Wang f927e00362 Move non-tensor nodes on boundary after split (#163605)
Summary: See details in the attached doc
[AOTI Non-Tensor on Boundary Issue.pdf](https://github.com/user-attachments/files/22608882/AOTI.Non-Tensor.on.Boundary.Issue.pdf)

Meta internal post: https://fb.workplace.com/groups/aoti.productionization/permalink/743060011864813/

Test Plan: unit test

Bifferential Revision: D80903201

Steps to show how this feature works:
- checkout commit: 01eb5dd5c3dc3e5d62fc975da9bcfee4befbd421
- run this local lowering command: P2072906967
You will see error like below, this means there is a node on the boundary whose dtype is `torch.dtype`, the corresponding model code is [this line](https://www.internalfb.com/code/fbsource/[e9ae35402388]/fbcode/minimal_viable_ai/umia_v1/ig/omni/root_model.py?lines=2409)
```
Found <class 'torch.dtype'> in output, which is not a known type.
```
- Then search `move_non_tensor_nodes_on_boundary` in file `fbcode/caffe2/torch/fb/model_transform/lower_presets/aoti/ig_ss_t2i_retrieval_aot_inductor.py`, you will see it is commented, now set `move_non_tensor_nodes_on_boundary` to true, and rerun the command in last step, you will see the tracing is done and `_exported_run_on_acc_1_readable.txt` is generated. (although there is IMA error which is not related to this diff)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/163605
Approved by: https://github.com/ColinPeppler
2025-12-16 15:47:19 +00:00
Jane Xu d24276fc2a Add supported StableIValue types to docs (#168385)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/168385
Approved by: https://github.com/albanD
2025-12-16 06:34:05 +00:00
Zheng, Zhaoqiong 5be28ea833 update get start xpu with new client gpu & update format (#169810)
- update get start xpu with new client gpu
- update script format
Pull Request resolved: https://github.com/pytorch/pytorch/pull/169810
Approved by: https://github.com/EikanWang, https://github.com/gujinghui

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-16 04:37:57 +00:00
Mikayla Gawarecki e615d01eb8 Update libtorch stable abi doc to use TORCH_BOX macro (#170453)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/170453
Approved by: https://github.com/albanD
2025-12-15 23:52:33 +00:00
Vasiliy Kuznetsov aa905f813f Update tensor_attributes.rst with additional float4 information (#170448)
Update documentation clarifying the semantics of the `torch.float4_e2m1fn_x2` dtype.

Test plan: looked that preview of the docs, it renders correctly

Pull Request resolved: https://github.com/pytorch/pytorch/pull/170448
Approved by: https://github.com/ngimel
2025-12-15 23:25:42 +00:00
Angel Li 6b25a63ef4 add mechanism to restore default flash attn impl after override (#169866)
Fixes #168123

**Testing**

Trace with FA4 (calls cute backend):
<img width="1689" height="607" alt="Screenshot 2025-12-08 at 2 32 10 PM" src="https://github.com/user-attachments/assets/a33709cf-4a85-452f-9a4e-971d3a8a6ddb" />

Trace with FA2 (calls default flash_bwd):
<img width="1677" height="415" alt="Screenshot 2025-12-08 at 2 33 07 PM" src="https://github.com/user-attachments/assets/433a5d0e-8067-4638-a877-31c44725b5c7" />

Unit Test:  `python test_fa4.py -k test_fa4_kernel_called`

Pull Request resolved: https://github.com/pytorch/pytorch/pull/169866
Approved by: https://github.com/drisspg, https://github.com/mikaylagawarecki
2025-12-15 21:24:39 +00:00
Sherlock Huang 8335b05c3d Add public documentation for stable_topological_sort (#169498)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/169498
Approved by: https://github.com/albanD
2025-12-11 15:31:07 +00:00
manigkrish 34cfd5febc Add support for ignore_logging_functions in Dynamo to skip arbitrary logging callables during tracing (#168913)
Fixes #168317

Adds support for ignoring arbitrary Python callables during TorchDynamo tracing.
Introduces the new `ignore_logging_functions` config and updates DebuggingVariable
so functions in this set are treated as full no-ops without reordering, execution,
or graph breaks. The existing behavior for other logging configurations remains unchanged.

Tested locally by adding functions to `ignore_logging_functions` and verifying
that Dynamo skips them without graph breaks and produces the correct compiled output.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/168913
Approved by: https://github.com/williamwen42
2025-12-10 23:15:19 +00:00
David Ramon Prados c3cf85c3c0 [MTIA][RNG] Implement Python RNG API layer (#169982)
Summary:
The implementation adds 9 RNG functions (get/set_rng_state, manual_seed, seed, initial_seed, and their _all variants) that integrate with the existing C++ generator infrastructure. The lazy initialization pattern ensures RNG operations queue correctly before device initialization and execute during _lazy_init(). We follow the existing CUDA pattern. In addition, we integrated with the general torch.manual_seed and torch.seed functions following the exisiting custom accelerator pattern.

Added comprehensive test coverage for all API calls as well as for the torch integration.

Test Plan:
buck2 test //mtia/host_runtime/torch_mtia/tests:test_torch_mtia_api

https://www.internalfb.com/intern/testinfra/testrun/2533275122809554

buck2 test fbcode//mtia/host_runtime/torch_mtia/tests:test_mtia_rng_generators

https://www.internalfb.com/intern/testinfra/testrun/9288674362815734

Reviewed By: StellarrZ

Differential Revision: D88014851

Pull Request resolved: https://github.com/pytorch/pytorch/pull/169982
Approved by: https://github.com/albanD
2025-12-10 19:18:03 +00:00
PyTorch MergeBot c6b3d0f359 Revert "Add torch.backends.cuda.math_sdp.fp32_precision (#169694)"
This reverts commit da2a17c0bc.

Reverted https://github.com/pytorch/pytorch/pull/169694 on behalf of https://github.com/albanD due to As mentioned in my comment above, please wait for Driss to approve before merging ([comment](https://github.com/pytorch/pytorch/pull/169694#issuecomment-3634065809))
2025-12-09 20:11:36 +00:00
Anatoliy Litvinenko da2a17c0bc Add torch.backends.cuda.math_sdp.fp32_precision (#169694)
# Overview

This PR adds a new float32 precision API
`torch.backends.cuda.math_sdp.fp32_precision` to configure fp32 precision
behavior of `SDPBackend.MATH`

# Rationale

The `test/test_transformers.py` testing suite calculates the numerical
tolerance by comparing output tensors from the same precision ("reference")
and higher precision ("golden"), both calculated by `SDPBackend.MATH`.
However, the golden output is calculated with TF32 rather than FP32, which in
fact is less accurate than the FA/ME backend if they used IEEE rather than
TF32 for their accumulation.

The loss of precison causes false negatives in SDPA tests like
`TestSDPACudaOnlyCUDA.test_flash_attention_vs_math_ref_grads_batch_size_8_seq_len_q_143_seq_len_k_4_head_dim_203_is_causal_False_dropout_p_0_22_float16_scale_l1_enable_gqa_True_n_heads1_cuda_float16`
, at least on ROCM platform. The false negative disappears after forcing
`higher_precision_dtype = torch.float64`

# Major Changes

To restore the precision of golden output, a new API
`torch.backends.cuda.math_sdp.fp32_precision` is introduced, which allows
configuration of "matmul" precision during `SDPBackend.MATH`, and a new
decorator `@math_sdp_precision("ieee")` is added to all tests that use
`check_out_and_grad`. At last, an assert is added to the inner most function
`_check_equal` as a sanity check to ensure `math_sdp` has the right precison
configured for `torch.float32` golden tensors.

# Known Issues

The backward phase honors the configuration when calling `backward()`, regardless
the configuration when creating the graph.

This is copy of PR https://github.com/pytorch/pytorch/pull/167157 due to pytorchbot limited access to the ROCm fork.

As reference, pr for checking test state: https://github.com/pytorch/pytorch/pull/169676

Pull Request resolved: https://github.com/pytorch/pytorch/pull/169694
Approved by: https://github.com/jeffdaily

Co-authored-by: Xinya Zhang <Xinya.Zhang@amd.com>
2025-12-09 18:01:13 +00:00
KarhouTam 8acadd54d1 [OpenReg][Docs] Optimize docs for better expression (#169913)
Optimize some expressions to avoid ambiguity and improve logics

Pull Request resolved: https://github.com/pytorch/pytorch/pull/169913
Approved by: https://github.com/fffrog
2025-12-09 14:07:24 +00:00
Yu, Guangye 87449b1c16 Document PYTORCH_ALLOC_CONFIG and mark PYTORCH_CUDA_ALLOC_CONFIG as its alias (#167659)
# Motivation
This PR aims to document `PYTORCH_ALLOC_CONF` in the doc and comments and reminder the user that the previous environment variable `PYTORCH_CUDA_ALLOC_CONF` is its alias.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/167659
Approved by: https://github.com/albanD
2025-12-09 08:21:16 +00:00
Turner Richmond 5dcec44442 Escaped html tags name and target to appear as strings (#165543)
Fixes small typo in markdown documentation file - Added escape characters to precede tag pattern.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/165543
Approved by: https://github.com/isuruf
2025-12-09 02:34:33 +00:00
drisspg 5a68da4458 Fix grouped_gemm docs (#169862)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/169862
Approved by: https://github.com/Skylion007, https://github.com/ngimel
2025-12-08 20:29:08 +00:00
KarhouTam a25f70d1d3 [OpenReg][Guard] Enrich OpenReg guard implementation and add focused documentation (#166288)
## Summary
This PR refactors parts of the OpenReg device guard implementation, tightens up device/event/stream handling, and adds focused documentation to help developers understand and reuse the guard API for the PrivateUse1 backend.

## Motivation

- The OpenReg guard implementation previously mixed device, stream and event responsibilities in a single, less-structured area. That made it harder to include focused code snippets in the docs and to reason about semantics (e.g., which methods are device-only vs stream or event related).
- The documentation lacked a single, discoverable Guard chapter and literalinclude-friendly snippet markers that docs can include precisely.
- Small API/implementation correctness improvements (e.g., ensure runtime checks are applied) reduce subtle runtime errors when switching devices, recording events, or synchronizing streams.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/166288
Approved by: https://github.com/fffrog
2025-12-08 15:42:00 +00:00
bilibili12433014 3685c4588a Document: torch.compile support limitations for Python (#169401)
Added warning about Python compatibility with torch.compile in document.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/169401
Approved by: https://github.com/williamwen42

Co-authored-by: William Wen <william.wen42@gmail.com>
2025-12-07 03:24:06 +00:00
Angel Li d4803d0e6b [BE] documenting more functions (#167439)
adding more documentation for pytorch util functions
<img width="879" height="599" alt="Screenshot 2025-12-05 at 1 09 21 PM" src="https://github.com/user-attachments/assets/ff663607-92bf-4d84-a93f-30fe3ad28ee7" />

Pull Request resolved: https://github.com/pytorch/pytorch/pull/167439
Approved by: https://github.com/andrewor14, https://github.com/albanD
2025-12-05 20:47:25 +00:00