pytorch/torch/utils
Adnan Akhundov 809ff3b274 Add host-side Triton TMA support to Dynamo (#137677)
This adds Dynamo tracing support for the host-side Triton TMA API (see `create_2d_tma_descriptor` calls on the host in the [Triton tutorial](https://triton-lang.org/main/getting-started/tutorials/09-persistent-matmul.html#sphx-glr-getting-started-tutorials-09-persistent-matmul-py)). A few notes:

- Here we assume the availability of the host-side TMA API added to upstream Triton in https://github.com/triton-lang/triton/pull/4498. As of time of writing, this is not a part of the PT2 OSS Triton pin (although back-ported internally). OSS Triton pin update should be done in December 2024.
- To capture the chain of calls `t.data_ptr() --> create_{1d,2d}_tma_descriptor(ptr, ...) --> kernel[grid](tma_desc, ...)`, we add three new variable trackers: `DataPtrVariable`, `CreateTMADescriptorVariable` (for the function), `TMADescriptorVariable` (for TMA descriptor object). This is to maintain the path back from the Triton kernel to the Tensor from which the TMA descriptor has been created.
- The newly introduced variables have `reconstruct` methods used in case of graph breaks.
- The `tma_descriptor_metadata` extracted from the captured `create_{1d,2d}_tma_descriptor` calls is propagated through the HOPs in Dynamo and AOTAutograd to be used by the downstream compiler (e.g., Inductor). See the unit tests for how the captured HOP arguments look like.
- In the Dynamo-captured fx graph, we replace the TMA descriptor arguments of the Triton kernel by the underlying Tensors, to be able to track the input/output relationships in terms of Tensors.
- In the Triton kernel mutation analysis pass (in AOTAutograd), we use the `tt.experimental_descriptor_store` TTIR op to detect mutations of the underlying tensors via TMA descriptors. So that downstream AOTAutograd can perform functionalizations as required.
- JIT Inductor and AOT Inductor support will be implemented in follow-up PRs.

Differential Revision: [D64404928](https://our.internmc.facebook.com/intern/diff/D64404928)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/137677
Approved by: https://github.com/zou3519
2024-10-16 02:18:48 +00:00
..
_strobelight
_sympy Cache some ValueRanges (#137438) 2024-10-13 19:23:34 +00:00
backcompat
benchmark
bottleneck
data Faster Faster BatchSampler (#137423) 2024-10-13 09:36:03 +00:00
hipify [AMD] use rccl.h instead of rccl/rccl.h (#135472) 2024-10-10 08:55:57 +00:00
jit
model_dump
tensorboard Param fixes in docstring (#136097) 2024-09-21 18:56:34 +00:00
viz
__init__.py
_backport_slots.py
_config_module.py
_config_typing.pyi
_content_store.py
_contextlib.py
_cpp_extension_versioner.py
_cxx_pytree.py
_device.py
_exposed_in.py
_foreach_utils.py
_freeze.py
_get_clean_triton.py
_import_utils.py
_mode_utils.py
_ordered_set.py
_python_dispatch.py Turn on type-checking in torch.fx.experimental.symbolic_shapes (#136972) 2024-10-01 13:22:10 +00:00
_pytree.py
_stats.py
_thunk.py
_traceback.py
_triton.py Add host-side Triton TMA support to Dynamo (#137677) 2024-10-16 02:18:48 +00:00
_typing_utils.py
_zip.py
backend_registration.py
bundled_inputs.py
checkpoint.py Param fixes in docstring (#136097) 2024-09-21 18:56:34 +00:00
collect_env.py
cpp_backtrace.py
cpp_extension.py Add abi flags to cpp_extension cache folder (#136890) 2024-09-28 00:49:56 +00:00
deterministic.py
dlpack.py
file_baton.py
flop_counter.py [BE][Ez]: FURB142,FURB92 misc preview fixes (#133880) 2024-08-21 13:54:51 +00:00
hooks.py
mkldnn.py
mobile_optimizer.py
model_zoo.py
module_tracker.py Move module_tracker to logging for confused hierarchy (#134467) 2024-08-26 19:39:08 +00:00
show_pickle.py
throughput_benchmark.py
weak.py [BE]: Update mypy to 1.11.2 (#133816) 2024-09-16 19:44:11 +00:00