epic: Prompt-prefix cache reuse for sliding-window families
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 8/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Ambito
- backend, distributed-systems, performance
Direzione di ricerca
This is an epic tracking four sub-issues (#3255 to #3257, plus #3254) on the scheduler-owned prompt-prefix cache, so it is not a starting point. Read state_checkpoints.rs and the scheduler prompt-cache code, then the ADR 0010 reference migrations for Gemma 3 and Qwen 3.5. Pick a numbered sub-issue instead; this epic is done when all sub-issues merge and the scripts/bench_prompt_cache_replay.py --verify run is recorded in docs/benchmark_results/.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem / Background
Sliding-window families miss the prompt-prefix cache whenever a request diverges before the end of the stored prefix. Measured on GB10 with mlxcel-server 0.8.1, gemma-4-12b-it-4bit, fp16 KV and about 5.8k-token prompts:
- An exact multi-turn continuation hits: 5808/5823 tokens cached, TTFT about 4.9 s down to 0.4-0.56 s.
- An edit, a regenerate, or a new chat with the same system prompt reuses nothing (
snapshot_diverged). The sliding ring (window 1024) has wrapped, and the history-boundary snapshot cannot be truncated. - A desktop client (AI:GO) that edits the previous user message saw
cached_tokens=0on every turn.
Qwen3 under the same conditions reuses up to the divergence point.
The root cause is ownership. Sliding layers are model-owned rings, and every reuse feature is written per family. Among the sliding-window families, only Gemma 3, Gemma 4, AFMoE and Muse Glimmer have snapshot hooks. By code reading on origin/main, gpt-oss, Exaone 4, Ministral 3, Mellum, Laguna, Step 3.5, MiMo V2 Flash and DeepSeek V4 get no prefix reuse at all (see #3254).
Per-token KV in gemma-4-12b-it (40 sliding layers with 8 KV heads x 256, 8 full layers with 1 KV head x 512, K and V both stored) is 320 KiB sliding and 16 KiB full. The computed whole snapshot at 5.8k is about 431 MB, against snapshot_bytes_per_entry 435 MB measured.
| Context | Sliding ring | Full-size sliding | Full-attention KV |
|---|---|---|---|
| 8k | 320 MiB | 2.5 GiB | 128 MiB |
| 32k | 320 MiB | 10 GiB | 512 MiB |
| 128k | 320 MiB | 40 GiB | 2 GiB |
Goal
Rotating families reuse prompt prefixes at any block boundary while the prompt-cache budget holds the sliding blocks, and at the nearest anchor (system root, previous turn) beyond that: across sessions that share a system prompt, and after edits, regenerates and branches. Live memory stays window-bounded, and save, restore, truncation, checkpoints and APC are implemented once in the scheduler instead of per model.
Sub-issues
Phase 1
- #3255
Phase 2
- #3254 (depends on #3255; merged in #3305)
Phase 3
- #3256 (depends on #3254)
Phase 4
- #3257 (depends on #3256)
Acceptance Criteria
- All sub-issues completed and merged
- On gemma-4-12b-it-4bit, the edited-previous-user-message replay (
scripts/bench_prompt_cache_replay.py --verify) reuses up to the edit with outputs equal to cold reruns, recorded indocs/benchmark_results/ - Follow-up issues filed for every family group still model-owned after #3254, linked here
- #3250 re-evaluated against the scheduler-owned layer, with the decision recorded on that issue
Technical Considerations
- #3254 is the foundation. It is sequenced after #3255 because both touch Gemma 3,
state_checkpoints.rsand the scheduler prompt-cache code, and #3254 moves #3255's ring-only checkpoint into the generic path. It adds a scheduler-owned per-layer-kind state abstraction (paged blocks for full attention, window-bounded blocks for sliding, chunked, checkpointed recurrent state), with ADR 0010 and Gemma 3 and Qwen 3.5 as reference migrations. - #3255 is the interim fix and is recommended to ship first. It works on the current snapshot path and is built from what main already has (#2950, #2973, #3037, #3047). After #3256 it stays useful for recurrent families and any family #3256 does not cover.
- #3256 is the main piece.
- #3257 is the opt-in after it.
- #3250 (quantized KV in snapshots) applies today to the snapshot path. Int8 and Turbo sequences are never pool-backed, so the paged sliding design covers FP16 only until #3250 is revisited against #3254.
- #3246 (Prometheus prompt-cache double count) affects
/metricstotals. All acceptance here readscached_tokensand/v1/cache/statsinstead. - App side. The client-side fix, keeping chat history append-only, is tracked separately in lablup/backend.ai-go. It is still needed for remote providers.
Run wrap-up — 2026-11-25
#3255 merged in #3283 and #3254 merged in #3305. The isolated execution-overhead optimization #3385 merged in #3406 (50ac7182), with the owner accepting the small-model performance tradeoff documented there. This does not complete the sliding-window work.
#3256 remains open with draft #3334 stopped at its second B=1 performance gate (about 6% slower on the measured Gemma 3 case). Server paged-cache acceptance, retention/eviction checks, the real-model live-block bound, Gemma 4 migration and replay/parity acceptance remain incomplete. #3257 is still blocked by #3256. The epic remains open.
Family follow-ups were filed as #3324–#3329. #3386 tracks the OpenAI-route ignore_eos propagation bug and #3387 tracks other pool-slab kernels. #3250 must retain its separate quantized-state acceptance: this optimization neither adds Turbo4 prefix cloning/trimming nor proves quantized sliding-cache reuse.
- Lingua principale
- Rust
- Stelle
- 505
- Fork
- 81
- Merge medio
- 14h 2m
- PR unite (30g)
- 448
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di lablup/mlxcel
-
area:core priority:high status:ready type:security
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
priority:medium status:ready type:security
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
I maintainer di solito rispondono entro 1 giorno
-
area:models modeltype:text priority:medium status:in-progress type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 57/100
I maintainer di solito rispondono entro 1 giorno
-
area:models priority:low status:ready type:test
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
-
area:models modeltype:omni priority:medium status:ready type:bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di lablup/mlxcel
Issue simili
-
area:ui effort:medium enhancement P7 source:agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
marketing
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Read a requested CodeRabbit PR review's findings with `coderabbit pullrequest --show-threads`Apertadocumentation priority: low tech-debt
Difficoltà 2/5 1-3 ore Idoneità per principianti 64/100
nledford/Ladderback#1823 ·
I maintainer di solito rispondono entro 1 giorno
-
psmux-resurrect: restoring a session with a numeric name puts its windows into the wrong session (`new-window -t 4` is read as window 4)Forse già presa @ealwanlee l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
psmux/psmux-plugins#47 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 87/100
I maintainer di solito rispondono entro 1 giorno