Build custom portable ops#17642
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/17642
Note: Links to docs will display an error until the docs builds have been completed. ❌ 4 New FailuresAs of commit 0d07e8e with merge base 19de115 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
b1eb06c to
b2c40cb
Compare
3c5b9ae to
d40a142
Compare
There was a problem hiding this comment.
Pull request overview
Adds build + Python import support for portable custom ops (AOT) so OSS Python tests (e.g., memory planning) can load the shared library without Buck-specific mechanisms.
Changes:
- Introduces
EXECUTORCH_BUILD_KERNELS_CUSTOM_AOTCMake option and Torch discovery at root scope. - Builds
portable_custom_ops_aot_libinkernels/portablefor registering custom ops into PyTorch. - Updates
test_memory_planning.pyto importexecutorch.kernels.portableand adds a loaderkernels/portable/__init__.py.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/cmake/preset/pybind.cmake | Enables a new overridable build option in the pybind preset. |
| tools/cmake/preset/default.cmake | Defines the new EXECUTORCH_BUILD_KERNELS_CUSTOM_AOT option. |
| src/executorch/kernels/portable | Adds a symlink-like entry pointing to kernels/portable. |
| kernels/quantized/CMakeLists.txt | Fixes/rewraps a formatting instruction comment. |
| kernels/portable/init.py | Adds runtime discovery + torch.ops.load_library for the custom ops AOT library. |
| kernels/portable/CMakeLists.txt | Builds portable_custom_ops_aot_lib and sets RPATH for runtime loading. |
| exir/tests/test_memory_planning.py | Replaces Buck-only load with importing executorch.kernels.portable. |
| CMakeLists.txt | Finds Torch at root scope when custom AOT is enabled. |
| .lintrunner.toml | Excludes kernels/portable and kernels/quantized from lintrunner. |
Comments suppressed due to low confidence (1)
src/executorch/kernels/portable:1
- This appears to be a symlink-style entry. Git symlinks can degrade into plain text files on some Windows configurations/checkout modes, which can break imports/packaging. If this is part of the Python package layout, consider replacing it with a real package directory (e.g.,
src/executorch/kernels/portable/__init__.pythat re-exports) or adjust packaging configuration to includekernels/portablewithout relying on symlinks.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| set_target_properties( | ||
| portable_custom_ops_aot_lib PROPERTIES BUILD_RPATH ${RPATH} INSTALL_RPATH | ||
| ${RPATH} | ||
| ) |
There was a problem hiding this comment.
This adds the portable_custom_ops_aot_lib target but does not add any install(TARGETS ...) rule (or otherwise ensure the built shared library ends up inside the Python package/wheel). Since kernels/portable/__init__.py tries to discover and load the library at runtime, missing installation/packaging will prevent import executorch.kernels.portable from actually registering ops in an installed environment. Add an install rule consistent with the quantized AOT library pattern and align it with the loader’s expected search location.
| ) | |
| ) | |
| install( | |
| TARGETS portable_custom_ops_aot_lib | |
| EXPORT ExecuTorchTargets | |
| DESTINATION ${CMAKE_INSTALL_LIBDIR}/executorch/extensions/pybindings | |
| ) |
d40a142 to
cbc0f54
Compare
cbc0f54 to
0029e05
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0029e05 to
363b81e
Compare
363b81e to
003983e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
003983e to
db0252d
Compare
db0252d to
a433fb8
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a433fb8 to
0301fa3
Compare
0301fa3 to
0d07e8e
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Build custom portable ops, allow for easy import in python. This is mostly for testing but it does allow us to run memory planning tests (and potentially others) in OSS.
Test plan
Confirm memory planning can be tested in python
Confirm buck test still works