Skip to content

[executorch][cuda] Test prefix-cache reuse on CudaExecutor - #24008

Merged
Gasoonjia merged 1 commit into
gh/Gasoonjia/47/origfrom
gh/Gasoonjia/48/orig
Oct 20, 2026
Merged

Gasoonjia merged 1 commit into
gh/Gasoonjia/47/origfrom
gh/Gasoonjia/48/orig

Conversation

@Gasoonjia

Copy link
Copy Markdown
Contributor

This PR was created by the merge bot to help merge the original PR into the main branch.
ghstack PR number: #23732 by @Gasoonjia
^ Please use this as the source of truth for the PR details, comments, and reviews
ghstack PR base: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/48/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/48/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/47/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/48/orig
Differential Revision: D124871960
@diff-train-skip-merge

Pull Request resolved: #23732

The serving runtime's opt-in prefix cache (batching::PrefixCache, enabled by
`--prefix_cache_entries`) reuses KV through Session::clone_async, which on CUDA
reaches CudaExecutor::clone -> SessionTable::clone -> CellCache::seq_clone. The
cell layout clones by reference: the snapshot's id joins the owner bits of the
source's cells below the boundary, so reuse shares the prompt's KV instead of
copying it. Nothing needed to change to enable it; this adds the coverage that
shows it is correct on the GPU.

PrefixCacheResumesFromACapturedPrompt, on each toy artifact (dense, sparse,
device_sampling): every prompt's cold generation leaves a snapshot captured at
its prompt boundary. A lookup for the same prompt reuses all but its last token
and one for a prompt extending it reuses the whole snapshot; both resume on the
eager greedy continuation. So the clone carried the prompt's exact KV, and the
source's later decode writes, padding rows and the clones' own writes did not
disturb one another.
ghstack-source-id: 451855087
@exported-using-ghexport

Differential Revision: [D124871960](https://our.internmc.facebook.com/intern/diff/D124871960/)
@pytorch-bot

pytorch-bot Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24008

Note: Links to docs will display an error until the docs builds have been completed.

⏳ No Failures, 189 Pending

As of commit d81042b with merge base 897d28f (image):
💚 Looks good so far! There are no failures yet. 💚

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

@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 Oct 20, 2026
@Gasoonjia
Gasoonjia added this pull request to stack #24012 October 20, 2026 03:42
@Gasoonjia
Gasoonjia merged commit 7ed9cd8 into main Oct 20, 2026
259 of 270 checks passed
@Gasoonjia
Gasoonjia deleted the gh/Gasoonjia/48/orig branch October 20, 2026 03:43
@Gasoonjia
Gasoonjia deployed to upload-benchmark-results October 20, 2026 08:47 — with GitHub Actions Active

This branch was successfully deployed

2 active deployments
upload-benchmark-results — d81042b8 Deployed Oct 20, 2026 by Gasoonjia via upload-benchmark-results #21105
cadence — d81042b8 Deployed Oct 20, 2026 by Gasoonjia via hifi-op-test / hifi4 #34140
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants