Skip to content

[executorch][muse] Add export_solo_batching.py - #23373

Open
Gasoonjia wants to merge 1 commit into
gh/Gasoonjia/40/basefrom
gh/Gasoonjia/40/head
Open

Gasoonjia wants to merge 1 commit into
gh/Gasoonjia/40/basefrom
gh/Gasoonjia/40/head

Conversation

@Gasoonjia

@Gasoonjia Gasoonjia commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

Exports Muse Glimmer text generation as the artifact CudaExecutor drives. It
lives beside the single-sequence export_solo.py, which it leaves untouched.

Two methods over one set of weights, both (tokens[1, T], input_pos[T], logits_to_keep[K]) -> logits[K, vocab] float32:

  • decode: T = K = 1, static; the runtime captures it into a CUDA graph.
  • prefill: T and K in [5, W], dynamic. MG's quantized linears switch kernels
    at M <= 4, so a dynamic width only traces from 5, as in export_solo;
    get_min_prefill_chunk = 5 tells CudaExecutor to run narrower slices as
    decodes.

The whole step runs through the decoder so every token's K/V reaches the
cache; only the rows the batch samples pass through the LM head.

The delegate reads the step's token count from input_pos[T], the cache
ops' position, as the backend's CheckOffGraphKVStepWidthPass requires. The
spec names a delegate input, and the delegate's inputs need not follow the
method's order: decode's delegate takes (tokens, input_pos, logits_to_keep) (spec 1:0), while prefill reads logits_to_keep's
symbolic size first and takes (tokens, logits_to_keep, input_pos) (spec
2:0). Sampling happens on the host, per session, so logits are not kept on
the device.

Reuses export_solo's loaders and constant methods and the off-graph source
transform, whose manifest gains layout: cell and max_cells. Adds the
metadata CudaExecutor reads: get_max_context_len,
get_logits_to_keep_mode = selected, get_offgraph_kv_max_cells, and the
cache geometry.

CLI: --gguf | --prequantized | --checkpoint-dir, --max-seq-len (the
per-session context), --max-step-tokens (W, default 512), --max-cells
(the shared pool, default 65536; memory grows with use).

The new test also joins the OSS unittest-cuda job, where MG's CUDA tests did
not run before.

Differential Revision: D123051484

[ghstack-poisoned]
@pytorch-bot

pytorch-bot Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

🔗 Helpful Links

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

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

❌ 6 New Failures, 2 Unclassified Failures

As of commit d91f120 with merge base c16dd0a (image):

NEW FAILURES - The following jobs have 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:

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

@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

@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 2, 2026

This branch was successfully deployed

1 active deployment
cadence — d91f120f Deployed Oct 2, 2026 by Gasoonjia via hifi-op-test / hifi4 #31151
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. meta-exported

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant