Merge branch 'main' into patches
Signed-off-by: MOVZX <movzx@yahoo.com>
This commit is contained in:
@@ -15,6 +15,7 @@ from vllm.models.qwen4_exp.nvidia import (
|
||||
)
|
||||
from vllm.models.qwen4_exp.nvidia.ops import qsa as qsa_ops
|
||||
from vllm.models.qwen4_exp.nvidia.ops import qsa_indexer as qsa_indexer_ops
|
||||
from vllm.models.qwen4_exp.nvidia.qsa import qsa_kv_cache_dtype
|
||||
from vllm.platforms import current_platform
|
||||
from vllm.triton_utils import HAS_TRITON
|
||||
from vllm.v1.worker.utils import clear_layer_kv_caches
|
||||
@@ -314,7 +315,7 @@ def test_qsa_circular_buffer_metadata_keeps_only_each_requests_suffix() -> None:
|
||||
builder.k_work_metadata_buffer = torch.empty(0, 2, dtype=torch.int32, device=device)
|
||||
query_start_loc = torch.tensor([0, 7, 13, 13], dtype=torch.int32, device=device)
|
||||
token_to_req = torch.tensor([0] * 7 + [1] * 6 + [0] * 3, device=device)
|
||||
block_table = torch.tensor([[1], [0], [2]], dtype=torch.int32, device=device)
|
||||
block_table = torch.tensor([[1], [3], [2]], dtype=torch.int32, device=device)
|
||||
common = SimpleNamespace(
|
||||
num_actual_tokens=16,
|
||||
num_reqs=3,
|
||||
@@ -339,10 +340,10 @@ def test_qsa_circular_buffer_metadata_keeps_only_each_requests_suffix() -> None:
|
||||
4,
|
||||
-1,
|
||||
-1,
|
||||
3,
|
||||
0,
|
||||
1,
|
||||
2,
|
||||
15,
|
||||
12,
|
||||
13,
|
||||
14,
|
||||
-1,
|
||||
-1,
|
||||
-1,
|
||||
@@ -350,6 +351,10 @@ def test_qsa_circular_buffer_metadata_keeps_only_each_requests_suffix() -> None:
|
||||
|
||||
assert metadata.slot_mapping.tolist() == expected
|
||||
|
||||
# A dummy batch puts every request on the null block, which owns no ring.
|
||||
block_table.zero_()
|
||||
assert builder.build(0, common).slot_mapping.tolist() == [-1] * 16
|
||||
|
||||
|
||||
@pytest.mark.parametrize("chunk_start", list(range(8)))
|
||||
def test_qsa_circular_buffer_survives_one_speculative_step(chunk_start: int) -> None:
|
||||
@@ -366,7 +371,7 @@ def test_qsa_circular_buffer_survives_one_speculative_step(chunk_start: int) ->
|
||||
query_len = num_spec + 1
|
||||
|
||||
slots = qsa_cache.circular_qsa_slot_mapping(
|
||||
torch.tensor([[0]], dtype=torch.int32),
|
||||
torch.tensor([[1]], dtype=torch.int32),
|
||||
torch.zeros(query_len, dtype=torch.int32),
|
||||
torch.arange(chunk_start, chunk_start + query_len),
|
||||
capacity,
|
||||
@@ -374,7 +379,7 @@ def test_qsa_circular_buffer_survives_one_speculative_step(chunk_start: int) ->
|
||||
)
|
||||
|
||||
committed = torch.arange(chunk_start - chunk_start % compress_ratio, chunk_start)
|
||||
assert set(slots.tolist()).isdisjoint((committed % capacity).tolist())
|
||||
assert set((slots % capacity).tolist()).isdisjoint((committed % capacity).tolist())
|
||||
|
||||
|
||||
def _qsa_key_cache(
|
||||
@@ -448,6 +453,19 @@ def test_qsa_ring_capacity_covers_one_speculative_step(
|
||||
assert spec.block_size == expected
|
||||
|
||||
|
||||
def test_qsa_kv_cache_dtype_honors_skip_layers() -> None:
|
||||
"""``--kv-cache-dtype-skip-layers`` keeps the listed QSA layers unquantized.
|
||||
|
||||
The MTP layer's own attention is the one that matters on Flash-Next: FP8
|
||||
there cuts draft acceptance at depth while the target layers stay FP8.
|
||||
"""
|
||||
cache_config = SimpleNamespace(cache_dtype="fp8", kv_cache_dtype_skip_layers=["48"])
|
||||
assert qsa_kv_cache_dtype(cache_config, "mtp.layers.48.self_attn") == "auto"
|
||||
assert qsa_kv_cache_dtype(cache_config, "model.layers.47.self_attn") == "fp8"
|
||||
cache_config.kv_cache_dtype_skip_layers = []
|
||||
assert qsa_kv_cache_dtype(cache_config, "mtp.layers.48.self_attn") == "fp8"
|
||||
|
||||
|
||||
@requires_qsa_kernels
|
||||
def test_qsa_compressed_metadata_keeps_dummy_slots_inert() -> None:
|
||||
device = torch.device("cuda")
|
||||
|
||||
Reference in New Issue
Block a user