-
Notifications
You must be signed in to change notification settings - Fork 730
[Executorch][LLM] Use caching allocator for runner #15730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: gh/kimishpatel/213/base
Are you sure you want to change the base?
Conversation
We observed that on iOS it improves perf by 6% because SDPA op does temp allocations. No significant difference on android though. Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/) [ghstack-poisoned]
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/15730
Note: Links to docs will display an error until the docs builds have been completed. ❌ 122 New FailuresAs of commit 5cecbfc with merge base 7600df8 ( NEW FAILURES - The following jobs have failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
We observed that on iOS it improves perf by 6% because SDPA op does temp allocations. No significant difference on android though. Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/) ghstack-source-id: 322321964 Pull Request resolved: #15730
This PR needs a
|
We observed that on iOS it improves perf by 6% because SDPA op does temp allocations. No significant difference on android though. Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/) [ghstack-poisoned]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request integrates a CPU caching allocator into the LLM runner to improve performance by reducing temporary memory allocation overhead during inference. According to the PR description, this change provides a 6% performance improvement on iOS for operations like SDPA that perform temporary allocations, though no significant difference was observed on Android.
Key changes:
- Added CPUCachingAllocator as a temporary memory allocator for Module instances
- Updated build system dependencies in targets.bzl, CMakeLists.txt files
- Configured allocator with a 10MB cache size for temporary allocations
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| extension/llm/runner/targets.bzl | Added dependency on cpu_caching_allocator for Buck build system |
| extension/llm/runner/llm_runner_helper.cpp | Instantiated CPUCachingAllocator with 10MB cache for Module temp allocations |
| extension/llm/runner/CMakeLists.txt | Added extension_memory_allocator to runner dependencies for CMake |
| CMakeLists.txt | Added memory_allocator subdirectory to build when LLM runner is enabled |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| endif() | ||
|
|
||
| if(EXECUTORCH_BUILD_EXTENSION_LLM_RUNNER) | ||
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/memory_allocator/runner) |
Copilot
AI
Nov 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path extension/memory_allocator/runner does not exist in the repository. The memory allocator CMakeLists.txt is located at extension/memory_allocator/CMakeLists.txt. This line should be:
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/memory_allocator)| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/memory_allocator/runner) | |
| add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/extension/memory_allocator) |
|
|
||
| // Create the Module | ||
| std::unique_ptr<Module> module; | ||
| uint32_t max_cached_memory_size_bytes_ = 1024 * 1024 * 10; // 10MB |
Copilot
AI
Nov 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hardcoded value of 10MB for the caching allocator size should be documented or made configurable. According to the PR description, this improves performance by 6% on iOS for SDPA op temp allocations, but different models or use cases may benefit from different cache sizes. Consider:
- Adding a comment explaining why 10MB was chosen
- Making this value configurable through a parameter or constant
- Documenting the performance implications in code comments
Stack from ghstack (oldest at bottom):
We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.
No significant difference on android though.
Differential Revision: D86120038