[Bugfix] Normalize sparse MLA warmup compression ratios (#49392)

Signed-off-by: Wu, Xiaochang <xiaochang.wu@intel.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Xiaochang Wu
2026-07-27 07:02:48 +00:00
committed by GitHub
co-authored by Copilot
parent fd9d2ede6f
commit 8061dc26bd
2 changed files with 24 additions and 2 deletions
@@ -1,15 +1,37 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
from types import SimpleNamespace
import pytest
import torch
from tests.v1.attention.utils import create_vllm_config
from vllm.v1.attention.backend import CommonAttentionMetadata
from vllm.v1.attention.backends.mla.indexer import DeepseekV32IndexerMetadataBuilder
from vllm.v1.attention.backends.mla.indexer import (
BuildPrefillChunkMetadataKernel,
DeepseekV32IndexerMetadataBuilder,
)
from vllm.v1.kv_cache_interface import MLAAttentionSpec
def test_indexer_warmup_normalizes_zero_compress_ratios():
config = SimpleNamespace(
scheduler_config=SimpleNamespace(max_num_batched_tokens=8),
model_config=SimpleNamespace(
hf_config=SimpleNamespace(compress_ratios=[0, 0, 4, 128, 0])
),
parallel_config=SimpleNamespace(
decode_context_parallel_size=1,
cp_kv_cache_interleave_size=1,
),
)
keys = BuildPrefillChunkMetadataKernel().get_warmup_keys(config)
assert {key.COMPRESS_RATIO for key in keys} == {1, 4, 128}
@pytest.mark.skipif(not torch.cuda.is_available(), reason="requires CUDA")
def test_indexer_builder_deepseek_v4_compressed_slot_mapping_uses_storage_block_size():
"""Regression test: DeepseekV4 compression path must compute slot_mapping from