Skip to content

[AOTI] Make test_aoti_inference runnable from CI build artifacts - #201699

Closed
desertfire wants to merge 5 commits into
gh/desertfire/793/basefrom
gh/desertfire/793/head
Closed

desertfire wants to merge 5 commits into
gh/desertfire/793/basefrom
gh/desertfire/793/head

Conversation

@desertfire

@desertfire desertfire commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Fixes #199776.

test_aoti_inference has collected no tests in CI since #164277. That change
moved model generation from build time to test time and dropped the rebuild
in the test job, but the binary still depended on its build directory,
build/test_aoti_inference, which the build job does not ship (only build/lib
and build/bin are): libaoti_custom_class.so was built there, the generated
data is written there, and compile_model.py loaded the library from its cwd,
which only worked because that cwd was the same directory. The binary failed
to start, pytest-cpp skipped it, and run_test.py counted "no tests collected"
as a pass; #199440 made that a failure and dropped the test from
test_inductor_aoti_cpp.

aoti_custom_class is now built into the default build/lib, which is shipped
and already on the binary's RUNPATH. Its path is passed to the test as
AOTI_CUSTOM_CLASS_LIB and from there to compile_model.py on the command
line. The test creates the data directory before generating into it. The
remaining build-time paths (data directory, test sources) still resolve in the
test job because CI builds and tests in the same workspace path; making them
fully relocatable (relative to the binary or via an env var) is a larger
change that only matters if the test moves to a job where those paths differ.

test_inductor_aoti_cpp also runs in the CPU inductor_aoti_fallback job, so
test.py now skips its CUDA-only models when CUDA is unavailable, and the
files-exist check only requires script_model_cuda.pt when a GPU is visible,
matching the generators; otherwise every test process would regenerate all the
data on CPU, or on a CUDA build without a visible GPU.

Test Plan:

Built with the test enabled on macOS arm64 (CPU). Apple ld rejects
-Wl,--no-as-needed, so that flag was dropped locally for this build only. To
mirror a CI test job, build/test_aoti_inference was moved aside before
running, so the test had to create it and generate all data itself:

BUILD_AOT_INDUCTOR_TEST=1 pip install -e . -v --no-build-isolation
mv build/test_aoti_inference /tmp/
cd test && ../build/bin/test_aoti_inference

