[Spec] Refactor NaN/OOB checks to async maybe_detect_* with env-var control (#19899)

Co-authored-by: hnyls2002 <lsyincs@gmail.com>
This commit is contained in:
kpham-sgl
2026-03-05 13:51:05 -08:00
committed by GitHub
co-authored by hnyls2002
parent 1c1712d8e5
commit 346a4131cf
17 changed files with 171 additions and 68 deletions
@@ -50,7 +50,13 @@ class TestDeepseekV3FP4MTP(CustomTestCase):
"--model-loader-extra-config",
'{"enable_multithread_load": true,"num_threads": 64}',
]
with envs.SGLANG_ENABLE_SPEC_V2.override(True):
with envs.SGLANG_ENABLE_SPEC_V2.override(
True
), envs.SGLANG_SPEC_NAN_DETECTION.override(
True
), envs.SGLANG_SPEC_OOB_DETECTION.override(
True
):
cls.process = popen_launch_server(
cls.model,
cls.base_url,
@@ -59,7 +59,13 @@ class TestEagleConstrainedDecoding(
cls.grammar_backend,
]
launch_args.extend(cls.other_launch_args)
with envs.SGLANG_ENABLE_SPEC_V2.override(cls.spec_v2):
with envs.SGLANG_ENABLE_SPEC_V2.override(
cls.spec_v2
), envs.SGLANG_SPEC_NAN_DETECTION.override(
True
), envs.SGLANG_SPEC_OOB_DETECTION.override(
True
):
cls.process = popen_launch_server(
cls.model,
cls.base_url,
@@ -3,6 +3,7 @@ from types import SimpleNamespace
import requests
from sglang.srt.environ import envs
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.few_shot_gsm8k import run_eval as run_eval_few_shot_gsm8k
from sglang.test.send_one import BenchArgs, send_one_prompt
@@ -55,12 +56,15 @@ class TestEAGLE3EngineDPAttention(CustomTestCase):
"--cuda-graph-max-bs",
"64",
]
cls.process = popen_launch_server(
cls.model,
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
other_args=other_args,
)
with envs.SGLANG_SPEC_NAN_DETECTION.override(
True
), envs.SGLANG_SPEC_OOB_DETECTION.override(True):
cls.process = popen_launch_server(
cls.model,
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
other_args=other_args,
)
@classmethod
def tearDownClass(cls):
@@ -59,7 +59,13 @@ class TestEagleServerBase(CustomTestCase, MatchedStopMixin):
launch_args.extend(cls.other_launch_args)
with envs.SGLANG_ENABLE_SPEC_V2.override(
True
), envs.SGLANG_ENABLE_STRICT_MEM_CHECK_DURING_BUSY.override(1):
), envs.SGLANG_ENABLE_STRICT_MEM_CHECK_DURING_BUSY.override(
1
), envs.SGLANG_SPEC_NAN_DETECTION.override(
True
), envs.SGLANG_SPEC_OOB_DETECTION.override(
True
):
cls.process = popen_launch_server(
cls.model,
cls.base_url,
@@ -65,7 +65,13 @@ class TestEagleDPAttnServerSmall(CustomTestCase):
"--speculative-num-draft-tokens",
"4",
]
with envs.SGLANG_ENABLE_SPEC_V2.override(True):
with envs.SGLANG_ENABLE_SPEC_V2.override(
True
), envs.SGLANG_SPEC_NAN_DETECTION.override(
True
), envs.SGLANG_SPEC_OOB_DETECTION.override(
True
):
cls.process = popen_launch_server(
cls.model,
cls.base_url,
@@ -73,7 +73,13 @@ class TestEagleDPAttnServerLarge(CustomTestCase):
"--model-loader-extra-config",
'{"enable_multithread_load": true,"num_threads": 64}',
]
with envs.SGLANG_ENABLE_SPEC_V2.override(True):
with envs.SGLANG_ENABLE_SPEC_V2.override(
True
), envs.SGLANG_SPEC_NAN_DETECTION.override(
True
), envs.SGLANG_SPEC_OOB_DETECTION.override(
True
):
cls.process = popen_launch_server(
cls.model,
cls.base_url,
@@ -3,6 +3,7 @@ import unittest
import openai
from sglang.srt.environ import envs
from sglang.srt.utils import kill_process_tree
from sglang.test.ci.ci_register import register_cuda_ci
from sglang.test.test_utils import (
@@ -50,12 +51,15 @@ class ServerWithGrammar(CustomTestCase):
"--speculative-num-draft-tokens=8",
]
cls.process = popen_launch_server(
cls.model,
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
other_args=launch_args,
)
with envs.SGLANG_SPEC_NAN_DETECTION.override(
True
), envs.SGLANG_SPEC_OOB_DETECTION.override(True):
cls.process = popen_launch_server(
cls.model,
cls.base_url,
timeout=DEFAULT_TIMEOUT_FOR_SERVER_LAUNCH,
other_args=launch_args,
)
@classmethod
def tearDownClass(cls):