Conversation
…lookahead block With a sliding-window KV cache group whose block size is smaller than the alignment (DeepSeek V4: block 64, window 128, lcm 256) and EAGLE, MTP or DSpark speculation, the prefix cache never hits: "Prefix cache hit rate: 0.0%", silently, reported in 1CatAI#205. The write-side mask registers only the last blocks of each aligned segment, while the lookup under speculation needs one more contiguous block, the one past the aligned boundary, which it then drops. This is upstream's fix by ivanium, merged 2026-06-02. Three files apply cleanly to this base, four hunks were placed by hand and match the ones listed in 1CatAI#205: the use_eagle attribute in __init__, the NamedTuple import, verify_and_split_kv_cache_groups in SpecGroup form while keeping this base's prefix_cacheable skip, assertion and lcm_block_size, and the hunk that spans two methods. There the call site takes drop_eagle_block, the per-round flag, and cache_blocks lets an EAGLE group cache one block past the aligned boundary. alignment_tokens keeps lcm_block_size where upstream passes scheduler_block_size. This base's own find_longest_cache_hit variants (the no-op managers and the Mamba align manager) take the renamed parameter. Upstream's three regression tests build KVCacheManager directly; this base has no scheduler_block_size argument. Fixes 1CatAI#205. Co-authored-by: Claude <noreply@anthropic.com> Signed-off-by: Peuqui <peuqui@github.com>
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.
Purpose
Fixes #205.
With a sliding-window KV cache group whose block size is smaller than the
alignment (DeepSeek V4: block 64, window 128, lcm 256) and EAGLE, MTP or
DSpark speculation, the prefix cache never hits. The engine logs
Prefix cache hit rate: 0.0%on every interval and nothing else; everyfollow-up turn of a conversation recomputes its whole context.
The cause and the fix are upstream's: vllm-project/vllm#44082 by ivanium,
merged 2026-06-02. The write-side mask registers only the last blocks of each
aligned segment, while the lookup under speculation needs one more
contiguous block, the one past the aligned boundary, which it then drops.
The two sets never meet. @kezboard233 reported this for this repository in
#205, with a root-cause analysis and a hand-merged patch against an older
main; this PR is the same backport against currentmain, and all creditfor the analysis is theirs. Our four hand-placed hunks came out identical to
the ones listed in #205 section 5, which we take as a good sign for both.
Applying
gh pr diff 44082 -R vllm-project/vllmto b711d53: three filesapply cleanly, four hunks are rejected and were placed by hand.
single_type_kv_cache_manager.py:self.use_eagle = Falsein__init__.Rejected only because this base has
take_pending_boundary_state_offloadsright after
__init__.kv_cache_coordinator.py:from typing import NamedTuple.verify_and_split_kv_cache_groupsin upstream'sSpecGroupform, keepingwhat this base adds: the
prefix_cacheableskip, the "at least onecacheable group" assertion, and the
lcm_block_sizecomputation.alignment_tokenskeepsself.lcm_block_sizewhere upstream passesself.scheduler_block_size, which this base does not have.find_longest_cache_hitthe call sitetakes
drop_eagle_block, the per-round flag; left asuse_eagleit wouldpass the group-level flag and lose the convergence guard, silently. In
HybridKVCacheCoordinator.cache_blocksan EAGLE group may cache one blockpast the aligned boundary. We made exactly the mistake [Bug]: DSpark/MTP + 前缀缓存 命中率恒为 0 且静默失效 —— 上游 #44082 可直接 backport 修复 #205 warns about
in our own first attempt: a mask-only fix that gets hits but never
registers that lookahead block.
Beyond upstream's diff, this base has its own
find_longest_cache_hitvariants (the two no-op managers and the Mamba align manager) that still
named the parameter
use_eaglein their bodies; they takedrop_eagle_blocknow, otherwise they raiseNameError. Upstream's threeregression tests build the manager through a helper that passes
scheduler_block_size; here they callKVCacheManager(...)directly, thisbase derives the lcm itself.
test_mamba_honors_eagle_cache_droppasses therenamed keyword.
Test Plan
Test Result
With this change:
77 passed.Upstream's three regression tests against unmodified
main(b711d53), testfile only:
pre-commit: all hooks passed; mypy-3.10 manual stage passed.
Serving, which #205 says it could not measure. DeepSeek-V4-Flash NVFP4 +
DSpark (
num_speculative_tokens=5),--enable-prefix-caching, pipelineparallel over two RTX 8000 and three V100, on a fork of this repository that
carries the same backport:
1.5 s, with
cached_tokens: 4864reported for the second one. 4864 is 19 alignedsegments of 256; the twentieth is the lookahead block EAGLE drops.
Before, every turn took 85 to 99 s.
Prefix cache hit ratein the engine log goes from 0.0% to 56.8% over thetest session.
cached blocks are the right ones.
Not a duplicate
No PR carries this fix. #603 mentions #205 in passing and touches none of the
five files; #239 matches the last search on wording only.
Overlap to be aware of: #617 (open, Mamba prefix-cache retention, backport of
upstream #45845/#47782) and #598 stacked on it change the same three core
files. #617 does not contain #44082: its diff has no
drop_eagle_block, noSpecGroup, no_contiguous_blocks_for_hitand none of the three regressiontests. It does add a
reachable_block_maskclassmethod to the Mamba manager,with a different signature (
retention_interval,reachable_boundaries),and it edits
HybridKVCacheCoordinator.cache_blocks. The two changes areindependent in substance but will conflict textually in
single_type_kv_cache_manager.pyandkv_cache_coordinator.py. Whicheverlands second needs a rebase; I am happy to do that for this one.
AI assistance
AI assistance (Claude) was used for the hand-merge, the comparison with
upstream and with #205, and this text. I have read every changed line and
ran the tests and the server measurements above on my own hardware.
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.