Revert DSv4 eager workspace reuse (#52836)
Signed-off-by: Woosuk Kwon <woosuk@inferact.ai> Co-authored-by: OpenAI Codex <codex@openai.com>
This commit is contained in:
co-authored by
OpenAI Codex
parent
a9f4afb66f
commit
f1178f3a06
@@ -20,7 +20,6 @@ import torch
|
||||
|
||||
from vllm import _custom_ops as ops
|
||||
from vllm.models.deepseek_v4.common.ops import (
|
||||
compute_global_topk_indices_and_lens,
|
||||
dequantize_and_gather_k_cache,
|
||||
quantize_and_insert_k_cache,
|
||||
)
|
||||
@@ -113,23 +112,6 @@ def test_get_dspark_swa_index_width(
|
||||
assert get_dspark_swa_index_width(window_size, num_speculative_tokens) == expected
|
||||
|
||||
|
||||
def test_compute_global_topk_reuses_output_buffers():
|
||||
device = "cuda"
|
||||
topk_indices = torch.tensor(
|
||||
[[0, 3, -1], [1, 2, -1]], dtype=torch.int32, device=device
|
||||
)
|
||||
token_to_req = torch.tensor([0, 1], dtype=torch.int32, device=device)
|
||||
block_table = torch.tensor([[5, 7], [11, 13]], dtype=torch.int32, device=device)
|
||||
is_valid = torch.tensor([True, False], device=device)
|
||||
args = (topk_indices, token_to_req, block_table, 2, is_valid)
|
||||
expected = compute_global_topk_indices_and_lens(*args)
|
||||
outputs = tuple(torch.empty_like(tensor) for tensor in expected)
|
||||
actual = compute_global_topk_indices_and_lens(*args, output_buffers=outputs)
|
||||
for result, output, reference in zip(actual, outputs, expected):
|
||||
assert result.data_ptr() == output.data_ptr()
|
||||
torch.testing.assert_close(result, reference)
|
||||
|
||||
|
||||
def _ue8m0_reference(x: torch.Tensor, block_size: int, fp8_max: float):
|
||||
"""PyTorch reference for UE8M0 FP8 quantization (per-block, power-of-2 scale).
|
||||
|
||||
|
||||
@@ -257,18 +257,8 @@ def test_q_path_matches_reference(num_tokens: int, n_heads: int, padded_heads: i
|
||||
num_blocks, bs, HEAD_BYTES, dtype=torch.uint8, device=device
|
||||
).view(num_blocks, -1)
|
||||
slot_mapping = torch.full((num_tokens,), -1, dtype=torch.int64, device=device)
|
||||
q_out = torch.empty(num_tokens, padded_heads, HEAD_DIM, dtype=dtype, device=device)
|
||||
torch.ops._C.fused_deepseek_v4_qnorm_rope_kv_rope_quant_insert_out(
|
||||
q,
|
||||
kv,
|
||||
q_out,
|
||||
k_cache,
|
||||
slot_mapping,
|
||||
positions,
|
||||
cos_sin_cache,
|
||||
padded_heads,
|
||||
eps,
|
||||
bs,
|
||||
q_out = _call_fused(
|
||||
q, padded_heads, kv, k_cache, slot_mapping, positions, cos_sin_cache, eps, bs
|
||||
)
|
||||
|
||||
torch.testing.assert_close(q_out[:, :n_heads], q_ref, rtol=1e-2, atol=1e-2)
|
||||
|
||||
@@ -150,23 +150,6 @@ def test_fused_indexer_q_rope_quant_matches_unfused(
|
||||
q_quant_ref, weights_ref = _reference(
|
||||
positions, q, cos_sin_cache, weights, softmax_scale, head_scale, use_fp4
|
||||
)
|
||||
output_buffers: tuple[torch.Tensor, ...] | None = None
|
||||
OUTPUT_BUFFER_TEST_NUM_TOKENS = 7
|
||||
if num_tokens == OUTPUT_BUFFER_TEST_NUM_TOKENS and cache_dtype == torch.float32:
|
||||
if use_fp4:
|
||||
q_ref, q_scale_ref = q_quant_ref
|
||||
output_buffers = (
|
||||
torch.empty_like(q_ref),
|
||||
torch.empty_like(q_scale_ref)
|
||||
.view(torch.uint8)
|
||||
.reshape(num_tokens, N_HEAD, -1),
|
||||
torch.empty_like(weights_ref),
|
||||
)
|
||||
else:
|
||||
output_buffers = (
|
||||
torch.empty_like(q_quant_ref),
|
||||
torch.empty_like(weights_ref),
|
||||
)
|
||||
# use_cutedsl=False: force the triton path even when cutedsl is installed
|
||||
# by patching the dispatcher's has_cutedsl() binding to return False.
|
||||
cutedsl_patch = (
|
||||
@@ -186,17 +169,8 @@ def test_fused_indexer_q_rope_quant_matches_unfused(
|
||||
softmax_scale,
|
||||
head_scale,
|
||||
use_fp4,
|
||||
output_buffers=output_buffers,
|
||||
)
|
||||
|
||||
if output_buffers is not None:
|
||||
if use_fp4:
|
||||
assert q_quant_fused[0].data_ptr() == output_buffers[0].data_ptr()
|
||||
assert q_quant_fused[1].data_ptr() == output_buffers[1].data_ptr()
|
||||
else:
|
||||
assert q_quant_fused.data_ptr() == output_buffers[0].data_ptr()
|
||||
assert weights_fused.data_ptr() == output_buffers[-1].data_ptr()
|
||||
|
||||
if use_fp4:
|
||||
q_quant_ref, q_scale_ref = q_quant_ref
|
||||
q_quant_fused, q_scale_fused = q_quant_fused
|
||||
|
||||
Reference in New Issue
Block a user