X280-4: prefix-cache GDN snapshots in device DRAM (0 host RAM, no PCIe per hit) #308

Open
opened 2026-10-23 10:01:08 +02:00 by Grok · 0 comments
Owner

X280-4 — Prefix-cache snapshots in device DRAM (stop paying host RAM and PCIe for GDN state)

Type: capacity + latency lever (prefix reuse) · Stage: D (DRAM-dependent)
Effort (after X280-0): 6–10 weeks
Depends on: X280-0 (K0.5, K0.6), X280-3
Status note: this issue is PARKED (RAM) under LEDGER D-2026-10-06-ram-parked until the uncompressed pool requirement in §5 is accepted by the owner, or until the compression rung (P2) halves it. It is not closed; it is waiting on a decision.

1. TL;DR

A prefix-cache snapshot is 72 MiB of GDN recurrent state per sequence (36 MiB per card). Today it is pulled to the host and kept in host RAM, which is why the prefix arm is budget-limited on a 15.9 GB host and why _validate_gdn_snapshot explicitly refuses anything still on the device.

Three things get better if the pool lives in device DRAM on the channels the L2CPU clusters are directly attached to:

  1. Host RAM: zero bytes, which unparks the snapshot budget.
  2. Per-hit latency: the 72 MiB round trip stops crossing PCIe — card 0 is Gen3 x4, so that trip is 20–25 ms today; from a local GDDR6 channel it is ~2–3 ms.
  3. Capacity: the pool can be compressed with RVV (fp32 → bf16 → bfp8_b) with no host CPU cost.

Pre-registered target: ≥ 64 resident snapshots with 0 host RAM, save/restore ≤ 4 ms each, bit-identical restore at P1, and prefix-hit TTFT not worse than today.

2. Why (measured baseline)

  • docs/SERVING.md:157-194 — vLLM-native hybrid caching; each block stores ~72 MiB (estimate) of recurrent state; the snapshot path is ttnn.to_torch(...).clone() and _validate_gdn_snapshot rejects any snapshot still on device (model.py:1543).
  • LEDGER R-2026-09-25-kvbudget / 2800:1902 — "Prefix-cache snapshots are HOST memory, not device. GDN state is 72 MiB/sequence".
  • STATUS.md:791 — the warm cell killed the engine: host prefix snapshot budget exhausted. The default of 16 snapshots cannot hold a second batch, and the design fails closed rather than evicting.
  • docs/SERVING.md:187 — the 32/48-snapshot budget has never been exercised at B=8.
  • Byte model (docs/ISSUES-133-137-EVAL-2026-09-30.md:136): 24 value heads/card × 128×128 fp32 × 48 layers = 36 MiB/card/user.
  • Card 0 is Gen3 x4 (docs/HARDWARE.md) — a 72 MiB host round trip is ~20–25 ms at realistic goodput.

3. What exists today

prefix_cache_snapshot → ttnn.to_torch → .clone() (host) → _validate_gdn_snapshot (must be host) → kept in a host-side LRU with a count budget that fails closed. A hit restores by uploading the tensor and writing it into the slot.

The pool is a host-RAM object with a PCIe transfer on both ends. Both are consequences of placement, not of mathematics.

4. Design

4.1 Placement

Each L2CPU cluster has a direct AXI4 256-bit memory port to one GDDR6 channel with 128 outstanding transfers (X280 DS 21G3 p.4; L2CPUTile/MemoryMap.md). The pool must therefore be allocated on a specific channel, not "somewhere in the 31.87 GiB". That is a real change: tt-metal allocates device DRAM as one interleaved pool.

Two viable placements, decided by measurement in P1:

  • A — pinned per-channel region. Reserve a contiguous region at boot and force its channel mapping (interleaved-with-stride or a dedicated allocation path). Snapshots live there; X280 reads/writes at full channel bandwidth; Tensix still reaches them (slower) when restoring into a slot.
  • B — channel-agnostic pool, X280 as a copy engine. Snapshots sit anywhere; the X280 uses its DMA/TLB path. Simpler, loses the "direct port" advantage, and lands in K0.6 territory.

A is the design; B is the fallback.

4.2 What the X280 does

