pytorch/torch/utils
FindHao c99e91b1d7 [BE]Enhance _get_clean_triton.py to auto-generate launch_params if missing (#154666)
Previously, @Chillee wrote a script https://github.com/pytorch/pytorch/pull/125811 to remove inductor dependency for inductor compiled triton kernels. We'd like to automate the process of obtaining the launch parameters.

Added functionality to the torch/utils/_get_clean_triton.py to automatically generate the launch_params file if it does not exist and the auto_generate_params flag is set to True. This includes running the input file in a subprocess with the appropriate environment variable. Updated the get_clean_triton function and the main script to support this new feature, allowing users to disable auto-generation via a command-line argument.

# Test Plan
test embedding op in TritonBench
```
# generate inductor compiled triton kernels
TORCH_COMPILE_DEBUG=1 TORCHINDUCTOR_FX_GRAPH_CACHE=0 python run.py --op embedding  --mode fwd  --precision fp32 --metrics nsys_rep --only inductor_embedding  --num-inputs 1 --input-id 11
# run the script to get rid of inductor dependency. By default, triton_only_repro.py is the output file name.
python ~/pytorch/torch/utils/_get_clean_triton.py ~/tritonbench/torch_compile_debug/run_2025_05_29_14_47_50_497790-pid_849274/torchinductor/model__0_forward_1.0/output_code.py
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/154666
Approved by: https://github.com/davidberard98
2025-05-31 19:27:56 +00:00
..
_strobelight
_sympy [inductor] Fix ModularIndexing assumptions (#152993) 2025-05-08 18:26:45 +00:00
backcompat
benchmark Clean up conda usage in benchmark scripts (#152552) 2025-04-30 21:27:29 +00:00
bottleneck
data remove allow-untyped-defs from torch/utils/data/datapipes/iter/filelister.py (#154624) 2025-05-30 08:38:05 +00:00
hipify ROCm Sparsity through HipSparseLT (#150578) 2025-05-31 02:03:40 +00:00
jit
model_dump
serialization
tensorboard
viz [Visualizer] Start at index with most events (#154571) 2025-05-29 20:49:33 +00:00
__init__.py
_appending_byte_serializer.py
_backport_slots.py
_config_module.py Revert "inductor codecache: include private inductor configs in cache key (#153672)" 2025-05-30 15:54:14 +00:00
_config_typing.pyi Revert "inductor codecache: include private inductor configs in cache key (#153672)" 2025-05-30 15:54:14 +00:00
_content_store.py
_contextlib.py
_cpp_embed_headers.py
_cpp_extension_versioner.py
_cxx_pytree.py [BE] detect CXX pytree requirement with TorchVersion (#151102) 2025-05-01 18:55:57 +00:00
_device.py
_dtype_abbrs.py
_exposed_in.py
_filelock.py
_foreach_utils.py
_freeze.py
_functools.py
_get_clean_triton.py [BE]Enhance _get_clean_triton.py to auto-generate launch_params if missing (#154666) 2025-05-31 19:27:56 +00:00
_import_utils.py
_mode_utils.py
_ordered_set.py
_python_dispatch.py
_pytree.py [BE] detect CXX pytree requirement with TorchVersion (#151102) 2025-05-01 18:55:57 +00:00
_stats.py
_thunk.py
_traceback.py
_triton.py Revert "has_triton: Use the device interface for detecting Triton availability (#139171)" 2025-05-10 14:46:23 +00:00
_typing_utils.py
_zip.py
backend_registration.py
bundled_inputs.py
checkpoint.py Prevent SAC cache from being kept alive by reference cycle (#154651) 2025-05-29 22:27:35 +00:00
collect_env.py [BE]: Enable ruff YTT linter for Python version checks (#153547) 2025-05-14 21:09:16 +00:00
cpp_backtrace.py
cpp_extension.py [ROCm] cpp_extension allow user to override default flags (#152432) 2025-05-15 21:06:18 +00:00
deterministic.py
dlpack.py
file_baton.py
flop_counter.py
hooks.py
mkldnn.py
mobile_optimizer.py
model_zoo.py
module_tracker.py
show_pickle.py
throughput_benchmark.py
weak.py pymft lint torch/utils/weak.py (#154484) 2025-05-28 17:06:58 +00:00