Repository navigation
Conversation
A continuing turn's restore could fail with only the counter and resumed at 0 showing it (issue ashhart#966). The store's failure report now logs the state's length, the prompt's length, and whether a concurrent admission had already expired the state; the GLM backends log their refusal reason before the pass prefills from the start.
Another admission's eviction could free a resident state's pool blocks between its lookup and its prefill: the restore then failed and the pass prefilled the whole prompt from the start (issue ashhart#966). Admission now asks the prompt cache whether a state is still restoring and evicts it only when nothing else frees a run, so a cache-miss request stops destroying a concurrent session's kept prefix.
There was a problem hiding this comment.
Resolved on recheck at PR head 97158da66567333213c3a25133f642ce36cb5f7c: the failed-restore tests now inspect the store and counters after release, without dereferencing the released entry. All four current-head CI checks pass. The integrated lifetime suite on main 76aafcf274e60a5e31a59ce145b2f71f7b366e9d passes 100/100 locally with Zig 0.17.0 (CPU only). This closes the test-lifetime finding; it does not establish a served forced-eviction case.
Original finding: The new test reads a released entry; the current-head CI also fails this test. A tested patch is attached to the inline finding. This review is limited to that test failure.
| const live = (try s.lookup(arena.allocator(), &prompt, 4, &.{}, &.{}, &.{})).entry.?; | ||
| s.resumed(live, &prompt, false); // refused while still valid: the backend, not a concurrent eviction | ||
| try std.testing.expectEqual(@as(u64, 1), s.counts.failed); | ||
| try std.testing.expect(live.expired); |
There was a problem hiding this comment.
[P2] Assert the store state after the last borrower releases this entry
Store.resumed(live, ..., false) sets expired and defers release(live). With this entry's only borrower released, collect removes and destroys it before returning. Reading live.expired here is therefore a use-after-free in the new test. The current Linux CI fails this test; the ordinary allocator on my Mac happens to let it pass.
A diagnostic allocator that zeroes released storage reproduces the failure at this assertion. Replacing it with checks for zero store entries, zero live fake-family states and zero held bytes makes the same probe pass, and the full cache/lifetime suite passes 96/96 with Zig 0.17.0. Whole-tree format and diff checks also pass.
Patch and before/after evidence, local patch commit 567380532ee55c9dc0c26436df68f6d18c345725 on this head. Runtime code is unchanged; Linux CI still needs its adoption rerun. The broader eviction-policy/served-reproduction review is separate from this test fix.
…h store The two classifications shared one store: the second lookup ran after the first failed report had expired and collected its entry, so the test's outcome depended on removal timing. Each classification now runs alone.
The loop version shared one store across both classifications and failed without output on the CI's Linux runner; each classification now runs in its own store, matching the proven single-store pattern of the neighboring tests.
resumed drops a failed entry before it returns, so asserting the entry's own flag read freed memory: green on this Mac, failing without output on the CI's Linux runner. The tests now assert the failure counter, the Fake's dropped state, and that find hides the expired entry.
…ores, and says why a restore failed Two files took both sides: backend.zig keeps this line's restore coordinator, and pool.zig keeps the selected prefix's relocation.
|
Thank you, @heitke, for the borrowed-state repair and cache regression coverage. We merged your work for TensorFold 1.1.0 in 90695fe, followed by df4289c. Unborrowed states go first, then the selected prefix can relocate, and borrowed neighbours go only if still needed. A failed restore is reported once with the relevant lengths and expiry state. On the final EXL3 GB10 pair, cached chats equal cache-off chats 12/12, with 6,144 tokens restored on ten steps. Host fixtures cover the eviction ordering; the previous served reproducer did not force an eviction on either build, so the passing chat run does not establish that case. Two GB10s matched cache-off chat 12/12; host eviction-order checks passed, but a served forced-eviction case is not recorded. Posted by Ash's AI Assistant Synthena |
…ll restores, and says why a restore failed Two files took both sides: backend.zig keeps this line's restore coordinator, and pool.zig keeps the selected prefix's relocation.
What this changes
Two commits addressing issue #966 on the GLM-5.3-Flash Metal host (plus three test-only commits fixing the new tests' own lifetime bug, found by this CI):
30e82f4a— say why a kept prompt state's restore failed. The issue's literal ask: when a looked-up cache entry's restore fails,Store.resumednow logs one line — the state's token length, the arriving prompt's length, and why (the entry was already expired by a concurrent admission, or the backend refused the restore). The GLM Metal backend logs its refusal reason (state no longer residentvsstate past the prompt) with kept/prompt token counts before the pass prefills from the start; the CUDA lanes twin logs the same reason.2f51bed8— spare a state an outstanding lookup still restores. A lookup borrows its cache entry, but the resident snap's GPU pool blocks are only reserved when the backend's prefill runspool.reserve— later. In that window another admission's cold prefill (place -> evictHeld) could mark the snap stale with no knowledge that a restore was about to read it: the restore then failed and the turn prefilled the whole prompt from 0.evictHeldnow asks the store (Store.borrowed, wired through a newSlots.borrowedcallback inglm_host) and evicts a still-being-restored state last — only when nothing else frees a run, so admission refuses rather than deadlocks under pressure.Status: draft, pending review
The diagnostic commit stands on its own (it is the issue's ask). The eviction-order fix is root-cause code but unproven served: in an A/B served reproduction (two ~100k-token sessions plus concurrent 4.4k churn requests against pre-fix 1.0.12 vs this branch), the #966 signature — a continuing turn resuming at 0 with a
failedincrement — did not reproduce on either build. The server logs showevicted 0throughout: the workload never exercised the window. The fix is mutation-tested at the unit level (the new pool tests fail on the reverted order) but has no served failure to point at. The production logs that motivated #966 ran with the cache full (0 MiB spare,evictedclimbing), which suggests an admission-policy path this branch does not change — the new diagnostic should name it if it recurs.Gates (at head
97158da6, this tree)zig build test: 0 failed at the final headzig build native -Dcpu=apple_m1 -Dversion=1.0.12: clean; binary post-dates every source filezig fmt --check build.zig zigandgit diff --checkcleanTests
prompt_cache_lifetime_test.zig: two tests, one per diagnostic classification — a failed restore on a valid state, and on an already-expired state — each asserting the failure counter, the dropped state, and thatfindhides the expired entry. (An earlier version asserted the entry's own flag afterresumedreturned — the entry is dropped before the call returns, so that read freed memory: green on macOS, failing without output on this CI's Linux runner. The tests now read only the store and the Fake's counters.)families/glm/pool.zig: a held state an outstanding lookup still restores gives its blocks up last (a fitting run leaves it untouched); a borrowed state's blocks still free when nothing else can serve the pass (liveness). Both fail on the reverted eviction order.Closes #966's ask; the residual reproduction question stays open on that issue.