Operation Today After
save device→host copy (to_torch), host clone, host LRU device→pool DMA (on-card), LRU index in LIM, hash in LIM
hit host→device upload into the slot pool→slot DMA, no host bytes
capacity host RAM budget (fails closed) DRAM bytes, sized at boot
compression none optional RVV fp32→bf16, fp32→bfp8_b with per-block scale

The X280's job is index + copy + optional convert. It is not doing math on the state.

4.3 Sizing

Quantity Uncompressed bf16 bfp8_b
per sequence (both cards) 72 MiB 36 MiB 18 MiB
per card 36 MiB 18 MiB 9 MiB
64 snapshots, per card 2.25 GiB 1.13 GiB 0.56 GiB
128 snapshots, per card 4.5 GiB 2.25 GiB 1.13 GiB

Free device DRAM at B=8 is 4.7 GiB (docs/LEVERS.md:150). So 64 uncompressed snapshots (2.25 GiB) is feasible but eats half the free DRAM; 64 at bf8 is 0.56 GiB and is the recommended operating point. This is exactly why the compression rung is not optional in practice.

5. Numeric targets and kill criteria

ID Metric Target
T4.1 resident snapshots ≥ 64 (host budget today: 16, and it fails closed)
T4.2 host RAM for snapshots 0 bytes
T4.3 save time, 36 MiB/card ≤ 4 ms (from ~10–12 ms of PCIe + host copy)
T4.4 restore time ≤ 4 ms
T4.5 restored state bit-identical at P1 (uncompressed)
T4.6 prefix-hit TTFT, 8k shared head ≤ CONTROL
T4.7 compressed variants PCC ≥ 0.99999 vs fp32 state on real distributions, and the served acceptance corpus unchanged
K4.1 if K0.6 shows remote-channel reads < 4 GB/s and placement A is not achievable close — B would be slower than host RAM
K4.2 if the owner does not release 2.25 GiB (uncompressed) and B-pool compression fails T4.7 stay parked, do not consume DRAM on a bet
K4.3 if restore > 10 ms close (recompute of a small suffix may be cheaper)

6. Quality gates

Gate What must pass
G0 QWEN36_X280_PREFIX_POOL=1; flag off = host path; banner; ttx lint
G1 host tests for the LRU/index/hash; must-fail: a snapshot with a corrupted checksum must be rejected, not restored
G2 ttsim: pool→slot→pool round trip byte-exact; the compression path vs fp64 reference at full per-chip shapes
G3 on-card: save/restore latency and bandwidth at 1/8/64 snapshots; DRAM fragmentation and allocator behaviour recorded (this is the riskiest unknown)
G4 served boot with --enable-prefix-caching --mamba-cache-mode align, warm shared head, 48-snapshot budget
G5 the tt-prefix-benefit protocol: cold cell then warm shared-head cell in one boot, snapshot budget and chunk size that make a hit possible. Report hit rate, TTFT, PP, TG.
G6 P1 exact → tier 1. Compression → tier 2 (fp64/PCC + equiv + GSM8K + retrieval)
G7 ship + SERVING/STATUS/LEDGER rows; the host-RAM snapshot sidecar in LEVERS.md:151 can finally be closed

7. Work breakdown

Phase Work Exit
P0 Measure K0.5/K0.6 on the real harvested channel map; confirm which clusters have local DRAM go/no-go on placement A
P1 Pool allocation + uncompressed save/restore, bit-exact, 64 snapshots T4.1–T4.5
P2 RVV compression (bf16, then bfp8_b with block scales) T4.7
P3 LRU/eviction + checksums + crash-safe index G1
P4 Served prefix gate (tt-prefix-benefit) G5
P5 Ship + docs G7

8. Risks

  1. The DRAM allocator is the real enemy. tt-metal owns the pool; pinning a region to a channel and surviving allocator churn is the hard part, harder than the compression. If a fresh open_mesh_device resets the allocator (docs/RESEARCH-KERNEL-WORKBENCH.md:524), a persistent pool needs a boot-time reservation, which changes image config.
  2. Harvesting. The ISA notes a harvested placement can leave an L2CPU with no local GDDR. Our p150a DRAM map is measured, not that footnote — P0 must verify the four clusters each have a reachable channel before anything is built.
  3. The X280 is now on the critical path of a cache hit. A hung copy is a hung request. Watchdog + host fallback (upload from host RAM) is mandatory.
  4. Compression changes numerics of restored state. A prefix hit must produce the same continuation as a cold prefill, or the cache is a correctness bug generator. P2's gate is the real gate, and it must include a long-context drift test, not just PCC on one tensor.

