[ROCm][Bugfix] Fix GPT-OSS Quark MXFP4 MoE loading - emulation buffer not block-aligned (#43979)

Signed-off-by: xuebwang-amd <xuebwang@amd.com>
This commit is contained in:
xuebwang-amd
2026-07-18 03:49:41 +00:00
committed by GitHub
parent da64db78b9
commit f12b80c6ef
3 changed files with 59 additions and 7 deletions
@@ -27,6 +27,9 @@ from vllm.model_executor.layers.fused_moe.config import (
ocp_mx_moe_quant_config,
)
from vllm.model_executor.layers.quantization.utils.mxfp4_utils import _swizzle_mxfp4
from vllm.model_executor.layers.quantization.utils.ocp_mx_utils import (
OCP_MX_BLOCK_SIZE,
)
from vllm.model_executor.layers.quantization.utils.quant_utils import (
QuantKey,
kFp8Dynamic128Sym,
@@ -633,7 +636,13 @@ def mxfp4_round_up_hidden_size_and_intermediate_size(
backend: Mxfp4MoeBackend, hidden_size: int, intermediate_size: int
) -> tuple[int, int]:
"""Round up hidden_size and intermediate_size based on backend requirements."""
if backend == Mxfp4MoeBackend.DEEPGEMM_MXFP4:
if backend == Mxfp4MoeBackend.EMULATION:
# Emulation has no kernel tile; it only needs OCP MX block alignment so the
# per-block scale buffers (`dim // OCP_MX_BLOCK_SIZE`) aren't floor-truncated
# by a non-block-aligned TP/DP shard (e.g. 2880 // 4 = 720).
intermediate_size = round_up(intermediate_size, OCP_MX_BLOCK_SIZE)
hidden_size = round_up(hidden_size, OCP_MX_BLOCK_SIZE)
elif backend == Mxfp4MoeBackend.DEEPGEMM_MXFP4:
# DeepGEMM requires M/N/K alignment
intermediate_size = round_up(intermediate_size, 128)
hidden_size = round_up(hidden_size, 128)
@@ -1063,12 +1063,9 @@ class QuarkOCP_MX_MoEMethod(QuarkMoEMethod):
act_dtype=act_dtype,
moe_parallel_config=moe_parallel_config,
)
# In case quantization emulation backend is used, there is no need to apply
# MXFP4-specific padding logic as the compute happens in higher precision.
if (
self.mxfp4_backend is not None
and self.mxfp4_backend != Mxfp4MoeBackend.EMULATION
):
# Round per-partition sizes up to each backend's requirement. Emulation is
# handled inside the helper too (OCP MX block alignment), so no special-case.
if self.mxfp4_backend is not None:
hidden_size, intermediate_size_per_partition = (
mxfp4_round_up_hidden_size_and_intermediate_size(
self.mxfp4_backend, hidden_size, intermediate_size_per_partition