Skip to content

server: write a continued KV checkpoint at the first chunk past each step - #1342

Open
emilianbold wants to merge 1 commit into
antirez:mainfrom
emilianbold:fix/kv-continued-crossing
Open

emilianbold wants to merge 1 commit into
antirez:mainfrom
emilianbold:fix/kv-continued-crossing

Conversation

@emilianbold

Copy link
Copy Markdown
Contributor

The continued-checkpoint listener runs only on prefill_chunk events and stored a frontier only when the live length was an exact multiple of the step. The positions it is offered are the backend's chunk boundaries, which need not include those multiples: the default graph prefill chunk is 4096 (8192 for PRO), so the 10240 step landed on every second or fourth rung, and DeepSeek V4.1 SSD streaming sweeps most of a prompt in one chunk followed by a token-major tail, so no rung was ever reachable.

Store at the first chunk that enters a step bucket past the last frontier instead. This stores everywhere the exact-multiple rule did (a multiple of the step above the last frontier is always in a later bucket) and additionally at the first chunk past each boundary. Every bucket gets one frontier whatever the chunk schedule, a token-major tail does not add a frontier per token, and a cold cut inside a bucket claims it through the existing continued suppression, so no near-duplicate rung follows it. A disk hit seeds the slot's frontier, as the kvstore already does for its own counter, so resuming inside the loaded bucket does not immediately re-store it.

Measured on V4 Flash with the default interval and a 32.9k-token history resent by a stateless client: frontiers at 12288, 20480 and 32768 instead of 20480 alone, and later requests prefill 135 tokens in 0.6 s instead of 12.4k.

This fix was inspired by the investigation into #1323 root cause.

…step

The continued-checkpoint listener runs only on prefill_chunk events and stored
a frontier only when the live length was an exact multiple of the step.  The
positions it is offered are the backend's chunk boundaries, which need not
include those multiples: the default graph prefill chunk is 4096 (8192 for
PRO), so the 10240 step landed on every second or fourth rung, and DeepSeek
V4.1 SSD streaming sweeps most of a prompt in one chunk followed by a
token-major tail, so no rung was ever reachable.

Store at the first chunk that enters a step bucket past the last frontier
instead.  This stores everywhere the exact-multiple rule did (a multiple of
the step above the last frontier is always in a later bucket) and
additionally at the first chunk past each boundary.  Every bucket gets one
frontier whatever the chunk schedule, a token-major tail does not add a
frontier per token, and a cold cut inside a bucket claims it through the
existing continued suppression, so no near-duplicate rung follows it.  A
disk hit seeds the slot's frontier, as the kvstore already does for its own
counter, so resuming inside the loaded bucket does not immediately re-store
it.

Measured on V4 Flash with the default interval and a 32.9k-token history
resent by a stateless client: frontiers at 12288, 20480 and 32768 instead of
20480 alone, and later requests prefill 135 tokens in 0.6 s instead of 12.4k.
nazerim added a commit to nazerim/ds4 that referenced this pull request Nov 17, 2026
…dence

Was a 3.4 KB file in the session temp dir -- the exact failure mode DOC-ROT
catalogues, since temp has already eaten two boot-recipe artifacts.

Records what CONTRIBUTING.md actually demands and what is satisfied: clean build
0 warnings, ./ds4_test --server passing (the subset that covers KV disk-cache
bookkeeping), make cpu building, machine/backend/quant disclosed per their
reporting rule. Names the two gates still open and why they need the engine
stopped: full `make test`, and the before/after ds4-bench CSVs on prefill_tps
and gen_tps -- which their doc requires even for a store-path-only change, so
run them rather than argue for exemption.

Also states the scoping conclusion plainly: this is the only piece of today's KV
work that is upstreamable. FIX 1's bug cannot exist upstream (their
continued_store_target is exact-equality), FIX 2's divergence anchors are
fork-only, and the retention ladder (+3,163/-206 over 45 commits, none of
anchor_step/small_dense/parent_sha/children present upstream) would collide with
seven open PRs including antirez#1340/antirez#1342 in the same scheduling area.

Branch fix/kvstore-write-barrier (a5e9e77, +31) moved to
~/Projects/ds4-pr-kvstore-barrier to match the ds4-pr* worktree convention;
nothing opened against antirez/ds4.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant