[NPU] Add Gemma4 Sliding Window Attention support on Ascend backend (#26147)

This commit is contained in:
syy-hw
2026-06-12 11:44:38 +08:00
committed by GitHub
parent 8bfcc0c39c
commit 3a3a759464
14 changed files with 564 additions and 133 deletions
@@ -0,0 +1,30 @@
import unittest
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
from sglang.test.ascend.test_ascend_utils import GEMMA_4_26B_A4B_IT_WEIGHTS_PATH
from sglang.test.test_utils import CustomTestCase
class TestGemma426BA4BIt(GSM8KAscendMixin, CustomTestCase):
"""Testcase: Verify that the inference accuracy of the google/gemma-4-26B-A4B-it model on the GSM8K dataset is no less than 0.35.
[Test Category] Model
[Test Target] google/gemma-4-26B-A4B-it
"""
model = GEMMA_4_26B_A4B_IT_WEIGHTS_PATH
accuracy = 0.35
other_args = [
"--trust-remote-code",
"--mem-fraction-static",
"0.7",
"--attention-backend",
"ascend",
"--disable-cuda-graph",
"--tp-size",
"2",
]
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,30 @@
import unittest
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
from sglang.test.ascend.test_ascend_utils import GEMMA_4_31B_WEIGHTS_PATH
from sglang.test.test_utils import CustomTestCase
class TestGemma431B(GSM8KAscendMixin, CustomTestCase):
"""Testcase: Verify that the inference accuracy of the google/gemma-4-31B-it model on the GSM8K dataset is no less than 0.70.
[Test Category] Model
[Test Target] google/gemma-4-31B-it
"""
model = GEMMA_4_31B_WEIGHTS_PATH
accuracy = 0.70
other_args = [
"--trust-remote-code",
"--mem-fraction-static",
"0.7",
"--attention-backend",
"ascend",
"--disable-cuda-graph",
"--tp-size",
"2",
]
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,30 @@
import unittest
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
from sglang.test.ascend.test_ascend_utils import GEMMA_4_E2B_WEIGHTS_PATH
from sglang.test.test_utils import CustomTestCase
class TestGemma4E2B(GSM8KAscendMixin, CustomTestCase):
"""Testcase: Verify that the inference accuracy of the google/gemma-4-E2B-it model on the GSM8K dataset is no less than 0.05.
[Test Category] Model
[Test Target] google/gemma-4-E2B-it
"""
model = GEMMA_4_E2B_WEIGHTS_PATH
accuracy = 0.05
other_args = [
"--trust-remote-code",
"--mem-fraction-static",
"0.7",
"--attention-backend",
"ascend",
"--disable-cuda-graph",
"--tp-size",
"1",
]
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,30 @@
import unittest
from sglang.test.ascend.gsm8k_ascend_mixin import GSM8KAscendMixin
from sglang.test.ascend.test_ascend_utils import GEMMA_4_E4B_WEIGHTS_PATH
from sglang.test.test_utils import CustomTestCase
class TestGemma4E4B(GSM8KAscendMixin, CustomTestCase):
"""Testcase: Verify that the inference accuracy of the google/gemma-4-E4B-it model on the GSM8K dataset is no less than 0.60.
[Test Category] Model
[Test Target] google/gemma-4-E4B-it
"""
model = GEMMA_4_E4B_WEIGHTS_PATH
accuracy = 0.60
other_args = [
"--trust-remote-code",
"--mem-fraction-static",
"0.7",
"--attention-backend",
"ascend",
"--disable-cuda-graph",
"--tp-size",
"1",
]
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,22 @@
import unittest
from sglang.test.ascend.test_ascend_utils import GEMMA_4_26B_A4B_IT_WEIGHTS_PATH
from sglang.test.ascend.vlm_utils import TestVLMModels
class TestGemma426BA4BIt(TestVLMModels):
"""Testcase: Verify that the inference accuracy of the google/gemma-4-26B-A4B-it model on the MMMU dataset is no less than 0.40.
[Test Category] Model
[Test Target] google/gemma-4-26B-A4B-it
"""
model = GEMMA_4_26B_A4B_IT_WEIGHTS_PATH
mmmu_accuracy = 0.40
def test_vlm_mmmu_benchmark(self):
self._run_vlm_mmmu_test()
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,22 @@
import unittest
from sglang.test.ascend.test_ascend_utils import GEMMA_4_31B_WEIGHTS_PATH
from sglang.test.ascend.vlm_utils import TestVLMModels
class TestGemma431B(TestVLMModels):
"""Testcase: Verify that the inference accuracy of the google/gemma-4-31B-it model on the MMMU dataset is no less than 0.50.
[Test Category] Model
[Test Target] google/gemma-4-31B-it
"""
model = GEMMA_4_31B_WEIGHTS_PATH
mmmu_accuracy = 0.50
def test_vlm_mmmu_benchmark(self):
self._run_vlm_mmmu_test()
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,22 @@
import unittest
from sglang.test.ascend.test_ascend_utils import GEMMA_4_E2B_WEIGHTS_PATH
from sglang.test.ascend.vlm_utils import TestVLMModels
class TestGemma4E2B(TestVLMModels):
"""Testcase: Verify that the inference accuracy of the google/gemma-4-E2B-it model on the MMMU dataset is no less than 0.15.
[Test Category] Model
[Test Target] google/gemma-4-E2B-it
"""
model = GEMMA_4_E2B_WEIGHTS_PATH
mmmu_accuracy = 0.15
def test_vlm_mmmu_benchmark(self):
self._run_vlm_mmmu_test()
if __name__ == "__main__":
unittest.main()
@@ -0,0 +1,22 @@
import unittest
from sglang.test.ascend.test_ascend_utils import GEMMA_4_E4B_WEIGHTS_PATH
from sglang.test.ascend.vlm_utils import TestVLMModels
class TestGemma4E4B(TestVLMModels):
"""Testcase: Verify that the inference accuracy of the google/gemma-4-E4B-it model on the MMMU dataset is no less than 0.30.
[Test Category] Model
[Test Target] google/gemma-4-E4B-it
"""
model = GEMMA_4_E4B_WEIGHTS_PATH
mmmu_accuracy = 0.30
def test_vlm_mmmu_benchmark(self):
self._run_vlm_mmmu_test()
if __name__ == "__main__":
unittest.main()