Skip to content

[executorch][muse] Export the batching contract for CUDA with --use-offgraph-kv-cache - #24005

Merged
Gasoonjia merged 1 commit into
gh/Gasoonjia/43/origfrom
gh/Gasoonjia/45/orig
Oct 20, 2026
Merged

Gasoonjia merged 1 commit into
gh/Gasoonjia/43/origfrom
gh/Gasoonjia/45/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: #23729 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/45/base
ghstack PR head: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/45/head
Merge bot PR base: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/43/orig
Merge bot PR head: https://github.com/pytorch/executorch/tree/gh/Gasoonjia/45/orig
Differential Revision: D124871956
@diff-train-skip-merge

…ffgraph-kv-cache

Pull Request resolved: #23729

`export_solo.py --use-offgraph-kv-cache` now means the same thing on both
backends: export the contract the batching runtime drives. MLX already wrote
its selected-logits decoder there; CUDA now writes the text-only artifact
CudaExecutor (backends/cuda/batching) runs, over one set of weights and a
cell-layout off-graph KV cache:

- `forward_{N}` for N in `--forward-sizes` (default 1, 2, 4, ..., 64): static,
  T = K = N, each captured into a CUDA graph at runtime. Their quantized linears
  trace the smallest QuantizedGemmFamily bucket that holds N.
- `forward_others`: dynamic, T in [max N, `--max-step-tokens`] (default 4096).
- `sample` / `sample_argmax` (extension/llm/batching/sampler.py) so logits stay
  on the device; the existing `--logits` returns them to the host instead.
- Metadata: selected logits, native context, cache geometry, min prefill chunk,
  and `get_offgraph_kv_max_cells` (`--max-cells`, default 65536).

Without the flag CUDA is unchanged: the in-graph `embed_text`,
`forward_from_embeddings` (prefill) and `decode_from_embedding` (decode).
`--mmproj` with the flag on CUDA is a usage error, since the batching artifact
is text-only.

Every forward method declares its step width at input_pos, delegate input 1
(D124428885): forward_others keeps the exported input order too, which the
CUDA backend's CheckOffGraphKVStepWidthPass checks.

This replaces the single-sequence off-graph CUDA export that only the solo
engine's runtime-owned-cache path consumed, and with it the
`solo-text-offgraph` CI mode that ran it through `solo_runner`. CUDA batching
gets its own CI mode later in this stack. The solo engine's now unreachable
off-graph plumbing is left for a separate cleanup.

The exporter is the landable form of the CUDA batching experiments (D123051484,
D124377337, D124377340, D124377341, D124428885), cell layout only; the batched-sequence
layout is out of scope.
ghstack-source-id: 451855082
@exported-using-ghexport

Differential Revision: [D124871956](https://our.internmc.facebook.com/intern/diff/D124871956/)
@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/24005

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

⏳ No Failures, 381 Pending

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

UNSTABLE - The following job is marked as unstable, possibly due to flakiness on trunk:

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 611a5c0 into main Oct 20, 2026
468 of 476 checks passed
@Gasoonjia
Gasoonjia deleted the gh/Gasoonjia/45/orig branch October 20, 2026 03:43
@Gasoonjia
Gasoonjia deployed to upload-benchmark-results October 20, 2026 07:16 — with GitHub Actions Active

This branch was successfully deployed

2 active deployments
upload-benchmark-results — 360babae Deployed Oct 20, 2026 by Gasoonjia via upload-benchmark-results #21102
cadence — 360babae Deployed Oct 20, 2026 by Gasoonjia via hifi-op-test / hifi4 #34137
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