Skip to content

Use caching allocator for runner (#15730)#15730

Open
kimishpatel wants to merge 58 commits intomainfrom
gh/kimishpatel/213/head
Open

Use caching allocator for runner (#15730)#15730
kimishpatel wants to merge 58 commits intomainfrom
gh/kimishpatel/213/head

Conversation

@kimishpatel
Copy link
Copy Markdown
Contributor

@kimishpatel kimishpatel commented Nov 11, 2025

Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038

When doing prefill for quantized kv cache, with large prefill length, parallelizing this op helps.

Differential Revision: [D84962234](https://our.internmc.facebook.com/intern/diff/D84962234/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D84962234/)!

[ghstack-poisoned]
Reason this doesnt directly use Vectorize class is because the equivalent APIs dont exist in Vectorize class

Differential Revision: [D84962236](https://our.internmc.facebook.com/intern/diff/D84962236/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D84962236/)!

[ghstack-poisoned]
As the title

Differential Revision: [D84962233](https://our.internmc.facebook.com/intern/diff/D84962233/)

**NOTE FOR REVIEWERS**: This PR has internal Meta-specific changes or comments, please review them on [Phabricator](https://our.internmc.facebook.com/intern/diff/D84962233/)!

[ghstack-poisoned]
For small models dequantizing portions of v cache causes extra alloc overhead.

Probably a better way to handle this is to dequantize entire v cache outside the model

There isnt significant perf advantage from this yet but subsequent diffs will use caching allocator where this refactor help.

Differential Revision: [D85532077](https://our.internmc.facebook.com/intern/diff/D85532077/)

[ghstack-poisoned]
Meant to use this for temp allocator for kernels. Specifically for sdpa, it seems that on iOS there is a significant overhead coming from allocations

Differential Revision: [D85532079](https://our.internmc.facebook.com/intern/diff/D85532079/)

[ghstack-poisoned]
…allocator"

Meant to use this for temp allocator for kernels. Specifically for sdpa, it seems that on iOS there is a significant overhead coming from allocations

Differential Revision: [D85532079](https://our.internmc.facebook.com/intern/diff/D85532079/)

[ghstack-poisoned]
Meant to use this for temp allocator for kernels. Specifically for sdpa, it seems that on iOS there is a significant overhead coming from allocations

Differential Revision: [D85532079](https://our.internmc.facebook.com/intern/diff/D85532079/)

[ghstack-poisoned]
…allocator"

Meant to use this for temp allocator for kernels. Specifically for sdpa, it seems that on iOS there is a significant overhead coming from allocations

Differential Revision: [D85532079](https://our.internmc.facebook.com/intern/diff/D85532079/)

[ghstack-poisoned]
Meant to use this for temp allocator for kernels. Specifically for sdpa, it seems that on iOS there is a significant overhead coming from allocations

Differential Revision: [D85532079](https://our.internmc.facebook.com/intern/diff/D85532079/)

[ghstack-poisoned]
…allocator"

Meant to use this for temp allocator for kernels. Specifically for sdpa, it seems that on iOS there is a significant overhead coming from allocations

Differential Revision: [D85532079](https://our.internmc.facebook.com/intern/diff/D85532079/)

[ghstack-poisoned]
Meant to use this for temp allocator for kernels. Specifically for sdpa, it seems that on iOS there is a significant overhead coming from allocations

Differential Revision: [D85532079](https://our.internmc.facebook.com/intern/diff/D85532079/)

[ghstack-poisoned]
…allocator"

Meant to use this for temp allocator for kernels. Specifically for sdpa, it seems that on iOS there is a significant overhead coming from allocations

Differential Revision: [D85532079](https://our.internmc.facebook.com/intern/diff/D85532079/)

[ghstack-poisoned]
Meant to use this for temp allocator for kernels. Specifically for sdpa, it seems that on iOS there is a significant overhead coming from allocations

Differential Revision: [D85532079](https://our.internmc.facebook.com/intern/diff/D85532079/)

[ghstack-poisoned]
This allows us to leverage temp memory allocator and if that allocator is caching allocator it reduces the allocaiton overhead.

Differential Revision: [D85532076](https://our.internmc.facebook.com/intern/diff/D85532076/)

[ghstack-poisoned]
Existing constructors dont compose well such that if you want data loader or data files constructor then you cannot get to override memory allocator.
Fix that.

Differential Revision: [D86120037](https://our.internmc.facebook.com/intern/diff/D86120037/)

[ghstack-poisoned]
@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Nov 11, 2025

🔗 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.

❗ 1 Active SEVs

There are 1 currently active SEVs. If your PR is affected, please view them below:

❌ 2 Cancelled Jobs, 2 Unrelated Failures

As of commit c75df37 with merge base eef7921 (image):

CANCELLED JOBS - The following jobs were cancelled. Please retry:

BROKEN TRUNK - The following jobs failed but were present on the merge base:

👉 Rebase onto the `viable/strict` branch to avoid these failures

This comment was automatically generated by Dr. CI and updates every 15 minutes.

kimishpatel added a commit that referenced this pull request Nov 11, 2025
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
@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Nov 11, 2025
kimishpatel added a commit that referenced this pull request Dec 7, 2025
Pull Request resolved: #15730

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 327688519
@exported-using-ghexport

Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/)
@kimishpatel kimishpatel changed the base branch from gh/kimishpatel/213/base to main December 8, 2025 00:03
…r runner"

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]
kimishpatel added a commit that referenced this pull request Dec 9, 2025
Pull Request resolved: #15730

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
@exported-using-ghexport

Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/)
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 8, 2026

Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as Stale.
Feel free to remove the Stale label if you feel this was a mistake.
If you are unable to remove the Stale label please contact a maintainer in order to do so.
If you want the bot to never mark this PR stale again, add the no-stale label.
Stale pull requests will automatically be closed after 30 days of inactivity.

@github-actions github-actions Bot added the stale PRs inactive for over 60 days label Feb 8, 2026
@meta-codesync meta-codesync Bot changed the title [Executorch][LLM] Use caching allocator for runner Use caching allocator for runner (#15730) Mar 30, 2026
meta-codesync Bot pushed a commit that referenced this pull request Mar 30, 2026
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038
@meta-codesync meta-codesync Bot force-pushed the gh/kimishpatel/213/head branch from 3cd0176 to 32ebe0f Compare March 30, 2026 16:11
@meta-codesync
Copy link
Copy Markdown
Contributor

meta-codesync Bot commented Mar 30, 2026

@kimishpatel has exported this pull request. If you are a Meta employee, you can view the originating Diff in D86120038.

Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038
@meta-codesync meta-codesync Bot force-pushed the gh/kimishpatel/213/head branch from 32ebe0f to 6ebb435 Compare April 6, 2026 15:18
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Apr 15, 2026
Pull Request resolved: #15730

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 367670359
@exported-using-ghexport

Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/)
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Apr 16, 2026
Pull Request resolved: #15730

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 368353572
@exported-using-ghexport

Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/)
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Apr 17, 2026
Pull Request resolved: #15730

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 368981082
@exported-using-ghexport

Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/)
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Apr 17, 2026
Pull Request resolved: #15730

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 368983883
@exported-using-ghexport

Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/)
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Apr 20, 2026
Pull Request resolved: #15730

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 369818674
@exported-using-ghexport

Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/)
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
Summary:

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 328001114
exported-using-ghexport

Reviewed By: navsud, derekdixu

Differential Revision: D86120038




[ghstack-poisoned]
kimishpatel added a commit that referenced this pull request Apr 24, 2026
Pull Request resolved: #15730

We observed that on iOS it improves perf by 6% because SDPA op does temp allocations.

No significant difference on android though.
ghstack-source-id: 372501554
@exported-using-ghexport

Differential Revision: [D86120038](https://our.internmc.facebook.com/intern/diff/D86120038/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. fb-exported meta-exported stale PRs inactive for over 60 days

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants