Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23393
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Cancelled Job, 1 Unclassified FailureAs of commit d07e206 with merge base 61ec450 ( UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
CANCELLED JOB - The following job was cancelled. Please retry:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
c14c6ea to
836b175
Compare
2f63441 to
12fd39f
Compare
836b175 to
a6f16ff
Compare
12fd39f to
1beeef8
Compare
|
@claude review this PR |
|
Claude finished @metascroy's task in 2m 21s —— View job This PR wires the Core AI bridge into a Detailed reviewPR Review: #23393SummaryThis PR adds API Design
Code Quality
Testing
RecommendationApprove (once the error codes are settled). None of these findings blocks the PR. The error-code change is the one to make before merge, because the codes become observable behaviour. |
a6f16ff to
ed11289
Compare
1beeef8 to
61e2774
Compare
|
@claude review this code Updated head: Context on the previous findings: output failure handling is deliberately not transactional. Earlier output shapes may change before a later resize fails, but no result bytes are copied unless every output validates and resizes successfully. Callers must not use outputs as inference results after an error. We documented and tested this contract rather than adding shape rollback or duplicating runtime resize rules. Rejecting output dtype mismatches before inference would require model-output metadata the current handle does not expose; that bridge expansion was not necessary for the error-classification fix. Malformed SDK outputs now use |
|
Claude finished @metascroy's task in 3m 43s —— View job The follow-up commit addresses all three earlier findings and matches the contract you described, so there are no blockers left. What remains is minor: one output error code that still escapes the new split, the CTest registration and build wiring for the smoke test, two tests that pass on leftover state, and a stale README section. Detailed reviewPR Review: #23393SummaryThis PR adds the API Design
Infrastructure
Testing
Code Quality
RecommendationApprove. Nothing blocks. The cheapest fixes to make before merge are the Darwin gate on |
Summary: Wire the Core AI bridge into an ExecuTorch `BackendInterface` so `CoreAIBackend` can load and run models. - `runtime/coreai_backend.mm`: the `BackendInterface`. `init` parses the manifest, checks the OS floor, selects the platform/architecture assets, acquires a prepared model through the load coordinator and binds the named function with ordered inputs/outputs. `execute` validates dtype (FP16/FP32), CPU storage, default dim order and contiguity, borrows input bytes without copying, then validates and resizes every output before copying any results. - Build: `backends/apple/coreai/CMakeLists.txt` builds `coreaidelegate` (static, or shared against `executorch_shared`) from the backend sources plus the `coreai_bridge_obj` objects, and links `coreai_swift`. The delegate and its test consumers link with the C++ linker, so ExecuTorch's C/C++ compile options never reach swiftc. - Tests: the fake bridge gains function binding, sessions and execution, plus the C entry points the backend calls, so the real backend runs in `coreai_host_test`. `coreai_runtime_smoke` checks final linkage, registration retention and availability; with `EXECUTORCH_BUILD_TESTS=ON` it is built and registered with CTest, otherwise it is excluded from the default build. - README: execution semantics, device-architecture selection, the default assets root, "Runtime options", and delegate linkage in "Building". `init` and `execute` block their calling thread on Swift concurrency work, so the README tells callers not to invoke them from Swift `async` code. Changes outside `backends/apple/coreai` are CMake only and, like the other backends, only take effect when `EXECUTORCH_BUILD_COREAI=ON`: - `tools/cmake/preset/default.cmake`: `EXECUTORCH_BUILD_COREAI` now requires the data loader extension. - `CMakeLists.txt`: add `coreaidelegate` to the backend list. Test Plan: ``` cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_OSX_DEPLOYMENT_TARGET=27.0 -DEXECUTORCH_BUILD_COREAI=ON \ -DEXECUTORCH_BUILD_TESTS=ON -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON cmake --build build --target backends/apple/coreai/all ctest --test-dir build/backends/apple/coreai --output-on-failure --no-tests=error ``` CTest runs `coreai_host_test` (adding the delegate suite), `coreai_swift_bridge_test` and `coreai_runtime_smoke`. The smoke binary needs OS 27, so locally it is built but not run.
Summary: Distinguish malformed SDK results from incompatible caller output tensors. Exercise ordered multi-input/output execution and make the failure contract explicit: output shapes may change on error, but result bytes are not copied until all outputs pass validation and resizing. Keep failure handling simple without rollback or additional model metadata. Test Plan: All four Core AI CTest suites passed on macOS 27. Native tests verified reversed binding names and distinct output values, unchanged result bytes when a later output cannot resize, malformed output counts, and the updated dtype/rank error classifications. The full Core AI Python suite passed: 113 tests. # Conflicts: # backends/apple/coreai/runtime/test/test_sdk_source_lifetime.py # Please enter the commit message for your changes. Lines starting # with '#' will be kept; you may remove them yourself if you want to. # An empty message aborts the commit. # # interactive rebase in progress; onto 0ac18e1 # Last commands done (2 commands done): # pick e9a3f17 # [CoreAI] Integrate the delegate execute path # pick ed11289 # [CoreAI] Clarify delegate output errors and test multi-output execution # No commands remaining. # You are currently rebasing branch 'coreai-v2/05b-sdk-delegate' on '0ac18e163c'. # # Changes to be committed: # modified: backends/apple/coreai/README.md # modified: backends/apple/coreai/runtime/coreai_backend.mm # modified: backends/apple/coreai/runtime/test/coreai_delegate_test.mm # modified: backends/apple/coreai/runtime/test/coreai_fake_loader.h # modified: backends/apple/coreai/runtime/test/coreai_fake_loader.mm # # Changes not staged for commit: # modified: backends/mlx/third-party/mlx (modified content) #
Classify incompatible output resizing as InvalidArgument and strengthen borrowed-input and empty-tensor assertions. Gate SDK tests on native host deployment support, remove the unused data-loader dependency, expose the installed delegate in EXECUTORCH_LIBRARIES, and update documentation. Test Plan: CMake build and all four CoreAI CTest suites passed: 161 native tests, 18 Swift tests, portable/AOT lifetime probes, and runtime registration smoke. Python: 122 passed. Five delegate regressions passed twenty repetitions. Format and whitespace checks passed. Generic Buck owner validation failed without diagnostics. Additional installed-consumer and platform-matrix validation was stopped before completion.
Retain validated SDK arrays behind non-failing scoped copy callbacks instead of allocating and zeroing intermediate Data payloads. Validate and resize every output before copying directly into executor buffers. When destinations alias inputs or each other, stage all source reads into uninitialized storage before ordered copyback. Keep original borrowed input ranges alive for overlap checks and copying. Test Plan: All 122 CoreAI Python tests passed, including real AOT compilation. All four native CTest targets passed on the owning delegate layer, including real SDK bridge and source-lifetime tests. Added direct-destination/copy-count, partial overlap, cross-output alias, ordered overlapping outputs, SDK storage retention, and deferred copier lifetime coverage. et-extra lintrunner -a and CI clang-format 18.1.3 checks passed. Final code review found no issues.
Summary: Avoid duplicated dtype dispatch as supported scalar types evolve while preserving borrowed inputs and single-copy outputs. Reject conflicting output shape aliases before writing payload bytes, including different shapes with equal byte counts. Test Plan: Reproduced the shared-output shape bug before the fix: execution incorrectly succeeded and invoked output copiers. Regression tests now reject conflicting shapes without copying and preserve ordered copies for matching shapes. CoreAI native/SDK CTest: 4/4 passed, including scalar registry, bit-preserving output layout, lifetime, and delegate tests. Complete CoreAI Python suite: 122 passed. Validation: et-extra lintrunner -a and git diff --check passed. Generic Buck validation still fails at the existing Swift owner lookup without diagnostics.
fcc39d9 to
d07e206
Compare
7872a72 to
19ef724
Compare
Wires the Core AI bridge into an ExecuTorch
BackendInterfacesoCoreAIBackendcan load and run models (runtime/coreai_backend.mm).initparses the manifest, checks the OS floor, selects the platform/architecture assets, acquires a prepared model through the load coordinator and binds the named function with ordered inputs/outputs.executevalidates dtype (FP16/FP32), CPU storage, default dim order and contiguity, borrows input bytes without copying, then validates and resizes every output before copying any results.initandexecuteblock their calling thread on Swift concurrency work, so the README tells callers not to invoke them from Swiftasynccode.backends/apple/coreai/CMakeLists.txtbuildscoreaidelegate(static, or shared againstexecutorch_shared) from the backend sources pluscoreai_bridge_obj, linkingcoreai_swiftwith the C++ linker so ExecuTorch's C/C++ options never reach swiftc.coreai_host_test(delegate suite).coreai_runtime_smokechecks final linkage, registration retention and availability. WithEXECUTORCH_BUILD_TESTS=ONit is built and registered with CTest; otherwise it stays out of the default build.backends/apple/coreaiare CMake only and only take effect whenEXECUTORCH_BUILD_COREAI=ON:tools/cmake/preset/default.cmake:EXECUTORCH_BUILD_COREAIrequires the data loader extension.CMakeLists.txt: addcoreaidelegateto the backend list.Stack: 7 of 9, based on #23392. Review only this PR's commit. Next: #23394.
Test plan: built locally for macOS 27.0;
ctest -Nlistscoreai_host_test,coreai_swift_bridge_testandcoreai_runtime_smoke, which the Core AI workflow runs on the macOS 27 runner. The smoke binary needs OS 27, so it only runs there (first CI run of it).lintrunneris clean.