Repository navigation
fix(dsv41): protect retained cache extents during growth - #10
sayyidfareed wants to merge 1 commit into
Conversation
|
Thank you @sayyidfareed — the failure mode (one growing history silently overwriting another retained prefix) is exactly the kind of bug that's miserable to debug, and the eight-reservation regression is the right shape for it. We're not merging it now: it changes cache placement and eviction at serving time, the device seam/equivalence gates are still open on your own list, and the repo is in maintenance mode — small fixes only, nothing that moves existing behavior. Leaving it open with your receipt attached for the maintainers. Thanks again. |
|
Thank you again @sayyidfareed. Development is back on, so here is an update: our own branch now has a fix for this same overwrite. A kept prompt resumes in place only where no other kept prompt has rows, and kept prompts hold their whole extent back from placement while there is room. It is waiting for a test on two nodes. When it comes to this branch we will close this PR, with credit to you for finding the bug. |
…ther kept state has rows A kept prompts state now reserves its streams whole extent (rows and tail) from placement while another placement still fits, so a growing history cannot overwrite another retained prefix; a resume in place is taken only where no other kept state has rows, a duplicate of a live streams prompt waits when its copy would fill the pool, and kept states stay through a full window. A long prompt pass also lets streams near their max_tokens finish before the next pass. The Linux host build now runs the engine APIs tests too. The overwrite was reported by @sayyidfareed (TensorFold PR #10); its regression (eight 100K histories, growth relocation, eviction only under capacity pressure) is kept as a host test here. Host: zig build test -j1 --summary all, 21/21 steps, 217/217 tests (Zig 0.17.0 x86_64).
|
Thank you @sayyidfareed — closing this as superseded by our fix on |
…ns keep their kept prompt states On 3ff3b2a a growing history could take the rows of another kept prompt: with two conversations taking turns (40K tokens growing by 10K, 4 turns each) every turn of the second was prefilled again from token 0, 25-36 s instead of 6.6 s. 9f82099, the direct child of 3ff3b2a on the same branch, is Bertholomus AI's fix (it supersedes bertholomus/TensorFold#10): a kept prompt holds its whole extent while another placement fits, resumes in place only where no other kept state has rows, and relocates on growth. On our pair with 9f82099 at 1M x 4: 12 greedy prompts byte-identical to 3ff3b2a, the interleaved turns equal to each conversation alone and 6.5-6.7 s each, 10/10 tool calls, decode 86.7 / 57.0 / 104.9 tok/s (set a, as before), prefill 2,145 tok/s at 32K. The image tag follows the pin, so prepare.sh rebuilds the image; the rank caches stay valid (their key does not include the Zig engine). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st one's kept states (#26) A new conversation with the same system prompt and tools resumes from the shared cut, a mark inside the first conversation's extent. keptOver skipped every state with the same base, so the second conversation resumed in place, wrote over the first one's longer marks and staled them, and the first conversation's next turn ran from 0 (with an agent client, a subagent or a new session started while the main session was idle). A sibling longer than the state being resumed now counts: a conversation's own next turn still resumes in place, another one copies the shared rows to a free extent. Placement is first fit, so a new stream often landed flush against a kept extent's end; that conversation's next turn then clashed with it and had to move, and a large one found no contiguous room and staled its own state. placeSoft first tries to leave growth_rows (16 chunks) past each kept extent, then falls back to the extents and the rows as before, so a full pool packs as it did. A kept state of 64K tokens or more that goes stale is logged with the reason. Tests: two new (a shared prefix, room to grow); the PR #10 test follows the new layout (the eight histories sit growth_rows apart, a larger continuation resumes in place within that room, under pressure the oldest states still go first).
…st one's kept states A new conversation with the same system prompt and tools resumes from the shared cut, a mark inside the first conversation's extent. keptOver skipped every state with the same base, so the second conversation resumed in place, wrote over the first one's longer marks and staled them, and the first conversation's next turn ran from 0 (with an agent client, a subagent or a new session started while the main session was idle). A sibling longer than the state being resumed now counts: a conversation's own next turn still resumes in place, another one copies the shared rows to a free extent. Placement is first fit, so a new stream often landed flush against a kept extent's end; that conversation's next turn then clashed with it and had to move, and a large one found no contiguous room and staled its own state. placeSoft first tries to leave growth_rows (16 chunks) past each kept extent, then falls back to the extents and the rows as before, so a full pool packs as it did. A kept state of 64K tokens or more that goes stale is logged with the reason. Tests: two new (a shared prefix, room to grow); the PR #10 test follows the new layout (the eight histories sit growth_rows apart, a larger continuation resumes in place within that room, under pressure the oldest states still go first). (cherry picked from commit 8dd20d2, TF PR #26, onto the served TP4 build 5c976359; its two hunks that update a host test this line does not have are left out, its new tests are kept) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> (cherry picked from commit 2060ba0fc17ef4f2b5de41985fd99a42a2fc1216)
What this changes
Reserve each retained prompt's request extent, not only the consumed prefix. When a continuation grows beyond that reservation, place/copy it into free space and update the retained snapshot's ownership. This prevents one growing history from overwriting another retained prefix. Keep eviction at genuine capacity pressure. The new regression covers eight 100K reservations, growth relocation, and actual capacity pressure.
Receipt
4e80f05ecba89a4e90d16375ade2eddbdc0a10c4, Zig 0.17.0, Ubuntu 24.04.5 LTS, kernel 7.0.0-1019-nvidia, NVIDIA driver 580.178.04; Linux ARM64 CUDA environment; two NVIDIA GB10 nodes for historical live tests, SM121, Mia EXL3 2.9 bpw revision64ba41b6c916a587db06eae2e19b7845f7be6e6b, recipe v0.6.1 kit. Container ARM64 imagesha256:1ad8c1382c09861dee9c342b59f6e5e3e65fe7fde4a07b5e379bc985b66902dd.cd32df3e13e92ca8f8151442fc3d4145ab3e6ef7; commandzig build test -j1 --summary allwith a shared Zig cache.zig fmt --checkpasses changed Zig files.test-goldenwas attempted on the pinned source but that step does not exist, despite CONTRIBUTING.md naming it.Checklist
Merge considerations
Two-way source revert. Preserve both ranks at the same source/runtime identity. This PR has not changed the default deployed upstream recipe.