Repository navigation
[HiCache][perf] Queue and batch write-through backups off the request-finish path - #40363
Open
alphabetc1 wants to merge 21 commits into
Open
alphabetc1 wants to merge 21 commits into
alphabetc1 wants to merge 21 commits into
Conversation
alphabetc1
marked this pull request as ready for review
September 25, 2026 05:41
alphabetc1
requested review from
Ying1123,
hanming-lu,
hnyls2002,
huangtingwei9988,
hzh0425,
ispobock,
merrymercy,
xiezhq-hermann and
yizhang2077
as code owners
September 25, 2026 05:41
…ad of a capped cross-step queue
…d write-through paths
… write-through tests
…ack at insert time
…_HICACHE_BATCHED_BACKUP (default off)
This branch has not been deployed
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.
Motivation
With
--enable-hierarchical-cache(write_through) the unified radix cache backs up every new tree node to host. After #39050 the D2H submits are merged per step, but the per-node bookkeeping that precedes a submit still runs insidecache_finished_req, on the scheduler thread, at the moment the node is inserted:build_backup_spec(SWA/Mamba transfer lists,torch.cat/clone), host poolallocfor KV + side pools (with SWA host eviction when that pool is full),resolve_host_transfers,commit_backup,inc_lock_ref, and the ack bookkeeping. On Inkling-Small-NVFP4 that is ~0.2 ms per node, and most of it is fixed per-call torch-op and Python overhead on small tensors, not per-token work.Modifications
Write-through backups are now queued at insert and backed up in merged batches at flush. There is no flag. Write-back, the buffer pipeline and the external linker keep their existing paths.
Accuracy Tests
Speed Tests and Profiling
Base upstream/main 70f0b73 vs this PR, TP=4, Rust tree core (the default). Workload: 128 lanes x 16 timed turns, multi-turn (a 1k-token prefix shared by every 16 lanes, 4-5.6k-token first prompt, +256 tokens per turn, outputs 128-512 with
ignore_eos). The working set stays on device, so L2 only adds the write-through cost (no host hits). Each round runs L1 (main), L2 (main) and L2 (PR) servers back to back in a rotated order; loss is relative to the same round's L1, and the PR column is paired against main L2 per round. The numbers were taken with the batched path enabled on the PR's earlier heads (e7fa154 / feae617), which run the same write-through code as this head.* Round 1's L1 server ran before the FlashInfer autotune cache settled and is left out of the loss columns (n=5); the paired column uses all 6 rounds.
Inkling and DSV4 use
--max-total-tokens 2097152(Inkling also--max-mamba-cache-size 1024), DSV4--hicache-ratio 2. The PR helps where the request-finish bookkeeping is on the critical path (Inkling on Blackwell) and is neutral elsewhere: DSV4 runs at ~3k tok/s with a run-to-run spread larger than its L2 cost, and the H200 Qwen3-8B L2 cost is dominated by the page-size-1 host copy path, which this PR does not touch. An earlier GB300 session with the same commits (7 vs 7 interleaved L2 servers) measured +1.25% (t=3.2); its per-step profile shows the backup path 0.50 -> 0.30-0.33 ms andprocess_batch_result-0.22 to -0.27 ms, and the largest remaining L2 cost ischeck_hicache_events(0.77-0.89 ms per step).Checklist
CI States
Latest PR Test (Base): ✅ Run #38109269825
Latest PR Test (Extra): ❌ Run #38109269607
Latest PR Test (AMD ROCm 10): ❌ Run #38109269809