[ROCm][MoE] Fix gfx950 block scale swizzle for AITER Triton MXFP4 W4A16 (#54773)

Signed-off-by: Stefan Koncarevic <Stefan.Koncarevic@amd.com>
This commit is contained in:
stefankoncarevic
2026-09-01 19:48:45 +00:00
committed by GitHub
parent 3439bad37e
commit 73723b707f
@@ -152,6 +152,9 @@ def aiter_triton_kernel_w4a16_moe_forward(
score_mode: str | None = None,
):
assert quant_config is not None and rocm_aiter_ops.is_enabled()
from vllm.model_executor.layers.quantization.utils.mxfp4_utils import (
should_use_cdna4_mx_scale_swizzle,
)
from vllm.platforms.rocm import on_gfx1250
try:
@@ -245,6 +248,11 @@ def aiter_triton_kernel_w4a16_moe_forward(
# SILU: silu(gate) * up — same kernel, just no "+1" residual in swiglu.
swiglu_add_residual = activation != MoEActivation.SILU
# Weight loading already swizzled the block scales on gfx950, so the kernel
# has to be told; the load-time swizzle and this gate must agree or the
# kernel indexes a swizzled buffer as if it were linear.
swz = "CDNA4_SCALE" if should_use_cdna4_mx_scale_swizzle() else None
intermediate = moe_gemm_a16w4(
hidden_states,
w1_data,
@@ -256,7 +264,7 @@ def aiter_triton_kernel_w4a16_moe_forward(
routing_data,
gather_indx=gather_idx,
gammas=gammas if apply_router_weight_on_input else None,
swizzle_mx_scale=None,
swizzle_mx_scale=swz,
apply_swiglu=True,
alpha=swiglu_alpha,
limit=swiglu_limit,
@@ -276,7 +284,7 @@ def aiter_triton_kernel_w4a16_moe_forward(
routing_data,
scatter_indx=scatter_idx,
gammas=None if apply_router_weight_on_input else gammas,
swizzle_mx_scale=None,
swizzle_mx_scale=swz,
unpadded_N=unpadded_N_w2,
unpadded_K=unpadded_K_w2,
)