Skip to content

[executorch][cuda] Add CudaCellCache - #23367

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

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

Conversation

@Gasoonjia

@Gasoonjia Gasoonjia commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Stack from ghstack (oldest at bottom):

The runtime half of the cell layout: CudaCellCache is
cache::CellCache + CudaKVCache, the CUDA counterpart of MLXCellCache, built
over the CudaKVPool from the previous diff.

  • The neutral CellCache owns the cell table: placement, owner bitsets, and the
    BatchControl verbs (seq_new/clone/rm, rewind, declare_step).
  • The pool owns one growable K/V pool per layer (every layer, window or not,
    keeps its history there), plus the step buffers the cell lowering declares:
    cells, read_len, and one mask_w{window} per distinct window.
  • prepare_step(width, stream) places the declared tokens and writes the
    placement, extent and per-window masks into those buffers on the step's
    stream. Positions follow from the declaration (every token continues its
    sequence), so nothing is read back from the device. The pool grows before
    placement, to the furthest placement could reach, so a failed allocation
    leaves the table untouched.
  • The step buffers never move, so a captured decode graph serves any mix of
    sequences. Only pool growth recaptures.
  • Only mask rows [0, width) and columns [0, read_len) are written; the lowered
    program bounds its sweep by read_len (guarded by a test in the lowering
    diff).

Registered for batched-cell and for batched, as the batch layout this
backend serves.

The mutex is recursive because the base's verbs call each other virtually
(seq_clone takes its id through seq_new).

Differential Revision: D123051479

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

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

❌ 1 New Failure, 5 Unclassified Failures

As of commit 7db538f with merge base c16dd0a (image):

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:

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.

This branch was successfully deployed

1 active deployment
cadence — 7db538fa Deployed Oct 2, 2026 by Gasoonjia via hifi-op-test / hifi4 #31144
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