9. Anti-goals

  • Not changing the block granularity or the align semantics.
  • Not compressing KV (that is QWEN_SDPA_BF8 / k8v4, already shipped separately).
  • Not an eviction-policy research project: LRU with a checksum is enough.

10. Open questions

  • Q1: which of D5/D6/D7 is actually attached to which cluster on our harvested cards? (P0)
  • Q2: can a snapshot region survive a process restart, or is it inherently per-boot? (Determines whether the pool is a cache or a preload mechanism.)
  • Q3: is restoring 36 MiB into a slot faster than replaying the last ~2 chunks (Tail-Replay style)? If yes, the pool's value shrinks — measure before building P3.

11. References

  • docs/SERVING.md:157-194 — the host-resident snapshot design and its budget.
  • LEDGER D-2026-10-06-ram-parked, R-2026-09-25-kvbudget, docs/STATUS.md:791.
  • docs/ISSUES-133-137-EVAL-2026-09-30.md:125-136 — the 72 MiB byte model.
  • docs/notes/prefill-papers-scan-2026-09-27.md:122 — DASC/Tail-Replay/HYPIC: the state-compression and suffix-replay alternatives this issue must beat.
  • X280 DS 21G3 p.4 (Memory Port: 256-bit AXI4, 128 outstanding) + L2CPUTile/MemoryMap.md (one direct channel per cluster).
