Conversation
…ttention boundary mismatch Signed-off-by: Jing Wang <jingwang96@qq.com>
starkwj
requested review from
ApostaC,
NickLucche,
ivanium,
orozery and
xuechendi
as code owners
September 12, 2026 15:01
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
One or more issues must be addressed before approval.
Pull request overview
Fixes MooncakeStore prefix-cache misses by aligning Mamba/KDA boundary writes with EAGLE attention lookup behavior.
Changes:
- Adds shared EAGLE peek-margin calculation.
- Tracks completed token length before storing attention proofs.
- Handles per-boundary tail writes and deduplicates keys.
- Adds focused scheduler and worker tests.
File summaries
| File | Description |
|---|---|
| vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/worker.py | Updated as part of this pull request. |
| vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/scheduler.py | Updated as part of this pull request. |
| vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/data.py | Updated as part of this pull request. |
| vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/coordinator.py | Updated as part of this pull request. |
| tests/v1/kv_connector/unit/test_mooncake_store_worker.py | Updated as part of this pull request. |
| tests/v1/kv_connector/unit/test_mooncake_store_scheduler.py | Updated as part of this pull request. |
Review details
Suppressed comments (2)
vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/worker.py:762
- This hardcodes the fine-grained case (
eagle_margin == hash_block_size), but_eagle_peek_marginreturnsspec.block_sizefor non-fine-grained EAGLE groups such asSlidingWindowManager. Lookup then probesB + spec.block_sizeand drops that block, while this store keeps that group atB, so a hybrid Mamba + EAGLE-SWA boundary cannot be reused. Apply the per-group margin here.
eagle_margin = self.coord.eagle_peek_margin_by_group.get(g_idx)
if (
eagle_margin == hash_block_size
and boundary + eagle_margin <= req_meta.completed_token_len
):
group_boundary += eagle_margin
vllm/distributed/kv_transfer/kv_connector/v1/mooncake/store/worker.py:838
- This dispatch gate only recognizes an EAGLE peek of one hash unit and checks completion only through
B + H. For a block-granularity EAGLE group, lookup requiresB + spec.block_size; with no hash-unit-margin group, an aligned boundary takes_boundary_snapshot_putsand never publishes the companion key even when that block is complete. Derive the gate from each group's actual margin, matching the lookup-side calculation.
hash_unit_peek = any(
margin == self.coord.hash_block_size
for margin in self.coord.eagle_peek_margin_by_group.values()
)
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Signed-off-by: Jing Wang <jingwang96@qq.com>
…oints as original main Signed-off-by: Jing Wang <jingwang96@qq.com>
This was referenced Sep 14, 2026
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
Fix MooncakeStore cache misses caused by an EAGLE-induced boundary mismatch between Mamba/KDA states and attention KV cache.
For a reusable Mamba/KDA token boundary
B, EAGLE attention lookup probes the original cache boundaryB + H(His the prefix-match-unit) and then drops one hash unitHdue to the eagle drop, while other cache type (i.e., Mamba) directly looks up state atB.For a request at its prompt's tail, the existing boundary offload path (
_sub_block_tail_puts) stores Mamba and Attention both atB.Thus, when the same or the subsequent request lookup MooncakeStore, it get Attention at
B, and dropHdue to eagle drop, then lookup Mamba atB-Hand missed. (When the HBM prefix cache is evicted.)This PR makes the store layout match lookup behavior:
B.B + H.B + Hwhen GPU computation has completed through that position.Changes
completed_token_lento store metadata so the worker only publishes an attention companion whenB + Hhas been computed.The
His the EAGLE peek margin for each attention group.For fine-grained lookup,
His the hash block size; for block-granularity groups, it may be the group's physical block size.The boundary handoff logic covers three cases:
BB + Hwhen completed; otherwise only throughBBB + Hcompanion when completed; otherwise publish no companionB_sub_block_tail_putsis renamed to_boundary_tail_putsbecause it nowhandles both sub-block boundaries and block-aligned prompt replay boundaries
that require an EAGLE attention companion.
Test Plan
Test with some requests, then /reset_prefix_cache clean the HBM cache, send the same requests again.
Test Result
cached_tokens: 0created_cache_tokens: 7296cached_tokens: 0created_cache_tokens: 7296cached_tokens: 7296created_cache_tokens: 0cached_tokens: 0created_cache_tokens: 23040cached_tokens: 0created_cache_tokens: 23040cached_tokens: 23040created_cache_tokens: 0cached_tokens: 0created_cache_tokens: 41088cached_tokens: 30464created_cache_tokens: 10624cached_tokens: 41088created_cache_tokens: 0Thus, for the
maincurrent code, request A and B totally missed from MooncakeStore.Request C got partial hit at an internal point (FlashKDA internal checkpoint), but still missed a large portion.
unit tests passed:
Essential Elements of an Effective PR Description Checklist
supported_models.mdandexamplesfor a new model.Duplicate-work check
No open PR implementing the same MooncakeStore write-side B / B + H boundary pairing was found.
There are some PRs targeting at the similar issue around eagle drop, including #51295, #55036, #53945, etc.
But not related to external KV offloading as Mooncake.
B, but not save tail attention KV atB+H.AI assistance
AI was used for problem analysis, code implementation and review.