Repository navigation
Conversation
CudaExecutor rejected a cell-layout serving configuration with only "N sessions of T tokens exceed the program's C cells". Break the resident sessions down into live sessions, retained prefix entries and capture slots, show the cells needed (sessions x tokens + 1 padding) against those available, the largest per-session context that fits, and the --max-cells a re-export would need with its K/V size. When the model has sliding-window layers, point at --kv-layout sequence. The resident-sequence check gets the same breakdown, worded per layout: the sequence layout suggests a larger --max-kv-seqs, the cell layout explains its 64-sequence limit. The DFlash target receives the breakdown too, and a too-small DFlash draft cell pool reports its histories plus temporary draft-block cells against --draft-max-cells. Error codes are unchanged. The arithmetic lives in a pure header, kv_capacity.h, with unit tests that CUDA CI now builds and runs. export_solo prints the implied per-session context and full-size K/V before lowering, and BATCHING_SERVING.md documents the cell budget, a worked 128K example and when the sequence layout is preferable. Fixes #25648
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/25725
Note: Links to docs will display an error until the docs builds have been completed. ✅ You can merge normally! (1 Unrelated Failure)As of commit 927019b with merge base 2bb454f ( BROKEN TRUNK - The following job failed but were present on the merge base:👉 Rebase onto the `viable/strict` branch to avoid these failures
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude /pr-review Please review this PR (head |
This PR needs a
|
|
Claude finished @Gasoonjia's task in 21m 27s —— View job Request Changes: in reachable setups the new KV-capacity advice is wrong (more than 64 resident sessions, DFlash draft pools) or missing (the default automatic-context mode), and Detailed reviewPR Review: #25725SummaryThis PR explains
The backend's public header also hard-codes one example's export flags. This review comes from reading the code; nothing was built or run. Code Quality
API Design
Testing
RecommendationRequest Changes What this PR adds is the advice and numbers it prints. In reachable configurations (more than 64 resident sessions, any DFlash export, the native worker's default automatic-context mode) they are wrong or missing. The fixes are small and stay in |
…nd automatic-context advice Backend (backends/cuda/batching): - kv_capacity.h keeps only flag-neutral arithmetic and wording: the cell budget, the session breakdown, memory formatting, cell_pool_facts (now sized with elementSize for every valid dtype, and GPU-free) and a structured KvCapacityReport whose describe_capacity() explains layout limits without naming any export or serving option. - CudaExecutorConfig::capacity_report replaces capacity_note: the executor logs and hands every report to the caller -- automatic context mode's resolved budget (INFO), a budget of zero, a cell shortfall and a session limit. The cell layout's 64-session limit is reported in preference to a cell shortfall, whose advice no longer suggests a token limit or cell count that cannot work; the zero-budget advice respects the token limit. - reservations must total max_sessions (or be empty); a mismatch is an InvalidArgument instead of being silently dropped. - test_cuda_executor observes the reports, telling the cell-pool and session-limit paths apart, and the automatic budget. Muse Glimmer (examples/models/muse-glimmer): - runtime/kv_capacity_advice.h owns the flag-specific advice (--max-cells, --kv-layout sequence, --max-kv-seqs, --draft-max-cells, the worker's reservation and token-limit flags) and the DFlash draft admission rule, which the DFlash executor now uses for its check unchanged. - The DFlash executor caps the target advice by the draft pool's per-session budget, explains a draft shortfall by its actual reason (target budget, draft budget at or below the block, or a requested limit), and logs the resolved DFlash context in automatic mode. - export_solo's summary includes the DFlash draft pool's per-session limit and K/V; BATCHING_SERVING.md documents the draft term, the 64-session cap and automatic-mode logging. - The Python test derives the geometry from MuseGlimmerConfig and checks DFlash pools on synthetic inputs. No capacity behavior changes beyond rejecting an inconsistent breakdown.
|
@claude /pr-review Please review the current head
A100 (CUDA 13.2): test_kv_capacity 17, test_cuda_executor 33, muse_glimmer_cuda_dflash 40, test_step_plan 8, test_cuda_kv_cache 61, batching 227, Muse-Glimmer ctest, pytest 10, all passing. |
|
Claude finished @Gasoonjia's task in 22m 12s —— View job Request Changes: the follow-up fixes most of the last review, but some of the new advice still ends in a second startup failure if a user follows it. The DFlash Detailed reviewPR Review: #25725SummaryThis PR explains
Also, the reservation advice uses the native worker's flag spellings only. This review comes from reading the code. Nothing was built or run. Code Quality
RecommendationRequest Changes What this PR adds is advice users can follow. With the default draft pool, a DFlash cell-shortfall re-export at the advised |
…check Backend (backends/cuda/batching): - check_admission() and automatic_session_tokens() are the executor's KV admission rule, shared with the advice. Automatic context mode checks the layout's session limit (64 cells or the declared sequence columns) before reporting a budget, and a session-limit rejection is reported once. - An admitted explicit limit is reported too (kAdmitted, nothing logged), so callers always learn the target pool's limits; reports carry whether the context was automatic. - The session-limit wording uses the sessions the cells actually hold when a token budget is known. Muse Glimmer (examples/models/muse-glimmer): - kv_capacity_advice.h models the startup checks with check_startup() (CudaExecutor's check_admission(), the factories' token checks and the DFlash draft_admission()) and builds structured fixes -- fewer sessions, a token-limit range, a cell re-export, more sequence columns, a sequence layout, longer draft sequences -- offering each only if, applied alone, it passes every check. A refusal no single option fixes is described. - DFlash advice takes the DraftPool: re-exports size --draft-max-cells (sessions x tokens + owners x block + 1) as well as --max-cells, note the default draft pool, quote both pools' K/V, keep token limits above the block, never resolve to one-token sessions, and ask only for draft cells when only the draft limits an automatic context. Draft shortfalls with a requested limit are sized for that limit. - Flags are named in both the worker's and serve_batching's spellings, with a note that capture slots size themselves unless set explicitly. - The token and size rules are shared, not restated: CudaExecutor calls valid_session_limits(), within_context() and valid_cell_count() (kv_capacity.h), the factories call valid_requested_tokens() and holds_prompt_and_prediction() (kv_capacity_advice.h), and check_startup() calls the same functions, including the int limits on sessions x tokens and on target and draft cells. - A GPU-free closure test applies every fix over a grid of 3136 layouts, DFlash pools, session counts, token limits, cells, splits and blocks, and checks each passes every capacity check at its least favorable value. It also reads the fixes back from the advice text alone and checks those, and checks that every candidate left out fails. On the backend toy program, the real CudaExecutor admits each advised serving change. - test_cuda_executor checks that 65 automatic sessions with a positive budget yield exactly one session-limit report, and that an admitted explicit limit is reported. Diagnostics and docs only; capacity behavior is unchanged.
|
@claude /pr-review Please review the current head
A100: test_kv_capacity 22, test_cuda_executor 36, muse_glimmer_cuda_dflash 41, test_step_plan 8, test_cuda_kv_cache 61, batching 227, Muse-Glimmer ctest, pytest 10, all passing. |
…I check
- export_dflash's off-graph export (MLX or CUDA batching) uses the
checkpoint's native context and ignores --max-seq-len. The sequence-layout
DFlash note now says a session holds at most the program's context (the
draft's rows) less the block, and names --max_session_tokens/--max-context.
BATCHING_SERVING.md says so and gives the DFlash formula with the native
context; export_dflash warns when --max-seq-len is set on that path.
- draft_notes() takes the DFlash executor's own DraftAdmission instead of
recomputing it, and branches on the requested limit alone.
- The DFlash executor checks its draft packed-tensor shapes separately,
before admission: a malformed program now fails with InvalidProgram ("DFlash
draft packed tensors do not match the published owners and step width")
instead of InvalidArgument, and gets no capacity notes. A draft pool too
small for the sessions still fails with InvalidArgument, as before.
- The cell layout's session-limit line never reports "0 sessions ... fit";
it says one session alone needs more cells.
- The session limit is the program's count throughout; the no-op update
after the cache was built is gone, and the sequence report test is
renamed accordingly. A new test generates on the toy's batched-sequence
artifact and matches its expected continuations.
Runtime admission is otherwise unchanged.
|
@claude /pr-review Please review the current head
|
|
Claude finished @Gasoonjia's task in 26m 49s —— View job Request Changes: the new sequence-layout DFlash note and Detailed reviewPR Review: #25725SummaryThis PR explains At
This review comes from reading the code. Nothing was built or run. The new sequence generation test in Code Quality
API Design
RecommendationRequest Changes The point of this PR is to say where a KV limit comes from. On a DFlash sequence export whose draft and target contexts differ, the new note and doc name the program's context as the limit. The limit is actually the draft checkpoint's context. Fixing it means rewording three places, and the export summary already gets it right. The other findings are minor. |
- The sequence-layout DFlash refusal now states only figures the runtime reads from the program: the draft program holds N rows per session; with a B-token block a session can hold at most N - B tokens; R were requested (--max_session_tokens/--max-context). It no longer claims where N comes from. - draft_notes() takes every figure from the DFlash executor's admission (max_context, fits) and the program's pool; it no longer recomputes the draft budget. - Cell-layout draft-pool notes name the export flag that sized the pool: --draft-max-cells, default --max-cells. The sequence layout's per-session rows have no flag. - BATCHING_SERVING.md: export_dflash's off-graph export loads the target with the checkpoint's native context and warns only when --max-seq-len differs from its default; on the sequence layout a CUDA batching export gives the draft the draft GGUF's dflash.context_length rows per session (default 131072), whatever the target's context, so a DFlash session holds at most min(program context, draft rows - block). export_dflash's --max-seq-len help says off-graph export ignores it. Runtime behavior is unchanged.
|
@claude /pr-review Please review the current head
Runtime behavior is unchanged; only notes, docs, help text and tests changed. A100: test_kv_capacity 20, test_cuda_executor 38, test_step_plan 8, test_cuda_kv_cache 61, batching 227, Muse-Glimmer ctest (DFlash 40), pytest 11, all passing. |
|
Claude finished @Gasoonjia's task in 22m 6s —— View job Approve: at Detailed reviewPR Review: #25725SummaryThis PR explains KV capacity in the startup errors of CudaExecutor and the DFlash executor, in the export summary and in
Nothing blocks; two minor items follow. I reviewed by reading the code at API Design
Testing
RecommendationApprove. Nothing blocks. Both items are small (one sentence of docs wording, one test case) and can land in this PR or a follow-up. |
…word the limit - BATCHING_SERVING.md: the default --max-cells is 65536 and --draft-max-cells defaults to it, so the 8187-token draft example now states its --max-cells 131072 and the arithmetic, floor((131072 - 1 - 64) / 16). - The sequence-layout automatic-mode draft note says the draft "limits each session" rather than "limits them", which had no antecedent; a new test pins the line.
|
Thanks for the approval. I pushed
|
Muse-Glimmer CUDA serving rejected a 128K cell-layout export with only "N sessions of T tokens exceed C cells", which made
--max-seq-leneasy to mistake for usable per-session context (#25648).This PR reports KV capacity facts where users hit them:
Startup.
CudaExecutorbuilds a structured, flag-neutral capacity report and logs it, and the caller can receive it throughCudaExecutorConfig::capacity_report. It covers:Accept/reject behavior and error codes are unchanged, except that a reservation breakdown must add up to
max_sessions.Muse-Glimmer notes. The example layer adds factual notes: which pool refused (target or DFlash draft); the draft's cells, sessions and temporary block cells when the draft is the limit; the resident-session flags in both spellings; a pointer to the sizing docs; and a hint that the sequence layout, also available to DFlash exports, is recommended for long contexts with sliding-window models. No option values are prescribed.
Export.
export_soloprints the context per session and the full K/V size, target plus draft, before lowering.Docs.
BATCHING_SERVING.mddocuments the cell and sequence layout budgets,min(--max-seq-len, floor((--max-cells - 1) / resident sessions))per session, and DFlash draft sizing (sessions × tokens + owners × block + 1). It works a 128K example: 16 × 131072 cells is about 104 GiB of BF16 K/V in the cell layout, vs about 29 GiB in the sequence layout.The arithmetic lives in a GPU-free header (
backends/cuda/batching/kv_capacity.h). Unit tests aretest_kv_capacity, added to CUDA CI, plus executor report tests on the toy program, Muse-Glimmer note tests and a Python test of the export summary.Test plan (A100, CUDA 13.2):
test_kv_capacity20/20;test_cuda_executor38/38, including a real toy program on the cell layout and a 4-column sequence-layout toy (session-limit reports and eager-matched generation);test_step_plan8/8;test_cuda_kv_cache61/61;extension_llm_batching_test227/227; Muse-Glimmer ctest including the DFlash test (30 cases, 12 of them GPU-free capacity-note tests); pytest 11/11. No skips.Behavior note: apart from the reservation-breakdown check, accept/reject behavior is unchanged. The one exception is a malformed DFlash draft program, whose packed tensors don't match the published owners and step width: it now fails with InvalidProgram and an ABI message, instead of the draft-capacity InvalidArgument.
export_dflashwarns that its off-graph export uses the checkpoint's native context and ignores--max-seq-len.Fixes #25648