Skip to content

[Mooncake] Guards on the partial-hash hit retry - #52273

Draft
xinli-sw wants to merge 2 commits into
vllm-project:agentx-k3from
xinli-sw:k3-mooncake-partial-hit-retry-guards
Draft

[Mooncake] Guards on the partial-hash hit retry#52273
xinli-sw wants to merge 2 commits into
vllm-project:agentx-k3from
xinli-sw:k3-mooncake-partial-hit-retry-guards

Conversation

@xinli-sw

@xinli-sw xinli-sw commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Stacks on #52272.

mispa-ms and others added 2 commits August 14, 2026 01:21
…ndaries

Replaces the local fix reverted in the previous commit. vllm-project#50359 is upstream's
answer to the same defect and states it exactly: "A longer stored key proves
that one object exists at that endpoint; it does not imply that Mooncake also
contains independently addressable objects at every shorter hash boundary."

Our -704 is that, reached through DCP. Core's fine-grained lookup deliberately
extends a hit into the first non-full block -- locally a block is usable as a
prefix, remotely an object is not -- and the EAGLE path then subtracts exactly
one hash unit, landing mid-block by construction. Off DCP the gap is empty
because the attention block equals hash_block_size; scaling it by dcp opens a
96-unit interior, and every hit landing there names a key nobody wrote. Measured
on B300 c8 DCP=8: 2,757,664 OBJECT_NOT_FOUND, all on the one scaled group.

Preferred over the reverted local fix, which disabled partial hash hits under
DCP outright. That reached the same boundary in one step but gave up
fine-grained hits everywhere, including the no-spec arm that works today at a
29.1% external hit rate. vllm-project#50359 keeps them and steps back only when the exact
key is absent, off the already-populated exists set, so no extra store RPC.

ONE ADAPTATION. Upstream unpacks self.attention_groups[0] as a 3-tuple; here
SpecGroup also carries manager_cls and use_eagle, so that raises ValueError on
the first lookup. Attribute access instead, which is arity-independent. git
apply reported the patch clean -- this is a runtime mismatch, not a textual one.

The added test asserts a stronger property than upstream's: the reported hit
must be an exact object boundary for EVERY group, not only attention_groups[0],
over dcp in {1,2,4,8}. Upstream validates one group because off DCP the coarse
group is Mamba, which is tail-only; that assumption is what DCP inverts.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit ada5e31)

Co-authored-by: mispa-ms <81828223+mispa-ms@users.noreply.github.com>
Reviewing the carried patch on this branch found one path where it is safe only
by accident and one where it crashes.

SAFE BY ACCIDENT. find_longest_cache_hit is also called from load_mask, whose
pool is built with exists=None -- a sentinel that makes get_cached_block answer
"present" to anything. The retry therefore never fires there. Nothing states
that. If it did fire, load_mask would return a mask for a shorter length while
_handle_request keeps using the original token_len, so the trailing chunks
process_tokens yields would index past the end of the mask and be skipped,
leaving those blocks uninitialized in the local KV pool. That is silent, unlike
the -704 this patch exists to fix. Now explicit: ExternalCachedBlockPool carries
tracks_existence, and the retry declines to run against a pool that has no truth
to check.

CRASH. Upstream asserts isinstance(spec, FullAttentionSpec) on
attention_groups[0]. That group is only attention-first by a sort; a Mamba-only
layout puts a MambaSpec there, and partial hash hits are enabled by a Mamba group
alone, so the assert is reachable and fires at the first lookup. Nothing to
revalidate in that case anyway -- the defect needs an attention group coarser
than hash granularity, and a recurrent group is tail-only -- so return True.

Both guards are ours, not upstream's, and belong in a comment on vllm-project#50359.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 7b97d35)

Co-authored-by: mispa-ms <81828223+mispa-ms@users.noreply.github.com>
@mergify mergify Bot added the kv-connector label Aug 14, 2026
@xinli-sw
xinli-sw force-pushed the k3-mooncake-partial-hit-retry-guards branch from d241e11 to a7f22dc Compare August 14, 2026 13:57
@xinli-sw xinli-sw changed the title [Mooncake] Guards on the partial-hash hit retry [Bugfix][Mooncake] Guard partial-hit revalidation Aug 14, 2026
@mergify mergify Bot added the bug Something isn't working label Aug 14, 2026
@xinli-sw
xinli-sw force-pushed the k3-mooncake-partial-hit-retry-guards branch from a7f22dc to d241e11 Compare August 14, 2026 15:30
@xinli-sw xinli-sw changed the title [Bugfix][Mooncake] Guard partial-hit revalidation [Mooncake] Guards on the partial-hash hit retry Aug 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working kv-connector

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants