[ROCm][Perf] Enable fused KDA decode on gfx942 (MI325X) (#52293)
Signed-off-by: Matvei Pashkovskii <mpashkov@amd.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude
parent
ddbf826bee
commit
ad5e71b276
+6
-6
@@ -1180,14 +1180,14 @@ if(VLLM_GPU_LANG STREQUAL "CUDA" OR VLLM_GPU_LANG STREQUAL "HIP")
|
||||
endif()
|
||||
|
||||
# HIP counterpart of the FUSED_KDA_DECODE block above: same `fused_kda_decode`
|
||||
# op, same VLLM_ENABLE_FUSED_KDA_DECODE guard in torch_bindings.cpp. Only
|
||||
# measured on gfx950, so it is only built when gfx950 is in the arch list.
|
||||
# A multi-arch build that includes gfx950 still emits this source for every
|
||||
# arch in that list. The runtime gate in kda_decode.py keeps the kernel off
|
||||
# non-gfx950 devices.
|
||||
# op, same VLLM_ENABLE_FUSED_KDA_DECODE guard in torch_bindings.cpp. Built for
|
||||
# the CDNA archs the kernel supports (gfx942 / gfx950), so it is only emitted
|
||||
# when one of those is in the arch list. A multi-arch build that includes them
|
||||
# still emits this source for every arch in that list. The runtime gate in
|
||||
# kda_decode.py keeps the kernel off unsupported devices.
|
||||
if(VLLM_GPU_LANG STREQUAL "HIP")
|
||||
set(FUSED_KDA_DECODE_HIP_ARCHS ${VLLM_GPU_ARCHES})
|
||||
list(FILTER FUSED_KDA_DECODE_HIP_ARCHS INCLUDE REGEX "gfx950")
|
||||
list(FILTER FUSED_KDA_DECODE_HIP_ARCHS INCLUDE REGEX "gfx942|gfx950")
|
||||
if(FUSED_KDA_DECODE_HIP_ARCHS)
|
||||
set(FUSED_KDA_DECODE_HIP_SRC
|
||||
"csrc/libtorch_stable/kimi_k3/fused_kda_decode_kernel_rocm.cu")
|
||||
|
||||
@@ -14,17 +14,17 @@ import torch
|
||||
from vllm.platforms import current_platform
|
||||
|
||||
|
||||
def _on_gfx950() -> bool:
|
||||
def _on_supported_arch() -> bool:
|
||||
if not current_platform.is_rocm():
|
||||
return False
|
||||
from vllm.platforms.rocm import on_gfx950
|
||||
from vllm.platforms.rocm import on_gfx942, on_gfx950
|
||||
|
||||
return on_gfx950()
|
||||
return on_gfx950() or on_gfx942()
|
||||
|
||||
|
||||
pytestmark = pytest.mark.skipif(
|
||||
not _on_gfx950(),
|
||||
reason="The fused KDA decode kernel is only built for gfx950",
|
||||
not _on_supported_arch(),
|
||||
reason="The fused KDA decode kernel is only built for gfx942 / gfx950",
|
||||
)
|
||||
|
||||
# Kimi-K3 KDA: 96 heads x 128, conv width 4, gate_lower_bound -5.0.
|
||||
|
||||
@@ -35,7 +35,7 @@ def is_fused_kda_decode_supported(
|
||||
conv_state_dtype: torch.dtype,
|
||||
) -> bool:
|
||||
"""Whether the fused decode kernel can serve this layer on this device."""
|
||||
from vllm.platforms.rocm import on_gfx950
|
||||
from vllm.platforms.rocm import on_gfx942, on_gfx950
|
||||
|
||||
if (
|
||||
num_heads not in SUPPORTED_NUM_HEADS
|
||||
@@ -48,8 +48,9 @@ def is_fused_kda_decode_supported(
|
||||
or not hasattr(torch.ops._C, "fused_kda_decode")
|
||||
):
|
||||
return False
|
||||
# TODO: Verify on other archs; only measured on gfx950 for now
|
||||
return on_gfx950()
|
||||
# gfx950 (MI355X) and gfx942 (MI325X): both CDNA, sharing the wave64 / DPP /
|
||||
# bf16 primitives the kernel relies on.
|
||||
return on_gfx950() or on_gfx942()
|
||||
|
||||
|
||||
def make_decode_conv1d_weight_loader(
|
||||
|
||||
Reference in New Issue
Block a user