[logs] Add autotuning data (#154771)

Summary: Add autotuning logging data to scuba/chrome trace.

Test Plan:
```
TORCHINDUCTOR_MAX_AUTOTUNE=1 tlp buck run //scripts/sashko:compilation_sample
```

Open https://interncache-all.fbcdn.net/manifold/perfetto-artifacts/tree/ui/index.html#!/viewer?local_cache_key=00000000-0000-0000-92db-f23383ebf5b5, search for template_autotuning, see in metadata strides (see screenshot)

Differential Revision: D75457770

Pull Request resolved: https://github.com/pytorch/pytorch/pull/154771
Approved by: https://github.com/masnesral, https://github.com/PaulZhang12
This commit is contained in:
Oleksandr Stashuk
2025-06-06 17:12:55 +00:00
committed by PyTorch MergeBot
parent 706bc41c4c
commit 64436c38c9

View File

@ -2199,10 +2199,21 @@ class AlgorithmSelectorCache(PersistentCache):
def autotune(choices):
log.debug("Starting autotuning")
autotune_data = {
"shape": ", ".join(
["x".join(map(str, n.get_size())) for n in input_nodes]
),
"strides": ", ".join([str(n.get_stride()) for n in input_nodes]),
"dtypes": ", ".join([str(n.get_dtype()) for n in input_nodes]),
"offset": ", ".join([str(n.get_layout().offset) for n in input_nodes]),
}
with dynamo_timed(
f"{name}_template_autotuning",
log_pt2_compile_event=True,
dynamo_compile_column_us="compile_time_autotune_time_us",
metadata={"autotune_data": autotune_data},
):
return make_benchmark_fn()(choices)