[Bugfix][NPU] Fix MiniMax-H3 INT8 quantization dispatch (#6876)
Signed-off-by: KrystalRay <keeleiray@gmail.com> Co-authored-by: KrystalRay <keeleiray@gmail.com>
This commit is contained in:
1 parent
9b6a308914
commit
7be014bce6
3 files changed
+28
-1
No files matched your search
@@ -19,6 +19,7 @@ steps:
|
|||||||
pytest -s -v
|
pytest -s -v
|
||||||
tests/diffusion/layers/test_activation.py
|
tests/diffusion/layers/test_activation.py
|
||||||
tests/diffusion/layers/test_fused_qk_norm_rope_npu.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'
|
-m 'core_model and npu and A3'
|
||||||
--run-level 'core_model'
|
--run-level 'core_model'
|
||||||
|
|
||||||
|
|||||||
@@ -49,3 +49,29 @@ def test_qwen3_vl_npu_swiglu_matches_two_projection_reference() -> None:
|
|||||||
atol=2e-2,
|
atol=2e-2,
|
||||||
rtol=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
|
||||||
@@ -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:
|
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."""
|
"""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))
|
return self.down_proj(npu_swiglu_from_packed(gate_up))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user