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
@@ -438,7 +438,6 @@ def compute_global_topk_indices_and_lens(
|
||||
block_table: torch.Tensor,
|
||||
block_size: int,
|
||||
is_valid_token: torch.Tensor,
|
||||
output_buffers: tuple[torch.Tensor, torch.Tensor] | None = None,
|
||||
) -> tuple[torch.Tensor, torch.Tensor]:
|
||||
"""Map local topk indices to global KV cache slots and count valid entries.
|
||||
|
||||
@@ -448,15 +447,8 @@ def compute_global_topk_indices_and_lens(
|
||||
3. Masking padding tokens to length 0
|
||||
"""
|
||||
num_tokens = topk_indices.shape[0]
|
||||
if output_buffers is None:
|
||||
global_topk_indices = torch.empty_like(topk_indices)
|
||||
topk_lens = torch.empty(
|
||||
num_tokens, dtype=torch.int32, device=topk_indices.device
|
||||
)
|
||||
else:
|
||||
global_topk_indices, topk_lens = output_buffers
|
||||
assert global_topk_indices.shape == topk_indices.shape
|
||||
assert topk_lens.shape == (num_tokens,)
|
||||
global_topk_indices = torch.empty_like(topk_indices)
|
||||
topk_lens = torch.empty(num_tokens, dtype=torch.int32, device=topk_indices.device)
|
||||
_compute_global_topk_indices_and_lens_kernel[(num_tokens,)](
|
||||
global_topk_indices,
|
||||
global_topk_indices.stride(0),
|
||||
|
||||
@@ -295,7 +295,6 @@ def fused_indexer_q_rope_quant(
|
||||
index_weights_softmax_scale: float,
|
||||
index_weights_head_scale: float,
|
||||
use_fp4: bool = False,
|
||||
output_buffers: tuple[torch.Tensor, ...] | None = None,
|
||||
) -> tuple[
|
||||
torch.Tensor | tuple[torch.Tensor, torch.Tensor],
|
||||
torch.Tensor,
|
||||
@@ -333,13 +332,7 @@ def fused_indexer_q_rope_quant(
|
||||
num_index_q_heads = index_q.shape[1]
|
||||
index_q_head_dim = index_q.shape[2]
|
||||
|
||||
if output_buffers is None:
|
||||
index_weights_out = torch.empty_like(index_weights, dtype=torch.float32)
|
||||
else:
|
||||
expected_num_buffers = 3 if use_fp4 else 2
|
||||
assert len(output_buffers) == expected_num_buffers
|
||||
index_weights_out = output_buffers[-1]
|
||||
assert index_weights_out.shape == index_weights.shape
|
||||
index_weights_out = torch.empty_like(index_weights, dtype=torch.float32)
|
||||
|
||||
if use_fp4:
|
||||
assert index_q_head_dim % MXFP4_BLOCK_SIZE == 0, (
|
||||
@@ -347,23 +340,16 @@ def fused_indexer_q_rope_quant(
|
||||
f"size {MXFP4_BLOCK_SIZE}"
|
||||
)
|
||||
num_scale_blocks = index_q_head_dim // MXFP4_BLOCK_SIZE
|
||||
packed_shape = (num_tokens, num_index_q_heads, index_q_head_dim // 2)
|
||||
scale_shape = (num_tokens, num_index_q_heads, num_scale_blocks)
|
||||
if output_buffers is None:
|
||||
index_q_packed = torch.empty(
|
||||
packed_shape,
|
||||
dtype=torch.uint8,
|
||||
device=index_q.device,
|
||||
)
|
||||
index_q_scale = torch.empty(
|
||||
scale_shape,
|
||||
dtype=torch.uint8,
|
||||
device=index_q.device,
|
||||
)
|
||||
else:
|
||||
index_q_packed, index_q_scale, _ = output_buffers
|
||||
assert index_q_packed.shape == packed_shape
|
||||
assert index_q_scale.shape == scale_shape
|
||||
index_q_packed = torch.empty(
|
||||
(num_tokens, num_index_q_heads, index_q_head_dim // 2),
|
||||
dtype=torch.uint8,
|
||||
device=index_q.device,
|
||||
)
|
||||
index_q_scale = torch.empty(
|
||||
(num_tokens, num_index_q_heads, num_scale_blocks),
|
||||
dtype=torch.uint8,
|
||||
device=index_q.device,
|
||||
)
|
||||
if has_cutedsl():
|
||||
# lazily import, otherwise some tests fail due to CUDA driver init failure.
|
||||
from vllm.models.deepseek_v4.nvidia.ops.fused_indexer_q_cutedsl import (
|
||||
@@ -432,11 +418,7 @@ def fused_indexer_q_rope_quant(
|
||||
fp8_dtype = current_platform.fp8_dtype()
|
||||
use_fnuz = fp8_dtype == torch.float8_e4m3fnuz
|
||||
fp8_max = 224.0 if use_fnuz else 448.0
|
||||
if output_buffers is None:
|
||||
index_q_fp8 = torch.empty_like(index_q, dtype=fp8_dtype)
|
||||
else:
|
||||
index_q_fp8, _ = output_buffers
|
||||
assert index_q_fp8.shape == index_q.shape
|
||||
index_q_fp8 = torch.empty_like(index_q, dtype=fp8_dtype)
|
||||
if has_cutedsl():
|
||||
# lazily import, otherwise some tests fail due to CUDA driver init failure.
|
||||
from vllm.models.deepseek_v4.nvidia.ops.fused_indexer_q_cutedsl import (
|
||||
|
||||
Reference in New Issue
Block a user