From 5de683fab0bc6680604c5b4f36b3d3bec0a6f8d8 Mon Sep 17 00:00:00 2001 From: Jacob Szwejbka Date: Tue, 3 Nov 2026 09:42:06 -0800 Subject: [PATCH 1/2] [release/1.6] Fix complexity lint in AMD pointwise export Extract Triton source discovery into a helper, reducing main from complexity 13 to 10. Keep the release ROCm compile options, validation order, error messages and generated-code checks unchanged. Prepared with OpenAI Codex. --- examples/cuda/scripts/export_amd_pointwise.py | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/examples/cuda/scripts/export_amd_pointwise.py b/examples/cuda/scripts/export_amd_pointwise.py index d701a29e722..a7de96a2e7c 100644 --- a/examples/cuda/scripts/export_amd_pointwise.py +++ b/examples/cuda/scripts/export_amd_pointwise.py @@ -17,6 +17,19 @@ def forward(self, x: torch.Tensor) -> torch.Tensor: return torch.sin(x) * torch.sigmoid(x + 0.5) +def _find_triton_sources(cache_dir: pathlib.Path) -> list[pathlib.Path]: + triton_sources = [] + for source_path in cache_dir.rglob("*.py"): + source = source_path.read_text(errors="ignore") + if "async_compile.triton(" in source or "@triton_heuristics." in source: + triton_sources.append(source_path) + if not triton_sources: + raise RuntimeError( + f"Inductor did not generate a Triton kernel under {cache_dir}" + ) + return triton_sources + + def main() -> None: parser = argparse.ArgumentParser( description="Export a small Triton-backed AOTI delegate for an AMD GPU." @@ -90,15 +103,7 @@ def main() -> None: "the exported program does not contain an AOTI delegate call" ) - triton_sources = [] - for source_path in cache_dir.rglob("*.py"): - source = source_path.read_text(errors="ignore") - if "async_compile.triton(" in source or "@triton_heuristics." in source: - triton_sources.append(source_path) - if not triton_sources: - raise RuntimeError( - f"Inductor did not generate a Triton kernel under {cache_dir}" - ) + triton_sources = _find_triton_sources(cache_dir) executorch_program = edge_program.to_executorch() pte_path = args.output_dir / "amd_triton.pte" From ab77fc85fb10c61a09f06f6d615f4f33eb2b6e1a Mon Sep 17 00:00:00 2001 From: Jacob Szwejbka Date: Tue, 3 Nov 2026 09:44:57 -0800 Subject: [PATCH 2/2] [release/1.6] Use an inline C901 suppression for AMD export Restore the original export script and suppress complexity only on main, as requested. The script AST is unchanged from the release baseline and the repository Flake8 check passes. Prepared with OpenAI Codex. --- examples/cuda/scripts/export_amd_pointwise.py | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/examples/cuda/scripts/export_amd_pointwise.py b/examples/cuda/scripts/export_amd_pointwise.py index a7de96a2e7c..f1be1c5a12c 100644 --- a/examples/cuda/scripts/export_amd_pointwise.py +++ b/examples/cuda/scripts/export_amd_pointwise.py @@ -17,20 +17,7 @@ def forward(self, x: torch.Tensor) -> torch.Tensor: return torch.sin(x) * torch.sigmoid(x + 0.5) -def _find_triton_sources(cache_dir: pathlib.Path) -> list[pathlib.Path]: - triton_sources = [] - for source_path in cache_dir.rglob("*.py"): - source = source_path.read_text(errors="ignore") - if "async_compile.triton(" in source or "@triton_heuristics." in source: - triton_sources.append(source_path) - if not triton_sources: - raise RuntimeError( - f"Inductor did not generate a Triton kernel under {cache_dir}" - ) - return triton_sources - - -def main() -> None: +def main() -> None: # noqa: C901 parser = argparse.ArgumentParser( description="Export a small Triton-backed AOTI delegate for an AMD GPU." ) @@ -103,7 +90,15 @@ def main() -> None: "the exported program does not contain an AOTI delegate call" ) - triton_sources = _find_triton_sources(cache_dir) + triton_sources = [] + for source_path in cache_dir.rglob("*.py"): + source = source_path.read_text(errors="ignore") + if "async_compile.triton(" in source or "@triton_heuristics." in source: + triton_sources.append(source_path) + if not triton_sources: + raise RuntimeError( + f"Inductor did not generate a Triton kernel under {cache_dir}" + ) executorch_program = edge_program.to_executorch() pte_path = args.output_dir / "amd_triton.pte"