-
Notifications
You must be signed in to change notification settings - Fork 6.6k
[SPEC] feat: init adaptive spec params from config #27493
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
79a6e36
2eb7abd
523a7b0
044fa79
cc55051
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ | |
| import os | ||
| import tempfile | ||
| import unittest | ||
| from types import SimpleNamespace | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
| import sglang.srt.server_args as server_args_module | ||
|
|
@@ -522,6 +523,38 @@ def test_external_corpus_max_tokens_must_be_positive(self): | |
| 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( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This new test uses Useful? React with 👍 / 👎. |
||
| 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( | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test uses
SimpleNamespaceto mock the model configuration, butSimpleNamespaceis not imported in this file. This will cause aNameErrorwhen the test is executed. Please importSimpleNamespacefromtypes.