Repository navigation
perf(cache): retain reused frontiers and active branch checkpoints - #902
Closed
LostVector wants to merge 2 commits into
Closed
LostVector wants to merge 2 commits into
LostVector wants to merge 2 commits into
Conversation
This was referenced Oct 30, 2026
LostVector
marked this pull request as ready for review
October 31, 2026 02:06
This was referenced Nov 4, 2026
Collaborator
|
Thanks for this work and for the detailed measurements. We plan to migrate DeepSeek from the legacy continuation cache to the component cache, tracked in #1000, which will fix this problem. DeepSeek is the only in-tree model still on the legacy path, so we will address it there rather than change the legacy retention policy. We are closing this PR in favor of that migration. |
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.
Repeatedly reused continuation frontiers can be displaced by short one-off snapshots under a bounded RAM budget. Retain useful reused frontiers for a bounded amount of new feasible demand, and track active input metadata so shared parents survive while their children finish. Configured budgets, existing redundancy rules and snapshot payload ownership remain in force.
The reviewed diff remains two files: the legacy continuation-cache policy and its CPU regression test. It has no RDMA dependency. Single-host Flash-Next selects the separate component cache; no speedup of that path is claimed.
Refreshed against canonical
f25f4744a6348e6c9670e2684a0a1f898c1b69caby a normal merge, preserving the original measured commit. Fresh validation on this standalone branch:continuation_cache_test,text_model_runner_test,text_generation_scheduler_testandcontinuation_disk_store_test: 4/4 pass, 2.78 seconds total, CPU preset with AMD Clang 23.Reproduce the focused checks after the documented source prerequisites:
cmake --preset cpu-test -B build/cache-review cmake --build build/cache-review --target continuation_cache_test text_model_runner_test text_generation_scheduler_test continuation_disk_store_test --parallel 4 ctest --test-dir build/cache-review -R '^(continuation_cache_test|text_model_runner_test|text_generation_scheduler_test|continuation_disk_store_test)$' --output-on-failureEarlier evidence and retained caveats (prior canonical base 192b75a; not relabeled as the refreshed revision)
Under a bounded continuation-cache RAM budget, short one-off snapshots can evict long, repeatedly reused frontiers. A shared parent checkpoint can also be classified as redundant before its active child requests publish their final frontiers. Later requests then repeat substantial prefill despite an otherwise useful cached working set.
Track active request tokens and prefix-specific input identity without owning extra GPU snapshot payloads. Use that metadata when recognizing branch points. Protect recently reused frontiers from lower-value incoming snapshots, comparing cached tokens per retained byte among the existing sole-family candidates. Protection expires after one cache-capacity worth of new feasible snapshot demand, including demand from partial cache hits; it does not permanently pin old histories. Propagate lower-tier restore evidence, and clear active metadata on release/cancellation/failed restore. Existing redundancy/supersession rules and the configured RAM budget remain in force.
This diff changes only
continuation_cache.cppand its CPU regression test. It does not include the distributed executor, the independent MTP scheduling patch, a runtime flag, or model arithmetic changes.Current-main validation
Based on
gufo-org/gufo:mainat192b75a8b6079b498461b598b8514ecd05d71caf.python3 tools/ci/check-format.py: all 703 C++ files passed (clang-format 21.1.8).cmake --preset cpu-test -B <build>using AMD clang 23 and locally extracted development dependencies;cmake --build <build> --target continuation_cache_test --parallel 4;ctest --test-dir <build> --output-on-failure -R '^continuation_cache_test$': passed, 0.21 s.git diff --check: passed.192b75a8fails atrepeated offers count only once; it passes with this patch. This establishes that the added policy contracts distinguish main from the candidate, not an actual-model speedup.Supporting TP2 experiment — not a current-main speed claim
The same policy was developed and measured on
neuhaus/gufo:rdma, with our independent snapshot/MTP scheduling improvement present in both control and candidate. Fixed eight randomized paired blocks, 16 fresh process-pair starts, warm 49-request cache-pressure history, 784 total executions:Paired wall-time reduction 23.3175%, paired bootstrap 95% CI 23.1355–23.4787%, exact two-sided sign-flip p = 0.0078125; eight of eight pairs improved. The saved work is 33,855 prefill tokens across three retained-prefix cases. This is workflow latency, not 23% faster decode, equal-compute acceleration, or a representative estimate for every chat history. All requests matched frozen per-arm outputs and expected cache/prefill work; the changed cache hits are intentional.
Conditions: two 128 GB Strix Halo hosts, Flash Next UD-Q4_K_XL/shared-Q8_0 MTP, context capacity 65,536 (largest prompt 11,332 tokens), two sessions, chunk 2,048, 1 GiB cache RAM, two 20 Gb/s USB4 links. Timing excludes loading, shutdown and the separate cold controls. No full n-gram-table warming. Toolchain/driver/settings held fixed within comparisons. These measurements used an experimental GPU build profile, not the freshly adapted current-main commit.
A separate full 98-request TP2 history preserved every answer. Combined sampled/cancellation checks (14 requests, four server-verified cancellations), 18K/32K-context checks (28 requests, eight cancellations), and a real sampled disk-cache restore across process-pair restart (three requests) passed. A clean release GPU build of the reviewed RDMA-source combination also completed; this does not constitute GPU qualification of this main-based branch.
Remaining draft qualification
DeepSeekTextRunnerinherits the legacy cache path;QwenTextRunnerandQwenFlashNextTextRunnerexplicitly select the separate component cache, which this patch does not change. No single-node Flash Next speedup is claimed. No DeepSeek checkpoint is installed on our test hosts, so actual-model qualification of that main path remains outstanding. The TP2 branch uses the changed legacy cache.Clean RDMA review-build follow-up
A fresh clean-source B/C/B integration run compared scheduling-only
b6d4cbaawith scheduling-plus-retentiond29ac4c9. All 290 normalized compilation commands matched. All 294 request executions, including 49 cold-answer controls per arm, matched input/output hashes across arms. Warm prefill totals were 122,660 / 88,805 / 122,660; snapshot-copy bytes 7,764,835,908 / 7,137,814,776 / 7,764,835,908. Exactly the same three requests changed cache/prefill work. Both controls retained the same four floor failures; candidate retained only the pre-existing compaction miss. Tracked driver error deltas and severe-kernel scans were clean; both hosts ended on the approved idle driver baseline.This validates the reviewed RDMA-source behavior without the experimental GPU optimizations. It is not another confidence estimate or current-main DeepSeek GPU qualification. All 69 strict timing flags across the two comparisons remain recorded. A CPU negative-control compilation overlapped early candidate requests and was paused when detected, so the timings are explicitly affected and do not support a clean speed comparison. The original controller also incorrectly demanded whole-suite success: its first 98-request control and known floor failure were retained; continuation ran only the unmeasured candidate/after arms, preserving strict cold-answer checks and every floor failure. No arm was rerun or excluded.
Subsequent isolated clean-source timing check
One predeclared fixed B/C/B, with no concurrent compilation, replayed the original 49 warm requests/start against the same frozen per-arm input/output/work references. All 147 executions matched. Direct warm-history wall was 79.227634 / 60.950779 / 79.583587 s, a candidate reduction of 23.0688% / 23.4129% against the two controls. Prefill totals remained 122,660 / 88,805 / 122,660. Tracked driver error deltas, severe-kernel scans, fixed per-host boot/command line and approved final idle checks passed. Full cold-answer correctness belongs to the separate 294-request integration above.
These three starts are diagnostic point comparisons, not another confidence interval or a replacement for the earlier eight paired experimental-build starts. All 28 strict request/phase flags remain: 24 have the same reported work/admission residency and four have changed cache work. Two early short-fill requests are about 75 ms slower than both controls, while some neighboring requests show similar slowing in the later control too; their n-gram row/cache-hit/disk-read counts and snapshot payload work match. Their cause remains unassigned and needs a narrow path trace. No per-request equivalence or complete timing qualification is claimed.
The remaining compaction floor has prior direct policy attribution: its 2,048-token history reservation is refused because all victims are last-family continuations (priority 3), while optional history may evict only priority <=1. The later 11,230-token checkpoint shares only 2,263 tokens with the compacted prompt and cannot rewind recurrent state. The existing CPU contract explicitly protects those last-family continuations. Broader history admission previously added copy work without fixing compaction; changing that policy is outside this diff.
Short-prefill flag path trace
A fixed same-candidate untraced/traced/untraced replay of the exact first 13 fill requests matched all 39 outputs and expected work. Both hosts captured prefill/capture/cache spans, scoped HIP calls, GPU kernels/copies, libc reads and scheduling. The original ~75 ms excess did not recur in the untraced controls; the protocol adds three seconds of initial idle and observer preparation, so identical power/observer conditions are not claimed.
A positive traced delay in request index 7 involved 40 EVO 4 KiB O_DIRECT model-file reads: starts within 0.083 ms, returns within 0.823 ms after a 44.490 ms window. The slowest reader spent 44.404 ms blocked and 0.00087 ms runnable. EVO had 39.738 ms without a recorded GPU kernel in that read window; Corsair had a 40.514 ms GPU wait kernel in the corresponding ordinal prefill pass. These are application read-call timings, not hardware NVMe command-completion times. This locates the traced delay on a read/dependency path; it does not identify an SSD/controller cause or retrospectively assign the untraced flags.
Traced TP prefill lock wait peaked at 3.44 µs, wrapper-minus-inner prefill at 76.977 µs, cache reservation at 0.196524 ms, and capture at 6.727849 ms including copy/dependency work. Thus no millisecond cache-bookkeeping or TP-dispatch explanation was observed for that traced read stall. BPF method/HIP/read counters balanced, reported recursion misses were zero, explicit perf loss/order checks passed and SDK attach/detach succeeded; no independent SDK drop counter is available. Original flags remain retained, and next attribution would require request-correlated kernel I/O/completion tracing.
Command-correlated kernel I/O follow-up
A further fixed untraced/kernel-traced/untraced replay matched all 39 outputs and expected work, with no GPU profiling or policy change. It did not reproduce the later ~75 ms excess. Corsair instead had 190 slow reads confined to its first 38 ms of table I/O. Of these, 177 single 4 KiB commands have the validated doorbell boundary: median 20.798 ms doorbell → captured matching IRQ, versus 2.180 µs IRQ → CPU CQ consumption, across 31 queues/vectors. Six matched batch 8 KiB commands use only a queue-return boundary; seven slow reads lack full chains and remain separate. This places the matched startup delay before handler entry, including device/DMA/interrupt delivery; it is not a pure SSD service-time measurement.
Kernel probe links report up to 7/14 misses per link on EVO/Corsair; emitted read-return records also fall short of their counters by 1/3. These gaps are retained despite zero BPF-program recursion misses; no loss-free attribution is claimed. First-request prefill was 328.9 / 324.5 / 339.3 ms, so this replay shows no added end-to-end loss from that startup cohort. The 3-second initial idle and previously advertised PS4 exit latency make wake-up plausible, but power state was not sampled. Do not merge this startup event with the earlier later-request read cohort or persistent ~70 ms plateau. Both hosts returned to the approved idle driver state.
Related drafts