Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions source/tests/infer/gen_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions source/tests/pt_expt/aoti_config.py
Original file line number Diff line number Diff line change
@@ -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"
Loading