Repository navigation
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/23395
Note: Links to docs will display an error until the docs builds have been completed. ✅ No FailuresAs of commit 1ec12f2 with merge base 61ec450 ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
7094d5e to
f69015e
Compare
4ab2733 to
d83126b
Compare
d83126b to
25e467e
Compare
f69015e to
011fb30
Compare
|
@claude review this PR |
|
Claude finished @metascroy's task in 2m 32s —— View job This PR adds root-wide and per-PTE Core AI cache clearing; it looks correct, but I'd fix four design issues before merge: the cache key is computed by a copy of the load-path logic, eviction is tested through a function only the tests call, Detailed reviewPR Review: #23395SummaryThe PR adds API Design
Code Quality
Testing
RecommendationRequest Changes The main blocker is the copied key derivation. If it drifts from the load path, clearing will silently do nothing. Moving the eviction tests onto |
011fb30 to
ba2439e
Compare
25e467e to
5b46516
Compare
|
@claude review this code Updated head: Context on the previous findings: the actual key hash already used the same Two intentional contracts remain: (1) incompatible delegates fail before any entry is cleared rather than being silently skipped. Incompatibility does not prove cache absence, and minimum OS is not part of the cache key; success after skipping could conceal incomplete clearing. (2) key validation remains at the destructive storage boundary and has direct invalid-key tests. Please evaluate those contracts explicitly rather than treating their removal as a required cleanup. |
|
Claude finished @metascroy's task in 3m 50s —— View job Head Detailed reviewPR Review: #23395SummaryThe PR adds API Design
Evaluation of the intentional contracts(1) An incompatible delegate fails the whole PTE clear. This is sound for minimum OS but not for platform or architecture mismatches.
(2) Key validation at
RecommendationNeeds Discussion Nothing is unsafe. Before merge, please decide how to recover entries the clear path can't read or evict (clearing an invalid bookmark is a small fix), and narrow contract (1) so that platform/architecture mismatches and an unavailable SDK don't block clearing. |
ba2439e to
f13d818
Compare
5b46516 to
8774f1b
Compare
Summary:
Add public APIs to clear Core AI cache state, either for a whole assets root
or for the models referenced by one PTE.
- `runtime/coreai_cache.{h,mm}`:
- `clear_cache(coreai_assets_dir)` clears every keyed entry in an explicit
assets root.
- `clear_cache_for_pte(loader, dir)` and `clear_cache_for_pte(pte_path, dir)`
clear only the entries for the current platform and architecture that the
PTE's Core AI delegates reference. They find those delegates with
`inspect_coreai_pte`, so no Program/Method is constructed and no Core AI
assets are materialized. Every selected manifest is validated before any
key is cleared. A null directory selects the backend's default root.
- Per key, clearing preflights the staged source tree, evicts the SDK entry,
removes staging, then removes the bookmark. The bookmark is kept until
staging removal succeeds so a failed clear can be retried. SDK errors other
than confirmed absence preserve the key's files. Keys are processed in
sorted order and the first error is returned. Each removal syncs the
directory it changed. Missing roots and entries are no-ops.
- Everything under a keyed `staging/<key>` directory belongs to the backend
and is removed with that key. Outside keyed entries, PTEs, other files, lock
files and unkeyed temporaries are never removed.
- Supporting changes: descriptor-relative keyed staging removal in
`coreai_storage`, bookmark inventory and removal in `coreai_bookmarks`, and
SDK eviction plus per-key clearing in `coreai_load_coordinator`.
- Tests: cache-clearing and eviction suites in `coreai_host_test`.
`coreai_runtime_smoke` also links every public cache-clearing overload.
- README: "Clearing cached assets".
Callers must unload affected models and stop concurrent loads, inference and
maintenance until these calls return. Per-key locks are not a whole-root
barrier.
No changes outside `backends/apple/coreai`.
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 cache-clearing and eviction suites),
`coreai_swift_bridge_test` and `coreai_runtime_smoke`.
Summary: Prevent loading and maintenance from drifting in how they select model assets, and let applications clear the default cache without reconstructing a private path. Exercise real clearing behavior for eviction failures and loaded models while preserving strict compatibility checks and storage validation. Simplify the public maintenance documentation. Test Plan: Built the CoreAI targets and ran all four CTest suites successfully, including native host tests, Swift bridge tests, SDK source-lifetime tests, and runtime smoke coverage. New tests verify portable/AOT load-to-clear identity, isolated default-root clearing, rejection before mutation, and production eviction failure/retry behavior. Ran the complete CoreAI Python suite: 113 passed. Whitespace checks passed. The generic validator could not complete its Buck ownership query; native and Swift validation passed through CMake. # Conflicts: # backends/apple/coreai/runtime/coreai_storage.h # backends/apple/coreai/runtime/coreai_storage.mm # 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 f13d818 # Last commands done (2 commands done): # pick 2fef739 # [CoreAI] Add root and PTE cache clearing # pick 5b46516 # [CoreAI] Align cache clearing with loading and cover production eviction # No commands remaining. # You are currently rebasing branch 'coreai-v2/07-cache-clear' on 'f13d818a91'. # # Changes to be committed: # modified: backends/apple/coreai/README.md # modified: backends/apple/coreai/runtime/coreai_backend.mm # modified: backends/apple/coreai/runtime/coreai_cache.h # modified: backends/apple/coreai/runtime/coreai_cache.mm # modified: backends/apple/coreai/runtime/coreai_load_coordinator.h # modified: backends/apple/coreai/runtime/coreai_load_coordinator.mm # modified: backends/apple/coreai/runtime/coreai_storage.h # modified: backends/apple/coreai/runtime/coreai_storage.mm # modified: backends/apple/coreai/runtime/test/coreai_cache_test.mm # modified: backends/apple/coreai/runtime/test/coreai_delegate_test.mm # modified: backends/apple/coreai/runtime/test/coreai_eviction_test.mm # # Changes not staged for commit: # modified: backends/mlx/third-party/mlx (modified content) #
Clear every recorded variant associated with a PTE regardless of host loading compatibility. Persist durable per-key attribution without changing existing cache keys, and report incomplete cleanup when older entries cannot be safely identified. Recover malformed local entries without following links, while preserving uncertain SDK eviction state for retry. Test Plan: Ran all five CoreAI CTest suites: 236 native tests, 18 Swift tests, PTE export, real SDK source-lifetime checks, and runtime smoke all passed. Coverage includes cross-platform and architecture variants, legacy attribution, malformed entries, publication/removal failures, retry durability, and preservation of outside files. Ran the complete CoreAI Python suite: 124 tests passed. Formatting and whitespace checks passed. The generic Buck Swift owner lookup still fails without diagnostics; CMake build and functional validation passed.
Log eviction request, confirmed SDK absence, and local cleanup completion. Add clear-aware stripe reuse and per-key isolation regressions, and cover durable-save and eviction failure log boundaries. Preserve the previously validated final implementation after placing storage and acquisition changes in their owning PR layers. Test Plan: Exact final CoreAI tree matches the saved validated snapshot: 256 native tests, all five CTest targets, 124 Python tests, and playground rebuild passed. Lower bookmark and acquisition layers were also built and tested independently during placement.
f13d818 to
fb0cea1
Compare
8774f1b to
1ec12f2
Compare
Adds public APIs to clear Core AI cache state, either for a whole assets root or for the models referenced by one PTE (
runtime/coreai_cache.{h,mm}).clear_cache(coreai_assets_dir)clears every keyed entry in an explicit assets root.clear_cache_for_pte(loader, dir)andclear_cache_for_pte(pte_path, dir)clear only the entries for the current platform and architecture that the PTE's Core AI delegates reference. They find those delegates withinspect_coreai_pte, so no Program/Method is constructed and no assets are materialized. Every selected manifest is validated before any key is cleared. A null directory selects the backend's default root.staging/<key>directory belongs to the backend. Outside keyed entries, PTEs, other files, lock files and unkeyed temporaries are never removed.coreai_storage, bookmark inventory/removal incoreai_bookmarks, and SDK eviction plus per-key clearing incoreai_load_coordinator.coreai_host_test;coreai_runtime_smokealso links every public cache-clearing overload.No changes outside
backends/apple/coreai.Stack: 9 of 9, based on #23394. Review only this PR's commit.
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.lintrunneris clean.