Repository navigation
Refresh prefix-cache recency only for selected snapshots - #299
Closed
voipmonitor wants to merge 3 commits into
Closed
voipmonitor wants to merge 3 commits into
voipmonitor wants to merge 3 commits into
Conversation
Host restore admission discarded worthwhile cache hits when snapshot backing was temporarily held by requests or transfers, while checkpoint recency followed admission order even after a long request completed. Snapshot aliases and fenced ownership make capacity failures potentially transient. Defer restores within the existing transfer-versus-prefill cost budget and wake admissions on expiry or resource release, including inbound completion with no remaining waiters. Keep pooled lookup state across retries and reset wait accounting on admission. Refresh retained checkpoint chains after successful completion or cancellation with inference progress, excluding preemption and execution errors. Core formats and graph contracts remain compatible without re-export. The implemented policy is expected to avoid unnecessary prefills and retain recently completed conversations. CPU regressions qualify these decisions; GPU serving and performance remain unqualified and are tracked in docs/TODO.txt. Validation: tests for restore deferral and completion recency fail on base 7006928. The Helios library suite with server,runtime-core passes 1402 tests with 26 ignored. The patch applies cleanly to 3e9a95d3, whose library suite passes 1384 tests with 26 ignored using the same template fixtures. Ignored cases require CUDA, checkpoint/payload inputs, or manual CPU benchmarking. Nine bounded lifecycle model configurations and 361262 observed Rust transitions pass. Mutation checks detect all 8 TLA+ and 14 Rust faults, and restored-source checks pass. These checks assume truthful executor completion and drain signals and do not qualify CUDA execution. Signed-off-by: Martin Vit <martin@voipmonitor.org> Design-Signed-Off-By: Codex (GPT-6); design-review=ed22
Reusing or completing a long prefix refreshed every ancestor's eviction rank, protecting unused continuation rows that compete with KV pages and other conversations' captures. Descendants need ancestor pages, but only the selected checkpoint's snapshot; compaction can preserve those pages. Make PrefixCheckpointCache::touch update only the selected checkpoint's monotonic demand epoch. Reuse, promotion, duplicate publication, and completion use that rule. Older unpinned single-child rows can be compacted without changing descendant pages, branch pins, or retirement fences. Role ordering and capture budgets remain unchanged. Unused prompt and message rows can age even when a descendant finishes. Core formats and prepared graphs remain compatible without re-export. The implemented change is expected to reduce storage skips and retain more independently used prefixes under snapshot pressure. CPU regressions qualify recency and ownership behavior; native serving performance remains unqualified and is tracked in docs/TODO.txt. Five focused checks fail with PR #298's implementation and pass with this change. They cover slot and aliased-page pressure, admission, duplicate publication, promotion, and completion recency. Compaction preserves pages and fences at 64-, 128-, 256-, and 2048-token page geometries. The Helios server,runtime-core CPU suite passes 1405 tests with 26 ignored when run serially. A parallel run had one failure in unchanged payload-collection code; that test passes in isolation and in the serial suite. Ignored cases need CUDA, external checkpoint/payload fixtures, or manual CPU benchmarks. The patch applies to 3e9a95d3 plus PR #298; that base passes 1387 library tests with 26 ignored using the same serial CPU configuration. Signed-off-by: Martin Vit <martin@voipmonitor.org> Design-Signed-Off-By: Codex (GPT-6); design-review=ed22
A long request can finish with a recent terminal snapshot but a prompt snapshot still ranked by admission time. Follow-ups that branch or rewrite generated history can then lose the prompt snapshot under pressure. The terminal's direct parent provides a bounded second resume point; immutable checkpoint sharing makes its usefulness independent of which request captured or restored it. Refresh the published terminal and its actual cached parent with the same completion epoch. Duplicate publication follows the retained terminal's parent link, which can differ from the completing request's prefix. Stop at that parent so earlier ancestors keep aging. Preemption and execution errors still suppress completion refresh, and completion without a terminal or cancellation after progress still refreshes only the retained prefix. Core formats, capture budgets, and resource lifetime rules remain compatible. The implemented policy is expected to retain useful prompt boundaries after long responses without protecting entire checkpoint chains. CPU tests qualify the retention decisions; live serving improvements remain unmeasured. Three regressions fail on 8999ad1 and pass with this change: interleaved request completion, duplicate publication, and a restored parent checkpoint. Tests also preserve grandparent compaction and page order, preemption epochs, and client-stop fallback behavior. The Helios library suite with server,runtime-core and pinned templates passes 1408 tests in serial CPU execution, with 26 ignored CUDA, external-fixture, or manual-benchmark cases. No GPU execution or service benchmark was performed. The combined patch applies to 3e9a95d3 plus PR #298 and passes 1390 library tests with 26 ignored using the same serial CPU configuration. Signed-off-by: Martin Vit <martin@voipmonitor.org> Design-Signed-Off-By: Codex (GPT-6); design-review=ed22
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reusing or completing a long cached prefix refreshed every ancestor's eviction rank, allowing unused continuation snapshots to compete as recently used entries against other conversations' captures and KV pages. A descendant needs its ancestor pages but restores only its selected snapshot. Completion also needs to retain a useful earlier endpoint: follow-ups that branch or rewrite generated history can depend on the prompt or message snapshot immediately before the terminal. Leaving that snapshot at the admission epoch can lose it after a long response.
This PR changes two shared retention operations:
PrefixCheckpointCache::touchrefreshes only the selected checkpoint, retaining the maximum epoch. Admission reuse, promotion, and duplicate publication no longer refresh the entire ancestor chain.The expected benefit is fewer storage-related capture skips while retaining useful prompt boundaries after long responses. The policy is implemented and qualified by CPU regression tests; native serving latency, hit rates, and memory savings remain unqualified. Existing compaction preserves descendant page order, direct pins, branch points, retirement fences, and compaction-heir notices. The change applies to the shared Kimi, DeepSeek, GLM, and Qwen cache contracts without core re-export. Capture budgets and role ordering remain unchanged. Completion refreshes at most two checkpoints; there is no fixed row cap or proactive thinning, and a matching prompt or message snapshot is not guaranteed to exist.
Validation used Linux x86_64, Rust 1.95.0, GCC/G++ 13.3, protoc 30.2, pinned external template fixtures, an isolated Cargo target directory, and masked CUDA devices. The root test process dropped
cap_dac_overrideandcap_dac_read_searchso filesystem permission tests remained meaningful.3f6c74a160d00bba7ccf25f9e94b07e2e23edf15, with regression checks added8999ad14135acfb7ca0aa563ff7216d8e5e34c7d, with parent-refresh checks addedserver,runtime-core, serial CPU execution3e9a95d304843fbd9251ac11a8bdd622f04d93d0plus PR #298The 26 ignored cases require assigned CUDA devices, external checkpoint/payload inputs, or manual CPU benchmarks. No GPU execution or service benchmark was performed. A parallel library run at
8999ad14failed the unchangedcore::cache::tests::store_slice_streams_multi_block_payloads_and_holds_its_guardcollection assertion (zero objects collected instead of one); its isolated rerun and serial suites pass. The cause is unconfirmed, and this PR does not change payload-cache code.To reproduce, install the documented native build dependencies and
huggingface_hub, place protoc 30.2 onPATH, and provide a locked-memory limit of at least 64 MiB:An unprivileged process can run the Cargo command without the
capshwrapper.This PR targets
mainand is stacked on #298 at3f6c74a160d00bba7ccf25f9e94b07e2e23edf15. That dependency supplies bounded host-restore waiting and completion-time recency. Merge #298 first; this PR limits recency propagation to the selected snapshot on reuse and to the terminal plus its direct parent on completion. Until #298 merges, the cumulative diff includes its changes. No measurement files are included.