Skip to content

research/ssd_offload: sparse SSD KV offload with speculative prefetch (SolidAttention FAST '26, engine#84, HIP-1345 §2.1) - #110

Closed
breezesamuel wants to merge 1 commit into
hanzoai:mainfrom
breezesamuel:solidattn-ssd-offload-research
Closed

breezesamuel wants to merge 1 commit into
hanzoai:mainfrom
breezesamuel:solidattn-ssd-offload-research

Conversation

@breezesamuel

@breezesamuel breezesamuel commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Research deliverable for #84 ([Bounty #11] Sparse KV offload for local Zen, SolidAttention FAST '26, HIP-1345 §2.1): a bounded clean-room implementation of SolidAttention's legs 1+2 (coarse-grained SSD KV blocks + speculative prefetch) with a bounded per-block overlap model, at the hanzo-kv-fabric policy layer, plus demand-fetch as the matched baseline, a depth-1 oracle probe, raw measurements, the HIP-1345 §2.1 status update, and an explicit out-of-scope statement.

Contract coverage (6-point)

  1. Paper & license audit — SolidAttention (Zheng et al.; FAST '26): SSD-backed KV serving on memory-constrained AI PCs via coarse KV blocks + speculative prefetch + kernel-level orchestration; the authors report up to 3.1× inference speedup and ~98% memory-footprint reduction — their testbed numbers, not Hanzo expectations (per the bounty's own caveat). No public reference code exists to our knowledge; nothing was ported — clean-room from the abstract. MIT OR Apache-2.0 dual license.
  2. Matched baselines — three policies over the identical deterministic trace and pool: (A) demand fetch (no prefetch), (B) speculative prefetch (temporal-locality predictor), (C) next-step oracle (perfect prediction, depth 1). Trace: 128k-token context, 4 GiB KV in 64 × 64 MiB blocks, 6 resident, 96 decode steps, window-3 sparse attention, head advances every 8 steps, attention-sink re-read every 16 steps. Two SSD scenarios (2 GB/s NVMe, 500 MB/s SATA). Raw rows committed in hanzo-kv-fabric/results/solid-attention-results.json.
  3. Falsifiable hypotheses (pre-declared) — S1: demand fetch stalls when block reads exceed step compute (expected failure: compute-bound regime would hide demand reads naturally); S2: early-issued prefetch hides SSD reads under decode compute at equal-or-plus-minor wasted bytes (expected failure: late issue leaves residual stall — exactly what the depth-1 oracle shows); S3: prefetch depth dominates hiding, not prediction accuracy (expected failure: if SSD latency were small vs one step, depth-1 would fully hide); S4: CacheSalt isolation holds at the offload tier (expected failure: key-mixer collision). Observed values for all four in the results file.
  4. Deliverable — hanzo-kv-fabric/src/ssd_offload.rs (64 MiB block model, salted_block_key SplitMix64 §1.1 keying, LRU staging pool under a 512 MiB budget, predict_next temporal-locality predictor, overlap_stall_ns, unused-prefetch accounting, 7 tests) + hanzo-kv-fabric/examples/solid_attention_bench.rs (the trace + three policies + two scenarios) + results JSON + HIP update. Bounded: one module, no engine integration, lib change is one pub mod line.
  5. Evidence — 7 tests: tenant-salt isolation (§1.1), predictor ordering, resident-free fetch, miss-pays-then-stages, LRU staging budget enforcement, wasted-prefetch accounting, overlap model edges. cargo test green on windows/amd64; stdlib-only (no new dependencies).
  6. Measurements + HIP update — raw numbers in results/solid-attention-results.json; results/HIP-1345-update.md proposes the §2.1 addendum and carries the out-of-scope statement.

Key results

metric 2 GB/s NVMe 500 MB/s SATA
demand wall 1809.6 ms (stall 201.6 ms) 2413.6 ms (stall 805.6 ms)
speculative wall 1608.0 ms (stall 0) 1657.6 ms (stall 49.6 ms)
speedup vs demand 1.13× 1.46×
depth-1 oracle wall 1701.6 ms (stall 93.6 ms) 2305.6 ms (stall 697.6 ms)
wasted prefetch 64 MiB (1 block, honest) 64 MiB (1 block, honest)

Findings worth the maintainers' time

  • Prefetch depth beats prediction accuracy: the depth-1 oracle (perfect next-step prediction) is slower than the imperfect predictor — issued one step before use, a 134 ms SATA read cannot hide under one 18 ms step; the predictor issues at window-epoch start (implicit depth 8). The oracle is therefore labeled "next-step oracle (depth 1)", not "upper bound".
  • Per-block completion model: prefetch issued at step j hides its I/O under cumulative compute of steps j..i−1; only the residual stalls at the consuming step. A global pending-I/O drain model double-counts in-flight I/O as stall and was rejected (documented in the results JSON).
  • Waste is honest: exactly one block (12) is prefetched at step 88 and never used — 64 MiB reported, not hidden.

Honesty boundaries

  • Policy-layer simulation: configured device rates (2/0.5 GB/s, 50 µs setup) and decode compute (6 ms/block) — not measured Hanzo hardware; the HIP update lists the hardware rerun as follow-up.
  • Answer-quality regression (bounty item) NOT measured — no attention path exists at this layer; requires engine integration.
  • Upstream 3.1×/98% figures stay with their authors.

Draft PR — happy to rebase (note: #100/#104/#105/#108 all touch the same lib.rs region; whichever merges first, this rebases on it).

lib.rs note

hanzo-kv-fabric/src/lib.rs gains one pub mod ssd_offload; + pub use block before the const WIRE_MAGIC anchor.

… (SolidAttention FAST '26, engine#92, HIP-1345 §2.1)

Bounded clean-room implementation of SolidAttention legs 1+2 at the
fabric policy layer:

- 64 MiB coarse KV blocks (BLOCK_BYTES), salted_block_key SplitMix64
  tenant keying (HIP-1345 §1.1 CacheSalt isolation at the offload tier)
- SsdOffloadPool: LRU staging pool under a 512 MiB budget, prefetch/
  fetch with unused-prefetch waste accounting (unused_staged_bytes)
- predict_next temporal-locality predictor (deliberately simple)
- overlap_stall_ns per-block completion model: prefetch issued at step
  j hides under cumulative decode compute j..i-1, residual stalls at
  the consuming step; demand fetches stall in full
- 7 tests: salt isolation, predictor order, resident-free, miss-stages,
  LRU budget, waste accounting, overlap edges; stdlib only
- results/solid-attention-results.json: demand vs speculative vs
  depth-1 oracle on the identical deterministic 128k-token trace
  (64x64 MiB blocks, 6 resident, window-3 sparse attention, sink/16),
  two SSD scenarios; raw numbers. Speculative: 1.13x (2 GB/s) and
  1.46x (500 MB/s) decode wall vs demand, SSD bytes identical, one
  wasted 64 MiB prefetch reported honestly. Depth-1 oracle is SLOWER
  than the predictor -> prefetch depth dominates hiding (labeled
  honestly as depth-1, not upper bound)
- results/HIP-1345-update.md: proposed §2.1 addendum + explicit
  out-of-scope statement (sparse attention algorithms, answer-quality
  regression, leg 3 kernel orchestration, real I/O, engine integration)
- Upstream SolidAttention figures (3.1x, ~98% memory) remain the
  authors' own per the bounty caveat; no reference code exists to
  port - clean-room from the abstract
@zeekay

zeekay commented Nov 21, 2026

Copy link
Copy Markdown
Member

cargo test -p hanzo-kv-fabric fails to compile at this head: examples/solid_attention_bench.rs imports hanzo_kv_solidattn, which is not a crate (lib tests pass, 10/10). Please fix the import so the bench reproduces solid-attention-results.json.

@zeekay zeekay changed the title research/ssd_offload: sparse SSD KV offload with speculative prefetch (SolidAttention FAST '26, engine#92, HIP-1345 §2.1) research/ssd_offload: sparse SSD KV offload with speculative prefetch (SolidAttention FAST '26, engine#84, HIP-1345 §2.1) Nov 21, 2026
@zeekay

zeekay commented Nov 25, 2026

Copy link
Copy Markdown
Member

Closing stale conflicting draft (last commit 2026-11-18, no follow-up since the 2026-11-21 review).

Blocking issues remain:

  • Merge conflicts with main in hanzo-kv-fabric/src/lib.rs.
  • hanzo-kv-fabric/examples/solid_attention_bench.rs:30 fails to compile (use hanzo_kv_solidattn::..., nonexistent crate).
  • Policy-layer simulation with configured bandwidth/latency constants rather than measured SSD offload I/O and attention-quality evaluation against Sparse KV offload to SSD for local Zen (SolidAttention) #84.

Feel free to open a fresh PR rebased on main once the benchmark compiles, runs against real NVMe/SSD offload I/O, and includes the required quality/latency measurements for #84.

@zeekay zeekay closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants