[Spec] Clean up draft-window-size handling; extract spec arg setup to arg_groups (#25424)

This commit is contained in:
Liangsheng Yin
2026-05-16 03:23:48 -07:00
committed by GitHub
parent d1eb472a7a
commit aec4022e58
7 changed files with 574 additions and 502 deletions
@@ -3,6 +3,7 @@ import tempfile
import unittest
from unittest.mock import MagicMock, patch
from sglang.srt.arg_groups.speculative_hook import handle_speculative_decoding
from sglang.srt.server_args import PortArgs, ServerArgs, prepare_server_args
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import (
@@ -497,21 +498,23 @@ class TestNgramExternalSamArgs(CustomTestCase):
return args
def test_external_sam_budget_must_fit_draft_budget(self):
args = self._make_dummy_ngram_args(
speculative_num_draft_tokens=4,
speculative_ngram_external_corpus_path="/tmp/ngram-corpus.jsonl",
speculative_ngram_external_sam_budget=4,
)
with self.assertRaises(ValueError) as context:
self._make_dummy_ngram_args(
speculative_num_draft_tokens=4,
speculative_ngram_external_corpus_path="/tmp/ngram-corpus.jsonl",
speculative_ngram_external_sam_budget=4,
)._handle_speculative_decoding()
handle_speculative_decoding(args)
self.assertIn("speculative_num_draft_tokens - 1", str(context.exception))
def test_external_corpus_max_tokens_must_be_positive(self):
args = self._make_dummy_ngram_args(
speculative_ngram_external_corpus_path="/tmp/ngram-corpus.jsonl",
speculative_ngram_external_sam_budget=2,
speculative_ngram_external_corpus_max_tokens=0,
)
with self.assertRaises(ValueError) as context:
self._make_dummy_ngram_args(
speculative_ngram_external_corpus_path="/tmp/ngram-corpus.jsonl",
speculative_ngram_external_sam_budget=2,
speculative_ngram_external_corpus_max_tokens=0,
)._handle_speculative_decoding()
handle_speculative_decoding(args)
self.assertIn("external-corpus-max-tokens", str(context.exception))