[ROCm][DSV4] Use aiter mHC pre/post as the default ROCm path (#43950)

Signed-off-by: Fangzhou Ai <fangzhou.ai@amd.com>
Signed-off-by: Fangzhou-Ai <fangzhouai@gmail.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Fangzhou Ai
2026-07-01 16:27:42 +08:00
committed by GitHub
co-authored by Cursor Claude
parent 77a9c5ae28
commit ed41aa270a
3 changed files with 32 additions and 39 deletions
+24 -32
View File
@@ -5,6 +5,7 @@ import torch
# this import will also register the custom ops
# import vllm.model_executor.kernels.mhc # noqa: F401
import vllm.model_executor.kernels.mhc as mhc_kernels
from vllm._aiter_ops import is_aiter_found_and_supported
from vllm.model_executor.custom_op import CustomOp
from vllm.platforms import current_platform
from vllm.utils.import_utils import has_tilelang
@@ -25,6 +26,7 @@ def _has_tilelang_mhc() -> bool:
HAS_TILELANG_MHC = _has_tilelang_mhc()
HAS_AITER_MHC = is_aiter_found_and_supported()
# --8<-- [start:mhc_pre]
@@ -87,25 +89,20 @@ class MHCPreOp(CustomOp):
norm_weight: torch.Tensor | None = None,
norm_eps: float = 0.0,
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
# TODO: Reenable aiter after we are at the aiter
# version that has this bugfix
# https://github.com/ROCm/aiter/commit/b639cb63bcac4672dce33a731fad042a65cb3649
# It has accuracy problem at large number of tokens.
# hidden_size = residual.shape[-1]
# if hidden_size % 256 == 0:
# return torch.ops.vllm.mhc_pre_aiter(
# residual,
# fn,
# hc_scale,
# hc_base,
# rms_eps,
# hc_pre_eps,
# hc_sinkhorn_eps,
# hc_post_mult_value,
# sinkhorn_repeat,
# )
# else:
if HAS_TILELANG_MHC:
hidden_size = residual.shape[-1]
if HAS_AITER_MHC and hidden_size % 256 == 0:
return torch.ops.vllm.mhc_pre_aiter(
residual,
fn,
hc_scale,
hc_base,
rms_eps,
hc_pre_eps,
hc_sinkhorn_eps,
hc_post_mult_value,
sinkhorn_repeat,
)
elif HAS_TILELANG_MHC:
return torch.ops.vllm.mhc_pre_tilelang(
residual,
fn,
@@ -227,19 +224,14 @@ class MHCPostOp(CustomOp):
post_layer_mix: torch.Tensor,
comb_res_mix: torch.Tensor,
) -> torch.Tensor:
# TODO: Reenable aiter after we are at the aiter
# version that has this bugfix
# https://github.com/ROCm/aiter/commit/b639cb63bcac4672dce33a731fad042a65cb3649
# It has accuracy problem at large number of tokens.
# hidden_size = residual.shape[-1]
# if hidden_size % 256 == 0:
# return torch.ops.vllm.mhc_post_aiter(
# x,
# residual,
# post_layer_mix,
# comb_res_mix,
# )
# else:
hidden_size = residual.shape[-1]
if HAS_AITER_MHC and hidden_size % 256 == 0:
return torch.ops.vllm.mhc_post_aiter(
x,
residual,
post_layer_mix,
comb_res_mix,
)
if HAS_TILELANG_MHC:
return torch.ops.vllm.mhc_post_tilelang(
x, residual, post_layer_mix, comb_res_mix