From f35411ee8149e815f76fd7d69b825c5b4df48a0b Mon Sep 17 00:00:00 2001 From: Liangsheng Yin Date: Thu, 23 Jul 2026 01:47:27 -0700 Subject: [PATCH] [Spec] Enable grammar overlap scheduling for STANDALONE speculative decoding (#32110) --- python/sglang/srt/speculative/spec_info.py | 3 ++- test/registered/spec/test_spec_standalone.py | 9 +++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/speculative/spec_info.py b/python/sglang/srt/speculative/spec_info.py index 558e88f61..e50b8c261 100644 --- a/python/sglang/srt/speculative/spec_info.py +++ b/python/sglang/srt/speculative/spec_info.py @@ -136,7 +136,8 @@ class SpeculativeAlgorithm(Enum): def supports_grammar_overlap(self) -> bool: # Whether the worker advances the grammar FSM inside verify() (via the # scheduler's grammar barrier), letting spec + grammar decode overlap. - return self.is_eagle() + # STANDALONE inherits the EAGLE V2 worker's verify path, barrier included. + return self.is_eagle() or self.is_standalone() def has_draft_kv(self) -> bool: """Whether the draft phase writes KV chains. NGRAM does not (its tree diff --git a/test/registered/spec/test_spec_standalone.py b/test/registered/spec/test_spec_standalone.py index f86f6f2c5..1d9f04609 100644 --- a/test/registered/spec/test_spec_standalone.py +++ b/test/registered/spec/test_spec_standalone.py @@ -1,19 +1,24 @@ import unittest from sglang.test.ci.ci_register import register_cuda_ci +from sglang.test.kits.json_constrained_kit import JSONConstrainedMixin +from sglang.test.kits.regex_constrained_kit import RegexConstrainedMixin from sglang.test.server_fixtures.standalone_fixture import StandaloneServerBase from sglang.test.test_utils import CustomTestCase # V2 standalone speculative decoding tests (FA3, Triton, FlashInfer backends). # Non-V2 backends moved to test_spec_standalone_extra.py. -register_cuda_ci(est_time=406, stage="base-b", runner_config="1-gpu-large") +register_cuda_ci(est_time=450, stage="base-b", runner_config="1-gpu-large") class TestStandaloneV2SpeculativeDecodingBase(StandaloneServerBase, CustomTestCase): attention_backend = "fa3" -class TestStandaloneV2SpeculativeDecodingTriton(StandaloneServerBase, CustomTestCase): +class TestStandaloneV2SpeculativeDecodingTriton( + StandaloneServerBase, CustomTestCase, RegexConstrainedMixin, JSONConstrainedMixin +): + # Constrained mixins reuse this server; overlap on -> grammar barrier path. attention_backend = "triton"