[PR #52] [CLOSED] nvme kv cache #2431

Closed
opened 2026-11-04 02:00:03 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/52
Author: @maedoc
Created: 9/28/2026
Status: ❌ Closed

Base: main ← Head: nvme-kv-cache


📝 Commits (10+)

  • a7578f9 NVMe KV cold tier for warm sessions (docs/nvme-kv-cache-design.md)
  • 4152c79 kv-nvme: snapshot at the chat turn boundary (nvme_dump_at)
  • 75c22e0 docs: fold the NVMe tier design into a self-contained record; drop the review annexes
  • b820600 kv-nvme: payload-integrity footer on every snapshot
  • cb7ebee kv-nvme: diagnose layout drift before integrity on restore
  • f527caa WIP checkpoint: shared conversation core imported, tier retyped to it (step 2, unfinished)
  • d53aaff docs: write the section kv_nvme.hpp already pointed at
  • 4c7dd17 kv-nvme: a turn-boundary snapshot stored the WRONG IMAGE LIST, so any conversation with a picture was unreachable
  • 2c7321a kv-nvme: NvmeEntry::imgs was NEVER FILLED, so every image comparison in the tier compared against nothing
  • c6756f3 kv-nvme, generate: the shared core's diagnostic string was thrown away at every call site

📊 Changes

48 files changed (+14500 additions, -164 deletions)

View changed files

📝 CMakeLists.txt (+76 -1)
➕ docs/nvme-delta-cache-handoff.md (+824 -0)
➕ docs/nvme-delta-restore-handoff.md (+262 -0)
➕ docs/nvme-kv-cache-design.md (+648 -0)
➕ docs/nvme-kv-cache-web-design.md (+430 -0)
➕ docs/nvme-kv-cache-web-plan.md (+382 -0)
➕ docs/nvme-kv-web-merge-handoff.md (+335 -0)
➕ docs/nvme-restore-perf-evidence.md (+114 -0)
➕ include/strata/core/conversation_cache.hpp (+162 -0)
➕ include/strata/core/conversation_memory.hpp (+24 -0)
➕ include/strata/core/conversation_snapshot.hpp (+66 -0)
📝 include/strata/core/mtp.hpp (+3 -0)
📝 include/strata/kernels/qsa.hpp (+19 -0)
➕ include/strata/platform/kv_delta.hpp (+351 -0)
➕ include/strata/platform/kv_nvme.hpp (+384 -0)
➕ serve/kvcache.py (+475 -0)
📝 serve/server.py (+122 -23)
📝 serve/telemetry.py (+26 -3)
📝 serve/test_server.py (+898 -1)
📝 serve/web/app.css (+21 -2)

...and 28 more files

📄 Description

An nvme kv cache avoids constant prefills across multiple sessions (#47) so I'm taking a stab at it, testing it right now. Once the tests on the live server come through I'll detail those tests.

Whole-session snapshots (attention KV in every format + idx_pooled/idx_block_pos/ idx_dead/idx_tail + GDN/PLE running state + MTP drafter host KV) keyed by the exact token prefix, stored under --kv-nvme DIR:
  • automatic synchronous cascade on DONE (idempotent; one growing file per conversation via strict-prefix supersede), fsync'd
  • automatic promote on prefix match in the serve resume path - no client calls (a failed promote falls back to the clean session_zero path, never a mixed state)
  • LRU byte cap (--kv-nvme-max GB); corrupt/foreign store files are refused, never converted, and can no longer crash the server
  • atomic restore: the whole snapshot is validated before anything is applied
  • STRATA_STATE_HASH refactored into state_hash_line() and shared with a new post-restore oracle (STRATA_NVME_HASH); verify.cpp: add for Linux

Oracles: tools/nvme_p0_test.sh (bit-exact restore + negative control), tools/nvme_steps123_test.sh (cascade/supersede, promote-after-restart: 13 fresh tokens read in ~350 ms after a restart vs a full re-prefill; LRU cap evicts). Known engine property (documented): decode is run-to-run nondeterministic on v0.1.13 (pre-existing, reproduced with the old binary), so continuation token equality is informational; restore-exactness is the hard gate.

Design: docs/nvme-kv-cache-design.md; review: docs/nvme-kv-cache-critique.md (glm-5.3, design) and docs/nvme-kv-impl-review.md (glm-5.3, implementation, P1s addressed).

edit so for example, this is a round robin 110k needle-in-the-haystack example
image
where we see delicious ttft bc of reuse, across three different long prompts.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/52 **Author:** [@maedoc](https://github.com/maedoc) **Created:** 9/28/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `nvme-kv-cache` --- ### 📝 Commits (10+) - [`a7578f9`](https://github.com/Niko1221/Strata/commit/a7578f97082317010b5d6359a2eba8ea9e8faab7) NVMe KV cold tier for warm sessions (docs/nvme-kv-cache-design.md) - [`4152c79`](https://github.com/Niko1221/Strata/commit/4152c7934aa3a4d9205c2d7a63f18b5c69011d40) kv-nvme: snapshot at the chat turn boundary (nvme_dump_at) - [`75c22e0`](https://github.com/Niko1221/Strata/commit/75c22e0030a22205ab2f68d34bc6afc3ad97edc7) docs: fold the NVMe tier design into a self-contained record; drop the review annexes - [`b820600`](https://github.com/Niko1221/Strata/commit/b8206008e47c2047b424a809d597b33a425f5613) kv-nvme: payload-integrity footer on every snapshot - [`cb7ebee`](https://github.com/Niko1221/Strata/commit/cb7ebee1cd0e2fbdd20f72521d729ceb52a20fec) kv-nvme: diagnose layout drift before integrity on restore - [`f527caa`](https://github.com/Niko1221/Strata/commit/f527caafe80c5e8cd85702c38f126f113fcc0845) WIP checkpoint: shared conversation core imported, tier retyped to it (step 2, unfinished) - [`d53aaff`](https://github.com/Niko1221/Strata/commit/d53aaffed129dbdd0aabf98b65b33e5d8b77c2a2) docs: write the section kv_nvme.hpp already pointed at - [`4c7dd17`](https://github.com/Niko1221/Strata/commit/4c7dd17c552a36ae5be1725cb7c5754527439851) kv-nvme: a turn-boundary snapshot stored the WRONG IMAGE LIST, so any conversation with a picture was unreachable - [`2c7321a`](https://github.com/Niko1221/Strata/commit/2c7321a31016b7a8f4e255e59a314d976a9ee41e) kv-nvme: NvmeEntry::imgs was NEVER FILLED, so every image comparison in the tier compared against nothing - [`c6756f3`](https://github.com/Niko1221/Strata/commit/c6756f3c6971ac3a4606f35aa0e69524cfc87bfa) kv-nvme, generate: the shared core's diagnostic string was thrown away at every call site ### 📊 Changes **48 files changed** (+14500 additions, -164 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+76 -1) ➕ `docs/nvme-delta-cache-handoff.md` (+824 -0) ➕ `docs/nvme-delta-restore-handoff.md` (+262 -0) ➕ `docs/nvme-kv-cache-design.md` (+648 -0) ➕ `docs/nvme-kv-cache-web-design.md` (+430 -0) ➕ `docs/nvme-kv-cache-web-plan.md` (+382 -0) ➕ `docs/nvme-kv-web-merge-handoff.md` (+335 -0) ➕ `docs/nvme-restore-perf-evidence.md` (+114 -0) ➕ `include/strata/core/conversation_cache.hpp` (+162 -0) ➕ `include/strata/core/conversation_memory.hpp` (+24 -0) ➕ `include/strata/core/conversation_snapshot.hpp` (+66 -0) 📝 `include/strata/core/mtp.hpp` (+3 -0) 📝 `include/strata/kernels/qsa.hpp` (+19 -0) ➕ `include/strata/platform/kv_delta.hpp` (+351 -0) ➕ `include/strata/platform/kv_nvme.hpp` (+384 -0) ➕ `serve/kvcache.py` (+475 -0) 📝 `serve/server.py` (+122 -23) 📝 `serve/telemetry.py` (+26 -3) 📝 `serve/test_server.py` (+898 -1) 📝 `serve/web/app.css` (+21 -2) _...and 28 more files_ </details> ### 📄 Description An nvme kv cache avoids constant prefills across multiple sessions (#47) so I'm taking a stab at it, testing it right now. Once the tests on the live server come through I'll detail those tests. <details> Whole-session snapshots (attention KV in every format + idx_pooled/idx_block_pos/ idx_dead/idx_tail + GDN/PLE running state + MTP drafter host KV) keyed by the exact token prefix, stored under --kv-nvme DIR: - automatic synchronous cascade on DONE (idempotent; one growing file per conversation via strict-prefix supersede), fsync'd - automatic promote on prefix match in the serve resume path - no client calls (a failed promote falls back to the clean session_zero path, never a mixed state) - LRU byte cap (--kv-nvme-max GB); corrupt/foreign store files are refused, never converted, and can no longer crash the server - atomic restore: the whole snapshot is validated before anything is applied - STRATA_STATE_HASH refactored into state_hash_line() and shared with a new post-restore oracle (STRATA_NVME_HASH); verify.cpp: add <cmath> for Linux Oracles: tools/nvme_p0_test.sh (bit-exact restore + negative control), tools/nvme_steps123_test.sh (cascade/supersede, promote-after-restart: 13 fresh tokens read in ~350 ms after a restart vs a full re-prefill; LRU cap evicts). Known engine property (documented): decode is run-to-run nondeterministic on v0.1.13 (pre-existing, reproduced with the old binary), so continuation token equality is informational; restore-exactness is the hard gate. Design: docs/nvme-kv-cache-design.md; review: docs/nvme-kv-cache-critique.md (glm-5.3, design) and docs/nvme-kv-impl-review.md (glm-5.3, implementation, P1s addressed). </details> *edit* so for example, this is a round robin 110k needle-in-the-haystack example <img width="915" height="401" alt="image" src="https://github.com/user-attachments/assets/e0759f33-0ad7-4b9c-98a2-44012b73c57a" /> where we see delicious ttft bc of reuse, across three different long prompts. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-04 02:00:03 +07:00
Sign in to join this conversation.
No milestone
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.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#2431
No description provided.