[NPU] Add PR test cases (#32392)
Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: sglang-npu-bot <sglangnpu@163.com>
This commit is contained in:
co-authored by
Claude
sglang-npu-bot
parent
27b15349e5
commit
f8e62a9224
@@ -0,0 +1,49 @@
|
||||
"""NPU accuracy test mixin.
|
||||
|
||||
Wraps :class:`~sglang.test.kits.eval_accuracy_kit.GSM8KMixin` with:
|
||||
|
||||
* 1% accuracy tolerance (threshold * 0.99)
|
||||
* Automatic retry (up to 3 attempts)
|
||||
|
||||
Delegates to ``super().test_gsm8k()`` so community-side changes to eval
|
||||
setup, backend selection, or parameters are inherited automatically.
|
||||
|
||||
Usage::
|
||||
|
||||
from sglang.test.ascend.npu_eval_accuracy_kit import NPUGSM8KMixin
|
||||
|
||||
class TestFoo(CustomTestCase, NPUGSM8KMixin):
|
||||
gsm8k_accuracy_thres = 0.6
|
||||
"""
|
||||
|
||||
from sglang.test.kits.eval_accuracy_kit import GSM8KMixin
|
||||
|
||||
_NPU_ACCURACY_TOLERANCE = 0.99
|
||||
_NPU_MAX_ACCURACY_ATTEMPTS = 3
|
||||
|
||||
|
||||
class NPUGSM8KMixin(GSM8KMixin):
|
||||
"""NPU GSM8K accuracy mixin — 1% tolerance + up to 3 retries."""
|
||||
|
||||
def test_gsm8k(self):
|
||||
threshold = self.gsm8k_score_threshold
|
||||
if threshold != threshold: # NaN → legacy alias
|
||||
threshold = self.gsm8k_accuracy_thres
|
||||
relaxed = threshold * _NPU_ACCURACY_TOLERANCE
|
||||
|
||||
# Patch both so the parent picks up the relaxed threshold.
|
||||
self.gsm8k_score_threshold = relaxed
|
||||
self.gsm8k_accuracy_thres = relaxed
|
||||
|
||||
for attempt in range(_NPU_MAX_ACCURACY_ATTEMPTS):
|
||||
try:
|
||||
super().test_gsm8k()
|
||||
return
|
||||
except AssertionError:
|
||||
if attempt == _NPU_MAX_ACCURACY_ATTEMPTS - 1:
|
||||
raise
|
||||
print(
|
||||
f"[{type(self).__name__}] GSM8K attempt "
|
||||
f"{attempt + 1}/{_NPU_MAX_ACCURACY_ATTEMPTS} failed, "
|
||||
f"retrying..."
|
||||
)
|
||||
@@ -212,7 +212,7 @@ QWEN3_NEXT_80B_A3B_INSTRUCT_WEIGHTS_PATH = os.path.join(
|
||||
MODEL_WEIGHTS_DIR, "Qwen/Qwen3-Next-80B-A3B-Instruct"
|
||||
)
|
||||
QWEN3_32B_EAGLE3_WEIGHTS_PATH = os.path.join(
|
||||
MODEL_WEIGHTS_DIR, "Zjcxy-SmartAI/Qwen3-32B-Eagle3"
|
||||
MODEL_WEIGHTS_DIR, "Zjcxy-SmartAI/Eagle3-Qwen3-32B-zh"
|
||||
)
|
||||
QWEN3_32B_W8A8_MINDIE_WEIGHTS_PATH = os.path.join(
|
||||
MODEL_WEIGHTS_DIR, "aleoyang/Qwen3-32B-w8a8-MindIE"
|
||||
|
||||
Reference in New Issue
Block a user