pytorch/docs/source/notes
Jane Xu 8f766d6839 Add ScalarType -> shim conversion, add stable::Tensor.scalar_type (#160557)
TL;DR: Moving to ScalarType in user extensions and removing deprecated dtypes.

This change _modifies_ the from/to behavior between ScalarType and StableValue! Whereas 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.

Then we add a Tensor scalar_type API which reuses the from/to logic to return to the user a nice ScalarType (vs an abstracted int32_t).

I then changed the test to test the scalar_type API.

This code change required some refactoring because of circular dependencies.

## BC Breaking note
This commit is (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 narrow use case where an extension retrieves a Tensor dtype of the above and passes it into `aoti_torch_call_dispatcher`. As of now, I believe there are 0 users of this use case, so the benefits of this change significantly justify BC-breaking this API.

Pull Request resolved: https://github.com/pytorch/pytorch/pull/160557
Approved by: https://github.com/mikaylagawarecki, https://github.com/malfet
2025-08-19 22:13:47 +00:00
..
amp_examples.rst
autograd.rst [doc] Add documentation for division by zero behavior in autograd (#155987) 2025-06-16 19:02:12 +00:00
broadcasting.rst
cpu_threading_torchscript_inference.rst [3/n] Remove references to TorchScript in PyTorch docs (#158315) 2025-07-15 21:14:18 +00:00
cuda.rst Documents tuning NVLink performance on H100/H200 (#159792) 2025-08-08 20:28:24 +00:00
custom_operators.rst
ddp.rst
extending.func.rst
extending.rst [autograd][docs] Add more details on why save_for_backward is important in extending autograd note (#153005) 2025-05-09 16:36:57 +00:00
faq.rst
get_start_xpu.rst fix link for tutorial of inductor on windows (#159853) 2025-08-05 18:37:47 +00:00
gradcheck.rst [BE] fix typos in docs/ (#156080) 2025-06-21 02:47:32 +00:00
hip.rst [ROCm] Ck backend UX refactor (#152951) 2025-08-08 18:40:17 +00:00
large_scale_deployments.rst [3/n] Remove references to TorchScript in PyTorch docs (#158315) 2025-07-15 21:14:18 +00:00
libtorch_stable_abi.md Add ScalarType -> shim conversion, add stable::Tensor.scalar_type (#160557) 2025-08-19 22:13:47 +00:00
mkldnn.rst Enable TF32 as fp32 internal precision for matmul/linear/conv (#157520) 2025-07-17 08:57:34 +00:00
modules.rst
mps.rst
multiprocessing.rst [BE] fix typos in docs/ (#156080) 2025-06-21 02:47:32 +00:00
numerical_accuracy.rst Update warning of TF32 (#158209) 2025-07-16 01:28:50 +00:00
out.rst add Out Notes (#151306) 2025-04-24 20:25:09 +00:00
randomness.rst
serialization.rst Delete sections referencing torchscript in serialization docs (#156648) 2025-06-25 23:41:24 +00:00
windows.rst Removing conda references from PyTorch Docs (#152702) 2025-05-20 20:33:28 +00:00