All 9 CPU tests pass (with the previous commit's consts cpp fix). CUDA tests and
the run_test.py path were not run locally; CI covers them via the a10g
inductor_cpp_wrapper job.

This PR was authored with the assistance of Claude (AI).

[ghstack-poisoned]
@desertfire
desertfire requested a review from a team as a code owner October 22, 2026 04:17
@pytorch-bot

pytorch-bot Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

PR Status: Approved 🚀

Please fix all CI failures and trigger merge by commenting "@pytorchbot merge".

✅ AUTOMATED REVIEW - Ready for human review:

The PR makes test_aoti_inference runnable from CI build artifacts and re-enables
it in test_inductor_aoti_cpp. It also turns data-generation failures into hard
errors, but that error may cause every test to be reported as skipped instead of
failed. Recommendation: Needs Discussion.

Findings (1):

[minor] test/cpp/aoti_inference/test.cpp:82
A generation failure probably shows up as skipped tests, not failures (medium
confidence). The new TORCH_CHECKs run inside ensureTestDataGenerated(), whose
only caller is the static AotInductorTest::SetUpTestSuite() (line 1692). Recent
googletest releases catch an exception thrown in SetUpTestSuite(), record it on
the suite rather than on a test, and Skip() every test in the suite. pytest-cpp
runs each test with --gtest_filter, accepts exit code 1, and reports a skip when
that test's XML entry is marked skipped. So if test.py or compile_model.py fails
in CI (e.g. under TORCHINDUCTOR_LITE_MODE=1 in inductor_aoti_fallback), all
AotInductorTest.* cases would show as skipped and run_test.py would pass. Before
this PR, each test at least failed in torch::jit::load. Fix: call
ensureTestDataGenerated() from a non-static SetUp() so a failure counts against
the test, wrapped in ASSERT_NO_THROW or a catch that calls FAIL().
std::call_once is fine there because it re-runs the callable after it throws.
Not verified against the pinned googletest. To check, break compile_model.py and
run `python test/run_test.py --cpp -i cpp/test_aoti_inference`.

Reviewed commit: df124a7

Review run

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/201699

Note: Links to docs will display an error until the docs builds have been completed.

✅ No Failures

As of commit df124a7 with merge base 79a25ad (image):
💚 Looks good so far! There are no failures yet. 💚

🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:

  • Triviality
    • Spans CI script, CMake build output location, test binary data generation, and Python generators; no single trivial class covers all parts
    • Re-enables cpp/test_aoti_inference in test_inductor_aoti_cpp in .ci/pytorch/test.sh, which a human should confirm passes in both CPU and CUDA jobs
  • Build and runtime behavior
    • test/cpp/aoti_inference/CMakeLists.txt drops LIBRARY_OUTPUT_DIRECTORY so aoti_custom_class lands in shipped build/lib, a packaging-relevant change
    • test.py now gates generate_large_tests and two others on torch.cuda.is_available(), changing which data the C++ tests see
  • Review state
    • Dr. CI comment in PR metadata reports a maintainer requested changes

reason: not_trivial
Reviewed commit: 40d0905 (NOT the current head df124a7)

Inference job

🐛 Report a wrong verdict

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@desertfire desertfire added the topic: not user facing topic category label Oct 22, 2026
@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Oct 22, 2026
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
desertfire added a commit that referenced this pull request Oct 22, 2026
Fixes  #199776.

`test_aoti_inference` has collected no tests in CI since #164277. That change
moved model generation from build time to test time and dropped the rebuild
in the test job, but the binary still depended on its build directory,
`build/test_aoti_inference`, which the build job does not ship (only `build/lib`
and `build/bin` are): `libaoti_custom_class.so` was built there, the generated
data is written there, and `compile_model.py` loaded the library from its cwd,
which only worked because that cwd was the same directory. The binary failed
to start, pytest-cpp skipped it, and run_test.py counted "no tests collected"
as a pass; #199440 made that a failure and dropped the test from
`test_inductor_aoti_cpp`.

`aoti_custom_class` is now built into the default `build/lib`, which is shipped
and already on the binary's RUNPATH. Its path is passed to the test as
`AOTI_CUSTOM_CLASS_LIB` and from there to `compile_model.py` on the command
line. The test creates the data directory before generating into it. The
remaining build-time paths (data directory, test sources) still resolve in the
test job because CI builds and tests in the same workspace path; making them
fully relocatable (relative to the binary or via an env var) is a larger
change that only matters if the test moves to a job where those paths differ.

`test_inductor_aoti_cpp` also runs in the CPU `inductor_aoti_fallback` job, so
`test.py` now skips its CUDA-only models when CUDA is unavailable, and the
files-exist check only requires `script_model_cuda.pt` in CUDA/ROCm builds;
otherwise every test process would regenerate all the data on CPU.

Test Plan:

Built with the test enabled on macOS arm64 (CPU). Apple ld rejects
`-Wl,--no-as-needed`, so that flag was dropped locally for this build only. To
mirror a CI test job, `build/test_aoti_inference` was moved aside before
running, so the test had to create it and generate all data itself:

```
BUILD_AOT_INDUCTOR_TEST=1 pip install -e . -v --no-build-isolation
mv build/test_aoti_inference /tmp/
cd test && ../build/bin/test_aoti_inference
```

All 9 CPU tests pass (with the previous commit's consts cpp fix). CUDA tests and
the run_test.py path were not run locally; CI covers them via the a10g
`inductor_cpp_wrapper` job.

This PR was authored with the assistance of Claude (AI).

ghstack-source-id: e244a0a
Pull-Request: #201699
github-actions[bot]

This comment was marked as outdated.

@desertfire

Copy link
Copy Markdown
Contributor Author

@claude, was test_aoti_inference run in the inductor_cpp_wrapper shard, https://github.com/pytorch/pytorch/actions/runs/39726128445/job/119657279629 ?

@claude

claude Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Claude finished @desertfire's task in 38s —— View job


Yes. cpp/test_aoti_inference ran in that inductor_cpp_wrapper job (a CUDA runner) and passed. The console log doesn't list individual test cases, so I can't say which tests passed or how many.

Evidence from the job log
  • Line 10489: build/bin/test_aoti_inference is unpacked from the build artifact.
  • Line 12229: test_inductor_aoti_cpp runs run_test.py --cpp ... -i cpp/test_aoti_abi_check cpp/test_shim cpp/test_aoti_inference cpp/test_vec_half_AVX2.
  • Serial pass (-m '(serial)'): cpp/test_aoti_inference 1/1 was successful, 0.86 min. Every other cpp binary in the serial pass also took about 0.86 min, so this looks like the fixed per-binary overhead with no serial tests selected.
  • Non-serial pass (-m '(not serial)'): cpp/test_aoti_inference 1/1 was successful, 4.03 min. The other binaries took about 0.86 to 1.19 min. The extra ~3 min fits the test generating the AOTI data and running real test cases.
  • Since Fix C++ tests silently not running on ROCm CI #199440, "no tests collected" fails the run instead of passing. The binary passed, so tests were collected and run. Before this PR it was skipped entirely.

Per-test results are in the job's test-report artifacts: test/test-reports/cpp.test_aoti_inference_1.1_8c8cd7358dd110e7_.log and the junit XML cpp.test_aoti_inference-b9c7ae4ecc05a178.xml. You can also see them on HUD under the test results for this job.

@desertfire desertfire added the ciflow/trunk Trigger trunk jobs on your pull request label Oct 22, 2026
@desertfire

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorch-bot

pytorch-bot Bot commented Oct 22, 2026

Copy link
Copy Markdown

This PR has pending changes requested. Please address the comments and update the PR before merging.

[ghstack-poisoned]
desertfire added a commit that referenced this pull request Oct 22, 2026
Fixes  #199776.

`test_aoti_inference` has collected no tests in CI since #164277. That change
moved model generation from build time to test time and dropped the rebuild
in the test job, but the binary still depended on its build directory,
`build/test_aoti_inference`, which the build job does not ship (only `build/lib`
and `build/bin` are): `libaoti_custom_class.so` was built there, the generated
data is written there, and `compile_model.py` loaded the library from its cwd,
which only worked because that cwd was the same directory. The binary failed
to start, pytest-cpp skipped it, and run_test.py counted "no tests collected"
as a pass; #199440 made that a failure and dropped the test from
`test_inductor_aoti_cpp`.

`aoti_custom_class` is now built into the default `build/lib`, which is shipped
and already on the binary's RUNPATH. Its path is passed to the test as
`AOTI_CUSTOM_CLASS_LIB` and from there to `compile_model.py` on the command
line. The test creates the data directory before generating into it. The
remaining build-time paths (data directory, test sources) still resolve in the
test job because CI builds and tests in the same workspace path; making them
fully relocatable (relative to the binary or via an env var) is a larger
change that only matters if the test moves to a job where those paths differ.

`test_inductor_aoti_cpp` also runs in the CPU `inductor_aoti_fallback` job, so
`test.py` now skips its CUDA-only models when CUDA is unavailable, and the
files-exist check only requires `script_model_cuda.pt` when a GPU is visible,
matching the generators; otherwise every test process would regenerate all the
data on CPU, or on a CUDA build without a visible GPU.

Test Plan:

Built with the test enabled on macOS arm64 (CPU). Apple ld rejects
`-Wl,--no-as-needed`, so that flag was dropped locally for this build only. To
mirror a CI test job, `build/test_aoti_inference` was moved aside before
running, so the test had to create it and generate all data itself:

```
BUILD_AOT_INDUCTOR_TEST=1 pip install -e . -v --no-build-isolation
mv build/test_aoti_inference /tmp/
cd test && ../build/bin/test_aoti_inference
```

All 9 CPU tests pass (with the previous commit's consts cpp fix). CUDA tests and
the run_test.py path were not run locally; CI covers them via the a10g
`inductor_cpp_wrapper` job.

This PR was authored with the assistance of Claude (AI).

ghstack-source-id: 6b2be4d
Pull-Request: #201699
github-actions[bot]

This comment was marked as outdated.

@github-actions
github-actions Bot dismissed stale reviews from themself October 22, 2026 23:18

Withdrawn: the automated review of 7b2da50 found nothing blocking.

[ghstack-poisoned]
desertfire added a commit that referenced this pull request Oct 26, 2026
Fixes  #199776.

`test_aoti_inference` has collected no tests in CI since #164277. That change
moved model generation from build time to test time and dropped the rebuild
in the test job, but the binary still depended on its build directory,
`build/test_aoti_inference`, which the build job does not ship (only `build/lib`
and `build/bin` are): `libaoti_custom_class.so` was built there, the generated
data is written there, and `compile_model.py` loaded the library from its cwd,
which only worked because that cwd was the same directory. The binary failed
to start, pytest-cpp skipped it, and run_test.py counted "no tests collected"
as a pass; #199440 made that a failure and dropped the test from
`test_inductor_aoti_cpp`.

`aoti_custom_class` is now built into the default `build/lib`, which is shipped
and already on the binary's RUNPATH. Its path is passed to the test as
`AOTI_CUSTOM_CLASS_LIB` and from there to `compile_model.py` on the command
line. The test creates the data directory before generating into it. The
remaining build-time paths (data directory, test sources) still resolve in the
test job because CI builds and tests in the same workspace path; making them
fully relocatable (relative to the binary or via an env var) is a larger
change that only matters if the test moves to a job where those paths differ.

`test_inductor_aoti_cpp` also runs in the CPU `inductor_aoti_fallback` job, so
`test.py` now skips its CUDA-only models when CUDA is unavailable, and the
files-exist check only requires `script_model_cuda.pt` when a GPU is visible,
matching the generators; otherwise every test process would regenerate all the
data on CPU, or on a CUDA build without a visible GPU.

Test Plan:

Built with the test enabled on macOS arm64 (CPU). Apple ld rejects
`-Wl,--no-as-needed`, so that flag was dropped locally for this build only. To
mirror a CI test job, `build/test_aoti_inference` was moved aside before
running, so the test had to create it and generate all data itself:

```
BUILD_AOT_INDUCTOR_TEST=1 pip install -e . -v --no-build-isolation
mv build/test_aoti_inference /tmp/
cd test && ../build/bin/test_aoti_inference
```

All 9 CPU tests pass (with the previous commit's consts cpp fix). CUDA tests and
the run_test.py path were not run locally; CI covers them via the a10g
`inductor_cpp_wrapper` job.

This PR was authored with the assistance of Claude (AI).

ghstack-source-id: 572755e
Pull-Request: #201699
github-actions[bot]

This comment was marked as outdated.

[ghstack-poisoned]
desertfire added a commit that referenced this pull request Oct 26, 2026
Fixes  #199776.

`test_aoti_inference` has collected no tests in CI since #164277. That change
moved model generation from build time to test time and dropped the rebuild
in the test job, but the binary still depended on its build directory,
`build/test_aoti_inference`, which the build job does not ship (only `build/lib`
and `build/bin` are): `libaoti_custom_class.so` was built there, the generated
data is written there, and `compile_model.py` loaded the library from its cwd,
which only worked because that cwd was the same directory. The binary failed
to start, pytest-cpp skipped it, and run_test.py counted "no tests collected"
as a pass; #199440 made that a failure and dropped the test from
`test_inductor_aoti_cpp`.

`aoti_custom_class` is now built into the default `build/lib`, which is shipped
and already on the binary's RUNPATH. Its path is passed to the test as
`AOTI_CUSTOM_CLASS_LIB` and from there to `compile_model.py` on the command
line. The test creates the data directory before generating into it. The
remaining build-time paths (data directory, test sources) still resolve in the
test job because CI builds and tests in the same workspace path; making them
fully relocatable (relative to the binary or via an env var) is a larger
change that only matters if the test moves to a job where those paths differ.

`test_inductor_aoti_cpp` also runs in the CPU `inductor_aoti_fallback` job, so
`test.py` now skips its CUDA-only models when CUDA is unavailable, and the
files-exist check only requires `script_model_cuda.pt` when a GPU is visible,
matching the generators; otherwise every test process would regenerate all the
data on CPU, or on a CUDA build without a visible GPU.

Test Plan:

Built with the test enabled on macOS arm64 (CPU). Apple ld rejects
`-Wl,--no-as-needed`, so that flag was dropped locally for this build only. To
mirror a CI test job, `build/test_aoti_inference` was moved aside before
running, so the test had to create it and generate all data itself:

```
BUILD_AOT_INDUCTOR_TEST=1 pip install -e . -v --no-build-isolation
mv build/test_aoti_inference /tmp/
cd test && ../build/bin/test_aoti_inference
```

All 9 CPU tests pass (with the previous commit's consts cpp fix). CUDA tests and
the run_test.py path were not run locally; CI covers them via the a10g
`inductor_cpp_wrapper` job.

This PR was authored with the assistance of Claude (AI).

ghstack-source-id: 78e521f
Pull-Request: #201699

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review of df124a7: nothing blocking; ready for human review.

The PR makes test_aoti_inference runnable from CI build artifacts and re-enables it in test_inductor_aoti_cpp. It also turns data-generation failures into hard errors, but that error may cause every test to be reported as skipped instead of failed. Recommendation: Needs Discussion.

⚪ 1 non-blocking finding

A generation failure probably shows up as skipped tests, not failures (medium confidence). The new TORCH_CHECKs run inside ensureTestDataGenerated(), whose only caller is the static AotInductorTest::SetUpTestSuite() (line 1692). Recent googletest releases catch an exception thrown in SetUpTestSuite(), record it on the suite rather than on a test, and Skip() every test in the suite. pytest-cpp runs each test with --gtest_filter, accepts exit code 1, and reports a skip when that test's XML entry is marked skipped. So if test.py or compile_model.py fails in CI (e.g. under TORCHINDUCTOR_LITE_MODE=1 in inductor_aoti_fallback), all AotInductorTest.* cases would show as skipped and run_test.py would pass. Before this PR, each test at least failed in torch::jit::load. Fix: call ensureTestDataGenerated() from a non-static SetUp() so a failure counts against the test, wrapped in ASSERT_NO_THROW or a catch that calls FAIL(). std::call_once is fine there because it re-runs the callable after it throws. Not verified against the pinned googletest. To check, break compile_model.py and run python test/run_test.py --cpp -i cpp/test_aoti_inference.

This review is AI-generated and advisory. Each new automated review replaces the previous one.

@github-actions
github-actions Bot dismissed their stale review October 26, 2026 19:24

Withdrawn: the automated review of df124a7 found nothing blocking.

@desertfire

Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorch-bot pytorch-bot Bot added ready for review Automated review passed, ready for a final review by a maintainer. and removed in progress PR is being worked on by the author, until the automated review accepts it labels Oct 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/inductor ciflow/trunk Trigger trunk jobs on your pull request Merged ready for review Automated review passed, ready for a final review by a maintainer. topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants