From d6ef68881e263812d4901f632786015005c4d050 Mon Sep 17 00:00:00 2001 From: iridiumine <42236072+iridiumine@users.noreply.github.com> Date: Tue, 21 Jul 2026 09:16:48 +0800 Subject: [PATCH] [NPU] Adapt MiMo-V2.5-W8A8 (#29131) --- .../quantization/modelslim/modelslim.py | 4 ++ .../sglang/test/ascend/test_ascend_utils.py | 1 + .../llm_models/test_npu_mimo_v2_5_w8a8.py | 49 +++++++++++++++++++ 3 files changed, 54 insertions(+) create mode 100644 test/manual/ascend/llm_models/test_npu_mimo_v2_5_w8a8.py diff --git a/python/sglang/srt/layers/quantization/modelslim/modelslim.py b/python/sglang/srt/layers/quantization/modelslim/modelslim.py index 9975e6ae7..e02cdb667 100644 --- a/python/sglang/srt/layers/quantization/modelslim/modelslim.py +++ b/python/sglang/srt/layers/quantization/modelslim/modelslim.py @@ -175,6 +175,10 @@ class ModelSlimConfig(QuantizationConfig): prefix_in_quant_config = prefix.replace( proj_name, packed_modules_mapping_subset[proj_name][0] ) + # Verify the remapped prefix exists in quant_description. + # If not (e.g. json uses fused name as-is), fall back to original. + if prefix_in_quant_config + ".weight" not in self.quant_description: + prefix_in_quant_config = prefix if self.is_layer_skipped( prefix, packed_modules_mapping_subset ) or self.is_layer_skipped(prefix, self.packed_modules_mapping): diff --git a/python/sglang/test/ascend/test_ascend_utils.py b/python/sglang/test/ascend/test_ascend_utils.py index 8a70c8776..3c63bbc50 100644 --- a/python/sglang/test/ascend/test_ascend_utils.py +++ b/python/sglang/test/ascend/test_ascend_utils.py @@ -149,6 +149,7 @@ META_LLAMA_3_1_8B_INSTRUCT = os.path.join( ) MIMO_7B_RL_WEIGHTS_PATH = os.path.join(MODEL_WEIGHTS_DIR, "XiaomiMiMo/MiMo-7B-RL") MIMO_V2_FLASH_WEIGHTS_PATH = os.path.join(MODEL_WEIGHTS_DIR, "XiaomiMiMo/MiMo-V2-Flash") +MIMO_V2_5_W8A8_WEIGHTS_PATH = os.path.join(MODEL_WEIGHTS_DIR, "solinliu/MiMo-V2.5-W8A8") MINICPM3_4B_WEIGHTS_PATH = os.path.join(MODEL_WEIGHTS_DIR, "OpenBMB/MiniCPM3-4B") MISTRAL_7B_INSTRUCT_V0_2_WEIGHTS_PATH = os.path.join( MODEL_WEIGHTS_DIR, "mistralai/Mistral-7B-Instruct-v0.2" diff --git a/test/manual/ascend/llm_models/test_npu_mimo_v2_5_w8a8.py b/test/manual/ascend/llm_models/test_npu_mimo_v2_5_w8a8.py new file mode 100644 index 000000000..e71088831 --- /dev/null +++ b/test/manual/ascend/llm_models/test_npu_mimo_v2_5_w8a8.py @@ -0,0 +1,49 @@ +import unittest + +from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin +from sglang.test.ascend.test_ascend_utils import MIMO_V2_5_W8A8_WEIGHTS_PATH +from sglang.test.test_utils import CustomTestCase + + +class TestMiMoV25W8A8GraphWithMTP(GSM8KAscendMixin, CustomTestCase): + """Testcase: Verify the inference accuracy of MiMo-V2.5-W8A8 on GSM8K with cuda graph and MTP (speculative decoding). + + [Test Category] Model + [Test Target] XiaomiMiMo/MiMo-V2.5-W8A8 + [Test Config] Prefill+Decode, cuda graph enabled, EAGLE speculative decoding, modelslim quantization + """ + + model = MIMO_V2_5_W8A8_WEIGHTS_PATH + accuracy = 0.9 + other_args = [ + "--trust-remote-code", + "--mem-fraction-static", + "0.75", + "--attention-backend", + "ascend", + "--tp-size", + "8", + "--reasoning-parser", + "mimo", + "--speculative-algorithm", + "EAGLE", + "--speculative-num-steps", + "3", + "--speculative-eagle-topk", + "1", + "--speculative-num-draft-tokens", + "4", + "--enable-multi-layer-eagle", + "--quantization", + "modelslim", + "--speculative-draft-model-quantization", + "unquant", + "--dp-size", + "2", + "--enable-dp-attention", + "--enable-dp-lm-head", + ] + + +if __name__ == "__main__": + unittest.main()