From 42b6b469112261a02c85c00c80a16cc7da011423 Mon Sep 17 00:00:00 2001 From: "njzjz-bot (driven by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5))[bot]" <48687836+njzjz-bot@users.noreply.github.com> Date: Tue, 16 Jun 2026 19:59:57 +0000 Subject: [PATCH] test(pt_expt): apply fast AOTI config to generated pt2 fixtures C++ and LAMMPS tests generate their .pt2 fixtures via source/tests/infer/gen_*.py, which do not load pytest conftest.py. Apply the same fast AOTInductor settings through the shared generation helper so those fixtures skip expensive optimization passes too. Authored by OpenClaw (model: custom-chat-jinzhezeng-group/gpt-5.5) --- source/tests/infer/gen_common.py | 12 ++++++++++++ source/tests/pt_expt/aoti_config.py | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 source/tests/pt_expt/aoti_config.py diff --git a/source/tests/infer/gen_common.py b/source/tests/infer/gen_common.py index fea29fc63e..0063da33d1 100644 --- a/source/tests/infer/gen_common.py +++ b/source/tests/infer/gen_common.py @@ -11,9 +11,21 @@ def ensure_inductor_compiler(): Honours the ``CXX`` environment variable (standard CMake / CI convention). Falls back to torch._inductor's built-in default if ``CXX`` is not set. + Also applies fast test-only AOTInductor settings for generated ``.pt2`` + fixtures used by C/C++/LAMMPS tests. Also clears ``LD_PRELOAD`` so compiler subprocesses don't inherit the LSAN runtime, which causes false leak reports and non-zero exit codes in g++. """ + source_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), "..", "..")) + if source_dir not in sys.path: + sys.path.insert(0, source_dir) + + from tests.pt_expt.aoti_config import ( + apply_fast_aoti_compile_config, + ) + + apply_fast_aoti_compile_config() + cxx = os.environ.get("CXX") if cxx: import torch._inductor.config as inductor_config diff --git a/source/tests/pt_expt/aoti_config.py b/source/tests/pt_expt/aoti_config.py new file mode 100644 index 0000000000..d297cde2ed --- /dev/null +++ b/source/tests/pt_expt/aoti_config.py @@ -0,0 +1,18 @@ +# SPDX-License-Identifier: LGPL-3.0-or-later +"""AOTInductor settings for fast test-only ``.pt2`` compilation.""" + + +def apply_fast_aoti_compile_config() -> None: + """Reduce AOTInductor compile time for test fixtures. + + The test suite validates correctness rather than runtime performance, so it + can skip expensive Inductor/C++ optimization passes while producing usable + ``.pt2`` artifacts for Python, C, C++, and LAMMPS tests. + """ + import torch._inductor.config as inductor_config + + inductor_config.max_fusion_size = 8 + inductor_config.epilogue_fusion = False + inductor_config.pattern_matcher = False + inductor_config.aot_inductor.package_cpp_only = True + inductor_config.aot_inductor.compile_wrapper_opt_level = "O0"