Run the Metal backend tests, which are not importable today - #22978
shoumikhin wants to merge 1 commit into
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22978
Note: Links to docs will display an error until the docs builds have been completed. ❗ 1 Active SEVsThere are 1 currently active SEVs. If your PR is affected, please view them below: ⏳ No Failures, 149 PendingAs of commit b2d4da5 with merge base c5d07e4 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
5fb1b55 to
4e134e8
Compare
4e134e8 to
b6ed387
Compare
b6ed387 to
07bc019
Compare
07bc019 to
ac6c53f
Compare
ac6c53f to
c74f55c
Compare
|
The dependency diagnosis and if device_type == "mps":
definitions.append(" USE_MPS")
if _IS_MACOS and aot_mode and not link_libtorch:
ldflags.append("Wl,-dead_strip_dylibs")Inductor adds the leading I would also audit the explicit For regression coverage, test upstream that an unused OpenMP dependency disappears while a referenced one remains. In ExecuTorch, export a small Metal model, assert that its embedded library has no OpenMP dependency under any install name, and run inference in a separate native executable that neither links nor preloads OpenMP. I'd leave the generic Review assisted by Codex. |
backends/apple/metal/tests/test_metal_backend.py imports COMPILE_SPEC_KEYS from metal_backend, where it no longer lives. Importing the file raises, so the five tests in it cannot run, and pytest.ini never listed the path so nothing noticed. Take the name from aoti_backend, where it is defined, and add the file to testpaths. The tests pass as written once they can be imported. The package marker goes with it: the directory has no importable content of its own, and while it is a package the module is named tests rather than something under executorch, which is a top-level name to be claiming.
0407679 to
b2d4da5
Compare
|
You are right on all four points. I checked each one against The The flag is now upstream as pytorch/pytorch#198232, in the mps branch of
The This PR is now reduced to something unrelated that turned up on the way: |
Summary
Reduced. The OpenMP fix has moved upstream to pytorch/pytorch#198232, which adds
-dead_strip_dylibsto the link for AOTI MPS builds that do not link libtorch, per the review here. What is left in this PR is a separate defect found on the way.backends/apple/metal/tests/test_metal_backend.pyimportsCOMPILE_SPEC_KEYSfrommetal_backend, where it no longer lives. Importing the file raises, so its five tests cannot run, andpytest.ininever listed the path so nothing noticed. Take the name fromaoti_backend, where it is defined, and add the file totestpaths.The package marker goes with it. The directory has no importable content of its own, and while it is a package the module is named
testsrather than something underexecutorch, which is a top-level name to be claiming.What is still to do for #22955
libomp.dyliblinkage and the rpaths in the Metal CMake, and the install name rewrite inrun_metal_test.sh, and adds an end to end test that runs inference in a process which neither links nor preloads OpenMP.Step 3 cannot go before step 2. Removing the runner's OpenMP while exported models still name it would pass CI here for the wrong reason, because the exporter and the runner are the same machine and the baked absolute path resolves. That is the property that let this go unnoticed in the first place.
Test plan
pytest backends/apple/metal/tests/test_metal_backend.py, 5 passed. Before this change the same command fails at collection withcannot import name 'COMPILE_SPEC_KEYS'.