[3/N] HiSparse: host-resident sparse-MLA decode hot-buffering (#53781)
Signed-off-by: Matthew Bonanni <mbonanni@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkins@redhat.com> Signed-off-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> Signed-off-by: Matthew Bonanni <matthew@neuralmagic.com> Signed-off-by: Nicolò Lucchesi <nicolo.lucchesi@mistral.ai> Co-authored-by: OpenAI Codex <codex@openai.com> Co-authored-by: Lucas Wilkinson <lwilkins@redhat.com> Co-authored-by: Lucas Wilkinson <lwilkinson@neuralmagic.com> Co-authored-by: Nicolò Lucchesi <nicolo.lucchesi@mistral.ai> Co-authored-by: OpenAI Codex <noreply@openai.com> Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: Lucas Wilkinson <LucasWilkinson@users.noreply.github.com>
This commit is contained in:
co-authored by
OpenAI Codex
Lucas Wilkinson
Lucas Wilkinson
Nicolò Lucchesi
OpenAI Codex
Claude Opus 5
Lucas Wilkinson
parent
120ec4ebd2
commit
d43bb2f37f
@@ -1,16 +1,19 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
|
||||
"""Tests for per-KV-group attention backend selection (backend_per_kind)."""
|
||||
"""Tests for attention configuration and per-KV-group backend selection."""
|
||||
|
||||
from types import SimpleNamespace
|
||||
|
||||
import pytest
|
||||
|
||||
from vllm.config.attention import AttentionConfig
|
||||
from vllm.config.attention import AttentionConfig, HiSparseConfig
|
||||
from vllm.model_executor.layers.attention.attention import (
|
||||
_largest_kernel_block_within,
|
||||
)
|
||||
from vllm.v1.attention.backend import AttentionType, MultipleOf
|
||||
from vllm.v1.attention.backends.registry import AttentionBackendEnum
|
||||
from vllm.v1.attention.selector import get_attn_spec_kind
|
||||
from vllm.v1.hisparse.runtime import ResolvedHiSparseConfig
|
||||
from vllm.v1.kv_cache_interface import KVCacheSpecKind
|
||||
|
||||
|
||||
@@ -86,3 +89,52 @@ def test_backend_per_kind_rejects_unknown_kind():
|
||||
|
||||
def test_backend_per_kind_defaults_empty():
|
||||
assert AttentionConfig().backend_per_kind == {}
|
||||
|
||||
|
||||
def test_hisparse_device_buffer_size_boundaries():
|
||||
vllm_config = SimpleNamespace(
|
||||
attention_config=AttentionConfig(hisparse_config=HiSparseConfig()),
|
||||
speculative_config=None,
|
||||
)
|
||||
resolved = ResolvedHiSparseConfig.from_vllm_config(vllm_config, model_top_k=128)
|
||||
assert resolved is not None
|
||||
assert resolved.device_buffer_size == 256
|
||||
|
||||
vllm_config.attention_config.hisparse_config = HiSparseConfig(
|
||||
device_buffer_size=127
|
||||
)
|
||||
with pytest.raises(ValueError, match="expected at least 128"):
|
||||
ResolvedHiSparseConfig.from_vllm_config(vllm_config, model_top_k=128)
|
||||
|
||||
vllm_config.attention_config.hisparse_config = HiSparseConfig(
|
||||
device_buffer_size=32768
|
||||
)
|
||||
resolved = ResolvedHiSparseConfig.from_vllm_config(vllm_config, model_top_k=128)
|
||||
assert resolved is not None
|
||||
assert resolved.device_buffer_size == 32768
|
||||
|
||||
vllm_config.attention_config.hisparse_config = HiSparseConfig(
|
||||
device_buffer_size=32769
|
||||
)
|
||||
with pytest.raises(ValueError, match="int16 slot-index limit"):
|
||||
ResolvedHiSparseConfig.from_vllm_config(vllm_config, model_top_k=128)
|
||||
|
||||
|
||||
def test_hisparse_device_buffer_covers_speculative_window():
|
||||
vllm_config = SimpleNamespace(
|
||||
attention_config=AttentionConfig(hisparse_config=HiSparseConfig()),
|
||||
speculative_config=SimpleNamespace(
|
||||
num_speculative_tokens=3,
|
||||
parallel_drafting=False,
|
||||
),
|
||||
)
|
||||
|
||||
resolved = ResolvedHiSparseConfig.from_vllm_config(vllm_config, model_top_k=128)
|
||||
assert resolved is not None
|
||||
assert resolved.device_buffer_size == 5 * 128
|
||||
|
||||
vllm_config.attention_config.hisparse_config = HiSparseConfig(
|
||||
device_buffer_size=4 * 128 - 1
|
||||
)
|
||||
with pytest.raises(ValueError, match="expected at least 512"):
|
||||
ResolvedHiSparseConfig.from_vllm_config(vllm_config, model_top_k=128)
|
||||
|
||||
Reference in New Issue
Block a user