pytorch/torchgen
vasiliy 382fbcc1e4 add the torch.float8_e8m0fnu dtype to PyTorch (#147466)
Summary:

Continuing the work from https://github.com/pytorch/pytorch/pull/146427

Adds the `torch.float8_e8m0fnu` dtype to PyTorch, as detailed in
https://github.com/pytorch/pytorch/issues/146414 . Please see the issue for a detailed definition of the format.  Example of basic functionality:

```python
import torch

# round trip
x0 = torch.randn(4, 4, dtype=torch.float32)
x1 = x0.to(torch.float8_e8m0fnu)  # RNE rounding
x2 = x1.to(torch.float32)  # 2 ** exponent

# creation with empty
x0 = torch.empty(4, 4, dtype=torch.float8_e8m0fnu)

# printing
print(x0)
```

Done in this PR:
* numerical correctness
* op coverage (except for `torch._scaled_mm`): create tensor, cast to/from float32
* printing a tensor works

For future PRs:
* performance optimizations for casting
* torch._scaled_mm
* PT2
* various cleanups (detailed in comments with issue numbers)

Test Plan:

```
pytest test/quantization/core/experimental/test_float8.py -s
```

Reviewers:

Subscribers:

Tasks:

Tags:

Pull Request resolved: https://github.com/pytorch/pytorch/pull/147466
Approved by: https://github.com/drisspg
2025-02-20 13:55:42 +00:00
..
_autoheuristic [BE]: Enable ruff rule SIM113 (#147290) 2025-02-16 22:41:16 +00:00
aoti cpp_wrapper: fix set_.source_Tensor lowering (#145654) 2025-02-04 22:05:59 +00:00
api add the torch.float8_e8m0fnu dtype to PyTorch (#147466) 2025-02-20 13:55:42 +00:00
decompositions Revert "Use absolute path path.resolve() -> path.absolute() (#129409)" 2025-01-04 14:17:20 +00:00
dest [1/N] Apply py39 ruff fixes (#138578) 2024-12-02 21:46:18 +00:00
executorch [TorchGen] remove remove_non_owning_ref_types from valuetype_type (#142449) 2024-12-12 00:15:44 +00:00
fuse [BE] update type annotations for basic utilities in torch/__init__.py (#129001) 2024-06-24 18:04:38 +00:00
operator_versions Revert "Use absolute path path.resolve() -> path.absolute() (#129409)" 2025-01-04 14:17:20 +00:00
selective_build [BE][Easy] enable postponed annotations in torchgen (#129376) 2024-06-29 09:23:39 +00:00
shape_functions Revert "Use absolute path path.resolve() -> path.absolute() (#129409)" 2025-01-04 14:17:20 +00:00
static_runtime [BE][CI] bump ruff to 0.8.4 (#143753) 2024-12-24 12:24:10 +00:00
__init__.py
BUCK.oss
BUILD.bazel
build.bzl
code_template.py [1/N] Apply py39 ruff fixes (#138578) 2024-12-02 21:46:18 +00:00
context.py [2/N] Apply py39 ruff fixes (#141938) 2024-12-05 06:26:06 +00:00
gen_aoti_c_shim.py cpp_wrapper/aot_inductor: handle conjugation and negation dispatch keys (#145095) 2025-02-04 22:05:58 +00:00
gen_backend_stubs.py torchgen: move dispatch_helpers out of RegisterDispatchDefinitions.ini (#144363) 2025-01-10 18:13:06 +00:00
gen_executorch.py torchgen: support exception boundary for ExecuTorch functions (#144341) 2025-01-31 01:05:21 +00:00
gen_functionalization_type.py Revert "Make functionalization ViewMeta serializable with pickle. (#143712)" 2025-01-17 00:52:50 +00:00
gen_lazy_tensor.py [BE][Easy] use pathlib.Path instead of dirname / ".." / pardir (#129374) 2024-12-29 17:23:13 +00:00
gen_schema_utils.py [2/N] Apply py39 ruff fixes (#141938) 2024-12-05 06:26:06 +00:00
gen_vmap_plumbing.py [1/N] Apply py39 ruff fixes (#138578) 2024-12-02 21:46:18 +00:00
gen.py PEP585 update - benchmarks tools torchgen (#145101) 2025-01-18 05:05:07 +00:00
local.py [1/N] Apply py39 ruff fixes (#138578) 2024-12-02 21:46:18 +00:00
model.py add the torch.float8_e8m0fnu dtype to PyTorch (#147466) 2025-02-20 13:55:42 +00:00
native_function_generation.py [aotd] capture rrelu_with_noise noise mutation in compile (#141867) 2024-12-04 12:18:58 +00:00
utils.py Shard RegisterDispatchKey (#144364) 2025-01-10 18:21:19 +00:00
yaml_utils.py