Unify spec v2's naming manner. (#15990)

This commit is contained in:
Liangsheng Yin
2025-12-28 14:14:52 +08:00
committed by GitHub
parent 26c5091217
commit bf90ea9c5b
8 changed files with 31 additions and 35 deletions

View File

@@ -244,6 +244,7 @@ class Envs:
# NPU
SGLANG_NPU_DISABLE_ACL_FORMAT_WEIGHT = EnvBool(False)
SGLANG_NPU_USE_MULTI_STREAM = EnvBool(False)
SGLANG_NPU_USE_MLAPO = EnvBool(False)
# Quantization
SGLANG_INT4_WEIGHT = EnvBool(False)

View File

@@ -1854,16 +1854,16 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
)
@property
def is_eagle_v2(self):
# FIXME: finally deprecate is_eagle_v2
def is_spec_v2(self):
# FIXME: finally deprecate is_spec_v2
return self.enable_overlap and self.spec_algorithm.is_eagle()
def prepare_for_decode(self):
self.forward_mode = ForwardMode.DECODE
bs = len(self.reqs)
if self.is_eagle_v2:
# TODO(spec-v2): all v2 spec should go through this path
if self.is_spec_v2:
# TODO(spec-v2): all spec v2 should go through this path
draft_input: EagleDraftInput = self.spec_info
draft_input.prepare_for_decode(self)
@@ -1942,7 +1942,7 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
)
def maybe_wait_verify_done(self):
if self.is_eagle_v2:
if self.is_spec_v2:
draft_input: EagleDraftInput = self.spec_info
if draft_input.verify_done is not None:
draft_input.verify_done.synchronize()
@@ -2018,7 +2018,7 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
# NOTE: spec_info filtered before batch filtering only happens in:
# - Spec v1's verify phase
# - Only for decode batch (running_batch)
has_been_filtered = v1_spec_info_filtered and not self.is_eagle_v2
has_been_filtered = v1_spec_info_filtered and not self.is_spec_v2
if self.spec_info:
self.spec_info.filter_batch(
@@ -2027,7 +2027,7 @@ class ScheduleBatch(ScheduleBatchDisaggregationDecodeMixin):
)
def merge_batch(self, other: "ScheduleBatch"):
# NOTE: in v2 eagle mode, we do not need wait verify here because
# NOTE: in spec v2 mode, we do not need wait verify here because
# 1) current batch is always prefill, whose seq_lens is not a future
# 2) other batch is always decode, which is finished in previous step

View File

@@ -1165,7 +1165,7 @@ class Scheduler(
# TODO(lsyin): support overlap + spec + grammar
need_grammar_sync = (
batch
and batch.is_eagle_v2
and batch.is_spec_v2
and batch.has_grammar
and batch.forward_mode.is_decode()
and len(self.result_queue) > 0
@@ -2225,8 +2225,8 @@ class Scheduler(
# FIXME(lsyin): move this assignment elsewhere
future_indices_or_next_token_ids = -future_indices.indices
if batch.is_eagle_v2:
# FIXME(lsyin): tmp code for eagle v2
if batch.is_spec_v2:
# FIXME(lsyin): tmp code for spec v2
# We only keep future indices for next draft input
batch.spec_info = batch_result.next_draft_input

View File

@@ -359,7 +359,7 @@ class SchedulerOutputProcessorMixin:
next_token_ids = next_token_ids.tolist()
if batch.return_logprob:
next_token_logprobs = logits_output.next_token_logprobs.tolist()
elif batch.is_eagle_v2:
elif batch.is_spec_v2:
next_token_ids = self._resolve_spec_overlap_token_ids(result, batch)
self.num_generated_tokens += len(batch.reqs)
@@ -386,8 +386,8 @@ class SchedulerOutputProcessorMixin:
new_accepted_len = 1
if batch.spec_algorithm.is_none():
req.output_ids.append(next_token_id)
elif batch.is_eagle_v2:
# Only v2 eagle's output_ids are updated here.
elif batch.is_spec_v2:
# Only spec v2's output_ids are updated here.
req.output_ids.extend(next_token_id)
new_accepted_len = len(next_token_id)
@@ -438,7 +438,7 @@ class SchedulerOutputProcessorMixin:
if batch.spec_algorithm.is_none():
# Normal decode: single token
req.grammar.accept_token(next_token_id)
elif batch.is_eagle_v2:
elif batch.is_spec_v2:
# Speculative decode: next_token_id is a list of accepted tokens
for token_id in next_token_id:
req.grammar.accept_token(token_id)

View File

@@ -141,7 +141,7 @@ class ForwardMode(IntEnum):
)
def is_draft_extend_v2(self):
# For fixed shape logits output in v2 eagle worker
# For fixed shape logits output in eagle v2 worker
return self == ForwardMode.DRAFT_EXTEND_V2
def is_extend_or_draft_extend_or_mixed(self, include_draft_extend_v2: bool = False):