From 7be014bce6374f06c95b703763bdbac4c6198f31 Mon Sep 17 00:00:00 2001 From: Lei Ke <1141466880@qq.com> Date: Mon, 7 Sep 2026 22:50:44 +0800 Subject: [PATCH] [Bugfix][NPU] Fix MiniMax-H3 INT8 quantization dispatch (#6876) Signed-off-by: KrystalRay Co-authored-by: KrystalRay --- .buildkite/npu/test-npu-ready.yml | 1 + .../test_minimax_h3_qwen3vl_swiglu.py | 26 +++++++++++++++++++ vllm_omni/platforms/npu/models/minimax_h3.py | 2 +- 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/.buildkite/npu/test-npu-ready.yml b/.buildkite/npu/test-npu-ready.yml index 9aa55e5d0..1f25ebac1 100644 --- a/.buildkite/npu/test-npu-ready.yml +++ b/.buildkite/npu/test-npu-ready.yml @@ -19,6 +19,7 @@ steps: pytest -s -v tests/diffusion/layers/test_activation.py tests/diffusion/layers/test_fused_qk_norm_rope_npu.py + tests/diffusion/models/minimax_h3/test_minimax_h3_qwen3vl_swiglu.py -m 'core_model and npu and A3' --run-level 'core_model' diff --git a/tests/diffusion/models/minimax_h3/test_minimax_h3_qwen3vl_swiglu.py b/tests/diffusion/models/minimax_h3/test_minimax_h3_qwen3vl_swiglu.py index 3ed7649c6..699dd47d6 100644 --- a/tests/diffusion/models/minimax_h3/test_minimax_h3_qwen3vl_swiglu.py +++ b/tests/diffusion/models/minimax_h3/test_minimax_h3_qwen3vl_swiglu.py @@ -49,3 +49,29 @@ def test_qwen3_vl_npu_swiglu_matches_two_projection_reference() -> None: atol=2e-2, rtol=2e-2, ) + + +@pytest.mark.skipif(not current_omni_platform.is_npu(), reason="requires Ascend NPU") +def test_qwen3_vl_npu_swiglu_forward_uses_projection_module(mocker) -> None: + from vllm_omni.platforms.npu.models import minimax_h3 + from vllm_omni.platforms.npu.models.minimax_h3 import ( + _forward_minimax_h3_qwen3vl_text_mlp_npu, + ) + + x = torch.randn(1, 16, 128, device="npu", dtype=torch.bfloat16) + packed = torch.randn(1, 16, 256, device="npu", dtype=torch.bfloat16) + activated = torch.randn(1, 16, 128, device="npu", dtype=torch.bfloat16) + gate_up_proj = mocker.Mock(return_value=packed) + down_proj = mocker.Mock(side_effect=lambda value: value) + mlp = mocker.Mock(gate_up_proj=gate_up_proj, down_proj=down_proj) + swiglu = mocker.patch.object(minimax_h3, "npu_swiglu_from_packed", return_value=activated) + + output = _forward_minimax_h3_qwen3vl_text_mlp_npu(mlp, x) + + gate_up_proj.assert_called_once() + assert gate_up_proj.call_args.args[0] is x + swiglu.assert_called_once() + assert swiglu.call_args.args[0] is packed + down_proj.assert_called_once() + assert down_proj.call_args.args[0] is activated + assert output is activated diff --git a/vllm_omni/platforms/npu/models/minimax_h3.py b/vllm_omni/platforms/npu/models/minimax_h3.py index c8889f18f..a89768096 100644 --- a/vllm_omni/platforms/npu/models/minimax_h3.py +++ b/vllm_omni/platforms/npu/models/minimax_h3.py @@ -100,7 +100,7 @@ def npu_swiglu_from_packed(gate_up: torch.Tensor) -> torch.Tensor: def _forward_minimax_h3_qwen3vl_text_mlp_npu(self: Any, x: torch.Tensor) -> torch.Tensor: """Run the Qwen3-VL MLP with one packed GEMM and fused SwiGLU.""" - gate_up = F.linear(x, self.gate_up_proj.weight) + gate_up = self.gate_up_proj(x) return self.down_proj(npu_swiglu_from_packed(gate_up))