Skip to content

[executorch][llm] Share the batching executors' session logic under extension/llm/batching/util - #23371

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

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

Conversation

@Gasoonjia

@Gasoonjia Gasoonjia commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

ModuleExecutor and CudaExecutor (previous diff) carried copies of the same
logic. It moves into util::SessionTable, which both now use:

  • sessions: open/close/clone over the cache's BatchControl, bounded by
    max_sessions, with session ids never reused;
  • pack(BatchInput): flattens a batch onto one token axis with a per-sequence
    cursor, so consecutive chunks of a prompt abut, and truncates reopened
    sequences only after every input has checked out;
  • per-session sampling: one Sampler per generation, drawing a session's token
    from its logits row.

Plus util::select_rows, the logits rows a forward over one slice of a packed
batch selects.

What stays in each executor is what differs: how the program is read and
validated, and how slices map onto methods (one forward for ModuleExecutor;
decode/prefill for CudaExecutor).

No behavior change. Log messages from the moved code now say pack: rather
than build_step:.

Builds as extension_llm_batching_util (CMake) and
//executorch/extension/llm/batching:session_table (Buck).

Differential Revision: D123051482

[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/23371

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

❌ 7 New Failures, 1 Pending, 3 Unclassified Failures

As of commit f2c231d 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 — f2c231d1 Deployed Oct 2, 2026 by Gasoonjia via hifi-op-test / hifi4 #31148
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