# X280-4 — Prefix-cache snapshots in device DRAM (stop paying host RAM and PCIe for GDN state) **Type:** capacity + latency lever (prefix reuse) · **Stage:** D (DRAM-dependent) **Effort (after X280-0):** 6–10 weeks **Depends on:** X280-0 (K0.5, **K0.6**), X280-3 **Status note:** this issue is **PARKED (RAM)** under `LEDGER D-2026-10-06-ram-parked` until the uncompressed pool requirement in §5 is accepted by the owner, or until the compression rung (P2) halves it. It is not closed; it is waiting on a decision. ## 1. TL;DR A prefix-cache snapshot is **72 MiB of GDN recurrent state per sequence** (36 MiB per card). Today it is **pulled to the host** and kept in host RAM, which is why the prefix arm is budget-limited on a **15.9 GB host** and why `_validate_gdn_snapshot` explicitly refuses anything still on the device. Three things get better if the pool lives in device DRAM on the channels the L2CPU clusters are directly attached to: 1. **Host RAM:** zero bytes, which unparks the snapshot budget. 2. **Per-hit latency:** the 72 MiB round trip stops crossing PCIe — card 0 is **Gen3 x4**, so that trip is 20–25 ms today; from a local GDDR6 channel it is ~2–3 ms. 3. **Capacity:** the pool can be compressed with RVV (`fp32 → bf16 → bfp8_b`) with no host CPU cost. **Pre-registered target:** **≥ 64 resident snapshots** with **0 host RAM**, save/restore **≤ 4 ms** each, bit-identical restore at P1, and prefix-hit TTFT **not worse** than today. ## 2. Why (measured baseline) - `docs/SERVING.md:157-194` — vLLM-native hybrid caching; each block stores ~72 MiB (**estimate**) of recurrent state; the snapshot path is `ttnn.to_torch(...).clone()` and `_validate_gdn_snapshot` rejects any snapshot still on device (`model.py:1543`). - `LEDGER R-2026-09-25-kvbudget` / `2800:1902` — "**Prefix-cache snapshots are HOST memory, not device.** GDN state is 72 MiB/sequence". - `STATUS.md:791` — the warm cell **killed the engine**: `host prefix snapshot budget exhausted`. The default of 16 snapshots cannot hold a second batch, and the design fails closed rather than evicting. - `docs/SERVING.md:187` — the 32/48-snapshot budget has never been exercised at B=8. - Byte model (`docs/ISSUES-133-137-EVAL-2026-09-30.md:136`): 24 value heads/card × 128×128 fp32 × 48 layers = **36 MiB/card/user**. - Card 0 is **Gen3 x4** (`docs/HARDWARE.md`) — a 72 MiB host round trip is ~20–25 ms at realistic goodput. ## 3. What exists today `prefix_cache_snapshot` → `ttnn.to_torch` → `.clone()` (host) → `_validate_gdn_snapshot` (must be host) → kept in a host-side LRU with a **count** budget that fails closed. A hit restores by uploading the tensor and writing it into the slot. The pool is a **host-RAM object with a PCIe transfer on both ends**. Both are consequences of placement, not of mathematics. ## 4. Design ### 4.1 Placement Each L2CPU cluster has a **direct AXI4 256-bit memory port to one GDDR6 channel** with 128 outstanding transfers (X280 DS 21G3 p.4; `L2CPUTile/MemoryMap.md`). The pool must therefore be **allocated on a specific channel**, not "somewhere in the 31.87 GiB". That is a real change: tt-metal allocates device DRAM as one interleaved pool. Two viable placements, decided by measurement in P1: - **A — pinned per-channel region.** Reserve a contiguous region at boot and force its channel mapping (interleaved-with-stride or a dedicated allocation path). Snapshots live there; X280 reads/writes at full channel bandwidth; Tensix still reaches them (slower) when restoring into a slot. - **B — channel-agnostic pool, X280 as a copy engine.** Snapshots sit anywhere; the X280 uses its DMA/TLB path. Simpler, loses the "direct port" advantage, and lands in K0.6 territory. **A is the design; B is the fallback.** ### 4.2 What the X280 does | Operation | Today | After | |---|---|---| | save | device→host copy (to_torch), host clone, host LRU | device→pool DMA (on-card), LRU index in LIM, hash in LIM | | hit | host→device upload into the slot | pool→slot DMA, no host bytes | | capacity | host RAM budget (fails closed) | DRAM bytes, sized at boot | | compression | none | optional RVV `fp32→bf16`, `fp32→bfp8_b` with per-block scale | The X280's job is **index + copy + optional convert**. It is not doing math on the state. ### 4.3 Sizing | Quantity | Uncompressed | bf16 | bfp8_b | |---|---:|---:|---:| | per sequence (both cards) | 72 MiB | 36 MiB | 18 MiB | | per card | 36 MiB | 18 MiB | 9 MiB | | 64 snapshots, per card | **2.25 GiB** | 1.13 GiB | **0.56 GiB** | | 128 snapshots, per card | 4.5 GiB | 2.25 GiB | 1.13 GiB | Free device DRAM at B=8 is **4.7 GiB** (`docs/LEVERS.md:150`). So **64 uncompressed snapshots (2.25 GiB) is feasible but eats half the free DRAM**; 64 at bf8 is **0.56 GiB** and is the recommended operating point. This is exactly why the compression rung is not optional in practice. ## 5. Numeric targets and kill criteria | ID | Metric | Target | |---|---|---| | **T4.1** | resident snapshots | **≥ 64** (host budget today: 16, and it fails closed) | | **T4.2** | host RAM for snapshots | **0 bytes** | | **T4.3** | save time, 36 MiB/card | **≤ 4 ms** (from ~10–12 ms of PCIe + host copy) | | **T4.4** | restore time | **≤ 4 ms** | | **T4.5** | restored state | **bit-identical** at P1 (uncompressed) | | **T4.6** | prefix-hit TTFT, 8k shared head | **≤ CONTROL** | | **T4.7** | compressed variants | PCC ≥ 0.99999 vs fp32 state on real distributions, **and** the served acceptance corpus unchanged | | **K4.1** | if K0.6 shows remote-channel reads < 4 GB/s and placement A is not achievable | **close** — B would be slower than host RAM | | **K4.2** | if the owner does not release 2.25 GiB (uncompressed) and B-pool compression fails T4.7 | **stay parked**, do not consume DRAM on a bet | | **K4.3** | if restore > 10 ms | close (recompute of a small suffix may be cheaper) | ## 6. Quality gates | Gate | What must pass | |---|---| | **G0** | `QWEN36_X280_PREFIX_POOL=1`; flag off = host path; banner; `ttx lint` | | **G1** | host tests for the LRU/index/hash; must-fail: a snapshot with a corrupted checksum must be **rejected**, not restored | | **G2** | ttsim: pool→slot→pool round trip byte-exact; the compression path vs fp64 reference at full per-chip shapes | | **G3** | on-card: save/restore latency and bandwidth at 1/8/64 snapshots; **DRAM fragmentation and allocator behaviour recorded** (this is the riskiest unknown) | | **G4** | served boot with `--enable-prefix-caching --mamba-cache-mode align`, warm shared head, 48-snapshot budget | | **G5** | the `tt-prefix-benefit` protocol: cold cell then warm shared-head cell in one boot, snapshot budget and chunk size that make a hit possible. **Report hit rate, TTFT, PP, TG.** | | **G6** | P1 exact → tier 1. Compression → tier 2 (fp64/PCC + equiv + GSM8K + retrieval) | | **G7** | ship + SERVING/STATUS/LEDGER rows; the host-RAM snapshot sidecar in `LEVERS.md:151` can finally be closed | ## 7. Work breakdown | Phase | Work | Exit | |---|---|---| | P0 | Measure K0.5/K0.6 on the *real* harvested channel map; confirm which clusters have local DRAM | go/no-go on placement A | | P1 | Pool allocation + uncompressed save/restore, bit-exact, 64 snapshots | T4.1–T4.5 | | P2 | RVV compression (bf16, then bfp8_b with block scales) | T4.7 | | P3 | LRU/eviction + checksums + crash-safe index | G1 | | P4 | Served prefix gate (`tt-prefix-benefit`) | G5 | | P5 | Ship + docs | G7 | ## 8. Risks 1. **The DRAM allocator is the real enemy.** tt-metal owns the pool; pinning a region to a channel and surviving allocator churn is the hard part, harder than the compression. If a fresh `open_mesh_device` resets the allocator (`docs/RESEARCH-KERNEL-WORKBENCH.md:524`), a persistent pool needs a boot-time reservation, which changes image config. 2. **Harvesting.** The ISA notes a harvested placement can leave an L2CPU with **no local GDDR**. Our p150a DRAM map is measured, not that footnote — P0 must verify the four clusters each have a reachable channel before anything is built. 3. **The X280 is now on the critical path of a cache hit.** A hung copy is a hung request. Watchdog + host fallback (upload from host RAM) is mandatory. 4. **Compression changes numerics of restored state.** A prefix hit must produce the *same* continuation as a cold prefill, or the cache is a correctness bug generator. P2's gate is the real gate, and it must include a long-context drift test, not just PCC on one tensor. ## 9. Anti-goals - Not changing the block granularity or the `align` semantics. - Not compressing KV (that is `QWEN_SDPA_BF8` / `k8v4`, already shipped separately). - Not an eviction-policy research project: LRU with a checksum is enough. ## 10. Open questions - Q1: which of D5/D6/D7 is actually attached to which cluster on **our** harvested cards? (P0) - Q2: can a snapshot region survive a process restart, or is it inherently per-boot? (Determines whether the pool is a cache or a preload mechanism.) - Q3: is restoring 36 MiB into a slot faster than replaying the last ~2 chunks (Tail-Replay style)? If yes, the pool's value shrinks — measure before building P3. ## 11. References - `docs/SERVING.md:157-194` — the host-resident snapshot design and its budget. - `LEDGER D-2026-10-06-ram-parked`, `R-2026-09-25-kvbudget`, `docs/STATUS.md:791`. - `docs/ISSUES-133-137-EVAL-2026-09-30.md:125-136` — the 72 MiB byte model. - `docs/notes/prefill-papers-scan-2026-09-27.md:122` — DASC/Tail-Replay/HYPIC: the state-compression and suffix-replay alternatives this issue must beat. - X280 DS 21G3 p.4 (Memory Port: 256-bit AXI4, 128 outstanding) + `L2CPUTile/MemoryMap.md` (one direct channel per cluster).
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
bitpartner/tt-stack#308
No description provided.