[SPEC] feat: init adaptive spec params from config (#27493)
Co-authored-by: Qiaolin Yu <liin1211@outlook.com>
This commit is contained in:
@@ -72,12 +72,6 @@ class TestAdaptiveSpeculativeServer(CustomTestCase):
|
||||
"EAGLE",
|
||||
"--speculative-draft-model-path",
|
||||
cls.draft_model,
|
||||
"--speculative-num-steps",
|
||||
"1",
|
||||
"--speculative-eagle-topk",
|
||||
"1",
|
||||
"--speculative-num-draft-tokens",
|
||||
"2",
|
||||
"--speculative-adaptive",
|
||||
"--speculative-adaptive-config",
|
||||
cls.adaptive_config_path,
|
||||
|
||||
@@ -528,6 +528,38 @@ class TestNgramExternalSamArgs(CustomTestCase):
|
||||
self.assertIn("external-corpus-max-tokens", str(context.exception))
|
||||
|
||||
|
||||
class TestAdaptiveSpecArgs(CustomTestCase):
|
||||
def test_adaptive_defaults_to_config_step_when_spec_params_omitted(self):
|
||||
with tempfile.NamedTemporaryFile("w", suffix=".json") as f:
|
||||
json.dump(
|
||||
{
|
||||
"1": {"candidate_steps": [1, 3, 5]},
|
||||
"8": {"candidate_steps": [1]},
|
||||
},
|
||||
f,
|
||||
)
|
||||
f.flush()
|
||||
|
||||
args = ServerArgs(model_path="dummy")
|
||||
args.speculative_algorithm = "EAGLE"
|
||||
args.speculative_adaptive = True
|
||||
args.speculative_adaptive_config = f.name
|
||||
args.device = "cuda"
|
||||
args.get_model_config = lambda: SimpleNamespace(
|
||||
hf_config=SimpleNamespace(
|
||||
architectures=["LlamaForCausalLM"],
|
||||
get_text_config=lambda: SimpleNamespace(),
|
||||
)
|
||||
)
|
||||
|
||||
handle_speculative_decoding(args)
|
||||
|
||||
self.assertTrue(args.speculative_adaptive)
|
||||
self.assertEqual(args.speculative_eagle_topk, 1)
|
||||
self.assertEqual(args.speculative_num_steps, 3)
|
||||
self.assertEqual(args.speculative_num_draft_tokens, 4)
|
||||
|
||||
|
||||
class TestDeepEPWaterfillArgs(CustomTestCase):
|
||||
def test_waterfill_enforces_shared_experts_fusion(self):
|
||||
server_args = ServerArgs(
|
||||
|
||||
@@ -6,7 +6,6 @@ from sglang.srt.speculative.adaptive_spec_params import (
|
||||
AdaptiveSpeculativeParams,
|
||||
AdaptiveStepSlot,
|
||||
resolve_candidate_steps_from_config,
|
||||
validate_adaptive_initial_steps,
|
||||
)
|
||||
from sglang.test.ci.ci_register import register_cpu_ci, register_xpu_ci
|
||||
|
||||
@@ -403,25 +402,5 @@ class TestResolveCandidateSteps(unittest.TestCase):
|
||||
self.assertEqual(steps, [1, 3, 5, 7])
|
||||
|
||||
|
||||
class TestValidateAdaptiveInitialSteps(unittest.TestCase):
|
||||
def test_accepts_value_from_any_slot(self):
|
||||
with tempfile.NamedTemporaryFile("w", suffix=".json") as f:
|
||||
json.dump(
|
||||
{
|
||||
"1": {"candidate_steps": [1, 5]},
|
||||
"8": {"candidate_steps": [1, 3, 7]},
|
||||
},
|
||||
f,
|
||||
)
|
||||
f.flush()
|
||||
# Membership in any slot is enough: 5 lives in the smallest slot,
|
||||
# 7 only in a larger slot -- both accepted.
|
||||
validate_adaptive_initial_steps(5, cfg_path=f.name)
|
||||
validate_adaptive_initial_steps(7, cfg_path=f.name)
|
||||
# 9 is in no slot -> rejected.
|
||||
with self.assertRaises(ValueError):
|
||||
validate_adaptive_initial_steps(9, cfg_path=f.name)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
||||
Reference in New Issue
Block a user