[Core] Refactor server argument choices (#36586)

This commit is contained in:
Lianmin Zheng
2026-08-27 01:56:03 -07:00
committed by GitHub
parent a126a5fa31
commit 3402265989
5 changed files with 192 additions and 218 deletions
+17 -16
View File
@@ -21,29 +21,30 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../python"))
class TestDSAChoicesAndFields(unittest.TestCase):
"""Verify DSA_CHOICES constant and ServerArgs field renaming."""
"""Verify DSA CLI choices and ServerArgs field renaming."""
def setUp(self):
from sglang.srt.server_args import (
DSA_CHOICES,
NSA_CHOICES,
ServerArgs,
)
from sglang.srt.server_args import ServerArgs
self.ServerArgs = ServerArgs
self.DSA_CHOICES = DSA_CHOICES
self.NSA_CHOICES = NSA_CHOICES
parser = argparse.ArgumentParser()
ServerArgs.add_cli_args(parser)
self.actions = {
option: action
for action in parser._actions
for option in action.option_strings
}
def test_dsa_choices_is_canonical(self):
self.assertIn("fa3", self.DSA_CHOICES)
self.assertIn("tilelang", self.DSA_CHOICES)
self.assertIn("flashinfer_sparse_mla", self.DSA_CHOICES)
choices = self.actions["--dsa-prefill-backend"].choices
self.assertIn("fa3", choices)
self.assertIn("tilelang", choices)
self.assertIn("flashinfer_sparse_mla", choices)
def test_nsa_choices_is_alias(self):
self.assertIs(
self.NSA_CHOICES,
self.DSA_CHOICES,
"NSA_CHOICES must be the same object as DSA_CHOICES",
def test_nsa_choices_match_dsa_choices(self):
self.assertEqual(
self.actions["--nsa-prefill-backend"].choices,
self.actions["--dsa-prefill-backend"].choices,
)
def test_serverargs_has_dsa_fields(self):