From d5051abaf19a1cce19159756a79d27ccb0b2fccf Mon Sep 17 00:00:00 2001 From: Netanel Haber <58652339+netanel-haber@users.noreply.github.com> Date: Fri, 25 Sep 2026 02:46:42 +0300 Subject: [PATCH] [Bugfix][Mamba] Restore prompt-tail prefix-cache hits with MTP (#58368) Signed-off-by: Netanel Haber <58652339+netanel-haber@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 (1M context) Co-authored-by: Benjamin Chislett --- .../test_mamba_eagle_resume_checkpoint.py | 22 +++++++++++++++++++ vllm/v1/core/single_type_kv_cache_manager.py | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/v1/core/prefix_cache/test_mamba_eagle_resume_checkpoint.py b/tests/v1/core/prefix_cache/test_mamba_eagle_resume_checkpoint.py index 4cb9afe871..324aef425b 100644 --- a/tests/v1/core/prefix_cache/test_mamba_eagle_resume_checkpoint.py +++ b/tests/v1/core/prefix_cache/test_mamba_eagle_resume_checkpoint.py @@ -196,6 +196,28 @@ def test_sibling_resumes_below_the_block_grid_when_the_prefix_ends_early(): assert hit == resume, f"expected the resume point at {resume}, got {hit}" +@pytest.mark.parametrize("mtp_draft_group_identified", [False, True]) +def test_mamba_prefix_cache_drops_hash_block(mtp_draft_group_identified): + block_size, hash_block_size = 1024, 64 + manager = _manager( + block_size, + hash_block_size, + eagle_group=0 if mtp_draft_group_identified else None, + ) + prompt_a = PREFIX[:1600] + hit_after_mtp_block_drop = len(prompt_a) - hash_block_size + + _prefill( + manager, + _stub(manager, block_size, hash_block_size), + make_request("A", prompt_a, hash_block_size, sha256), + ) + + tokens_after_a = [-1] * 500 + hit = _sibling_hit(manager, len(prompt_a), tokens_after_a, hash_block_size) + assert hit == hit_after_mtp_block_drop + + # -------------------------------------------------------------------------- # Invariants the two clauses have to keep diff --git a/vllm/v1/core/single_type_kv_cache_manager.py b/vllm/v1/core/single_type_kv_cache_manager.py index 70d56c6543..0dd9734847 100644 --- a/vllm/v1/core/single_type_kv_cache_manager.py +++ b/vllm/v1/core/single_type_kv_cache_manager.py @@ -2078,7 +2078,7 @@ class MambaManager(SingleTypeKVCacheManager): latest_prompt_hash_boundary = ( request.num_prompt_tokens // hash_block_size ) * hash_block_size - if self.use_eagle: + if self.drop_eagle_checkpoint_block: # Eagle groups match one hash unit past the candidate and drop it, # so register the tail one unit lower. latest_prompt_hash_boundary = max(