fix(spec_v2): support EAGLE with spec_v2

1. add pass for spec_v2 in base_attn

2. fix: EAGLE with spec_v2 overlap Grammar accept_token failed

Signed-off-by: wxiwnd <wxiwnd@outlook.com>
This commit is contained in:
laoyao0822
2026-04-09 01:37:13 +08:00
committed by wxiwnd
parent 101100e25b
commit ef607c35c9
3 changed files with 124 additions and 14 deletions
@@ -0,0 +1,85 @@
"""Unit tests for overlap disaggregation decode event loop ordering."""
import unittest
from types import SimpleNamespace
from typing import Any, cast
from sglang.srt.disaggregation.decode import SchedulerDisaggregationDecodeMixin
from sglang.test.ci.ci_register import register_cpu_ci
from sglang.test.test_utils import CustomTestCase
register_cpu_ci(est_time=6, suite="stage-a-test-cpu")
class FakeBatch:
def __init__(self, label: str):
self.label = label
def copy(self):
return self
class TestOverlapDisaggDecodeEventLoop(CustomTestCase):
def test_processes_previous_result_before_disabled_overlap_launch(self):
class StopLoop(Exception):
pass
batch1 = FakeBatch("batch-1")
batch2 = FakeBatch("batch-2")
batches = iter([batch1, batch2])
events = []
def get_next_batch():
return next(batches)
def run_batch(batch):
result = f"result-{batch.label}"
events.append(f"run:{batch.label}")
return result
def process_batch_result(batch, result):
events.append(f"process:{batch.label}")
def launch_batch_sample_if_needed(result):
events.append(f"sample:{result}")
if result == "result-batch-2":
raise StopLoop()
scheduler = cast(
Any,
SimpleNamespace(
recv_requests=lambda: [],
process_input_requests=lambda reqs: None,
process_decode_queue=lambda: None,
get_next_disagg_decode_batch_to_run=get_next_batch,
run_batch=run_batch,
process_batch_result=process_batch_result,
is_disable_overlap_for_batch=lambda batch: batch is batch2,
launch_batch_sample_if_needed=launch_batch_sample_if_needed,
self_check_during_idle=lambda: None,
),
)
with self.assertRaises(StopLoop):
SchedulerDisaggregationDecodeMixin.event_loop_overlap_disagg_decode(
scheduler
)
self.assertEqual(
events,
[
"run:batch-1",
"sample:result-batch-1",
"process:batch-1",
"run:batch-2",
"sample:result-batch-2",
],
)
self.assertEqual(len(scheduler.result_queue), 1)
queued_batch, queued_result = scheduler.result_queue[0]
self.assertIs(queued_batch, batch2)
self.assertEqual(queued_result, "result-batch-2")
if __name__ == "__main__":
unittest.main()