Repository navigation
[executorch][cuda] Let the CUDA delegate drive the off-graph KV step - #22989
Merged
Merged
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22989
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New Failure, 2 Pending, 1 Unrelated Failure, 2 Unclassified FailuresAs of commit 0340d66 with merge base 57078b4 ( NEW FAILURE - The following job has failed:
UNCLASSIFIED FAILURES - DrCI could not classify the following jobs because the workflow did not run on the merge base. The failures may be pre-existing on trunk or introduced by this PR:
FLAKY - The following job failed but was likely due to flakiness present on trunk:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This was referenced Sep 22, 2026
This PR needs a
|
Gasoonjia
requested review from
kirklandsign and
larryliu0820
as code owners
September 28, 2026 23:09
metascroy
approved these changes
Sep 30, 2026
meta-codesync Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #22820 * #22819 * #22818 * #22817 * #22989 * #22816 * __->__ #22815 Lower the neutral `kvcache::update_and_attend` contract to runtime-bound private tensors, retain their logical metadata without serializing payloads, and allow the weight loader to defer those bindings. Add validation for manifests and storage omission. Authored with Codex. Differential Revision: D119571985 Pull Request resolved: #22815
meta-codesync Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #22820 * #22819 * #22818 * #22817 * #22989 * __->__ #22816 * #22815 Own dense flat and ring KV allocations in the CUDA runtime, grow flat caches geometrically with stream-ordered preservation, rebind AOTI pointers, and expose reset and memory metrics for the single-session path. Derive allocation size, growth-copy pitch, metrics, and AOTI descriptors from a configurable storage dtype; BF16 remains the default. Authored with Codex. Differential Revision: D119571986 Pull Request resolved: #22816
meta-codesync
Bot
merged commit Oct 1, 2026
2e4b876
into
gh/gasoonjia/191/base
287 of 292 checks passed
meta-codesync Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #22820 * #22819 * #22818 * __->__ #22817 * #22989 * #22816 * #22815 Replace every Muse Glimmer graph-owned flat or ring cache with the neutral `kvcache::update_and_attend` contract while preserving attention semantics. Add the CUDA export opt-in, emit the runtime cache manifest, omit legacy mutable-cache metadata, and reject incompatible TurboQuant configurations. Authored with Codex. Differential Revision: D119571989 Pull Request resolved: #22817
meta-codesync Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #22820 * #22819 * __->__ #22818 * #22817 * #22989 * #22816 * #22815 Load and validate off-graph cache metadata, scope AOTI handle binding, prepare and commit cache state around execution, expose reset and metrics, and reject CUDA graph or multiple sessions. Authored with Codex. Differential Revision: D119571991 Pull Request resolved: #22818
meta-codesync Bot
pushed a commit
that referenced
this pull request
Oct 1, 2026
Stack from [ghstack](https://github.com/ezyang/ghstack/tree/0.15.0) (oldest at bottom): * #22820 * __->__ #22819 * #22818 * #22817 * #22989 * #22816 * #22815 Allow the Muse Glimmer off-graph KV path to use the existing decode-only CUDA Graph backend option. When a flat cache grows and its address changes, release the stale graph resources, rebind the new cache allocation, warm up, and capture a replacement graph. Prefill remains outside CUDA Graph capture. Authored with Codex. Differential Revision: D120091513 Pull Request resolved: #22819
Gasoonjia
added a commit
that referenced
this pull request
Oct 1, 2026
…23294) This PR was created by the merge bot to help merge the original PR into the main branch. ghstack PR number: #22989 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/191/base ghstack PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/191/head Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/gasoonjia/186/orig Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/gasoonjia/191/orig Differential Revision: [D121131873](https://our.internmc.facebook.com/intern/diff/D121131873/) @diff-train-skip-merge --------- Co-authored-by: gasoonjia <gasoonjia@icloud.com> Co-authored-by: Gasoonjia <gasoonjia@meta.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack from ghstack (oldest at bottom):
The runner currently calls prepare_step/commit_step on CudaKVCache, which puts
a backend face in the runner's hands. The delegate is the natural owner: it
already runs on the host immediately before and after the compiled program, and
that is the only point where storage can grow and be rebound before the kernels
read it.
The one thing the delegate cannot work out for itself is how many tokens a step
writes. Lowering compiles the cache op away, so at runtime there is only
compiled code over pre-bound memory and nothing calls back out. The export side
knows the width from its own signature, so it declares where to find it as an
"input_index:dim" compile spec, and the delegate reads that input's extent --
shape metadata only, never contents, which are on device.
Committing from here also pairs the two halves on every exit: a run that fails
never advances the cache past tokens the kernels did not write.
Differential Revision: D121131873