[Spec] Clean up draft-window-size handling; extract spec arg setup to arg_groups (#25424)
This commit is contained in:
@@ -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))
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user