[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:
@@ -1,15 +1,37 @@
|
|||||||
# SPDX-License-Identifier: Apache-2.0
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||||
|
|
||||||
|
from types import SimpleNamespace
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
from tests.v1.attention.utils import create_vllm_config
|
from tests.v1.attention.utils import create_vllm_config
|
||||||
from vllm.v1.attention.backend import CommonAttentionMetadata
|
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
|
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")
|
@pytest.mark.skipif(not torch.cuda.is_available(), reason="requires CUDA")
|
||||||
def test_indexer_builder_deepseek_v4_compressed_slot_mapping_uses_storage_block_size():
|
def test_indexer_builder_deepseek_v4_compressed_slot_mapping_uses_storage_block_size():
|
||||||
"""Regression test: DeepseekV4 compression path must compute slot_mapping from
|
"""Regression test: DeepseekV4 compression path must compute slot_mapping from
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ class BuildPrefillChunkMetadataKernel(
|
|||||||
dcp_interleave = parallel_config.cp_kv_cache_interleave_size
|
dcp_interleave = parallel_config.cp_kv_cache_interleave_size
|
||||||
dcp_rank = get_dcp_group().rank_in_group if dcp_world > 1 else 0
|
dcp_rank = get_dcp_group().rank_in_group if dcp_world > 1 else 0
|
||||||
compress_ratios = tuple(
|
compress_ratios = tuple(
|
||||||
int(ratio)
|
max(1, int(ratio))
|
||||||
for ratio in (getattr(hf_config, "compress_ratios", None) or (1,))
|
for ratio in (getattr(hf_config, "compress_ratios", None) or (1,))
|
||||||
)
|
)
|
||||||
return self._trace_dispatch(self.dispatch)(
|
return self._trace_dispatch(self.dispatch)(
|
||||||
|
|||||||
Reference in New Issue
Block a user