Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions python/sglang/srt/managers/detokenizer_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,15 @@
class DecodeStatus:
"""Store the status of incremental decoding."""

decoded_text: str
decode_ids: List[int]
surr_offset: int
read_offset: int
# Offset that's sent to tokenizer for incremental update.
sent_offset: int = 0
decoded_text_len: int = dataclasses.field(init=False)
decoded_text: str = ""
decoded_text_len: int = dataclasses.field(default=0, init=False)
decoded_text_chunks: List[str] = dataclasses.field(default_factory=list)

def __post_init__(self):
self.decoded_text_len = len(self.decoded_text)

def append_decoded_text(self, text: str):
if text:
self.decoded_text_chunks.append(text)
Expand Down Expand Up @@ -317,7 +314,6 @@ def _decode_batch_token_id_output(self, recv_obj: BatchTokenIDOutput):
rid = recv_obj.rids[i]
if rid not in self.decode_status:
s = DecodeStatus(
decoded_text=recv_obj.decoded_texts[i],
decode_ids=self._clamp_decode_ids(
recv_obj.decode_ids[i], vocab_size
),
Expand Down
1 change: 0 additions & 1 deletion python/sglang/srt/managers/io_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,6 @@ class BatchTokenIDOutput(BaseBatchReq, kw_only=True):
# The finish reason
finished_reasons: List[Optional[FinishReasonDict]]
# For incremental decoding
decoded_texts: List[str]
decode_ids: List[array] # List[array[int]]
read_offsets: List[int]
# Only used when `--skip-tokenizer-init` is on
Expand Down
1 change: 0 additions & 1 deletion python/sglang/srt/managers/multi_tokenizer_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ def _handle_output_by_index(output, i):
),
time_stats=_extract_field_by_index(output, "time_stats", i),
finished_reasons=_extract_field_by_index(output, "finished_reasons", i),
decoded_texts=_extract_field_by_index(output, "decoded_texts", i),
decode_ids=_extract_field_by_index(output, "decode_ids", i),
read_offsets=_extract_field_by_index(output, "read_offsets", i),
output_ids=_extract_field_by_index(output, "output_ids", i),
Expand Down
11 changes: 4 additions & 7 deletions python/sglang/srt/managers/schedule_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,6 @@ def __init__(
# 3: last token
self.surr_offset = None # Surrounding offset to defeat the cleanup algorithm
self.read_offset = None
self.decoded_text = ""

# For multimodal inputs
self.multimodal_inputs: Optional[MultimodalInputs] = None
Expand Down Expand Up @@ -1930,13 +1929,11 @@ def _check_str_based_finish(self, new_accepted_len: int = 1):
# Check stop strings
if len(self.sampling_params.stop_strs) > 0:
for stop_str in self.sampling_params.stop_strs:
stop_str_in_tail = stop_str in tail_str
if stop_str_in_tail or stop_str in self.decoded_text:
if stop_str in tail_str:
self.finished_reason = FINISH_MATCHED_STR(matched=stop_str)
if stop_str_in_tail:
self.finished_len = self._locate_str_stop_finished_len(
new_accepted_len, stop_str=stop_str
)
self.finished_len = self._locate_str_stop_finished_len(
new_accepted_len, stop_str=stop_str
)
return True

# Check stop regex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,6 @@ class _GenerationStreamAccumulator:
output_reqs: list[Req] = field(default_factory=list)
http_worker_ipcs: list = field(default_factory=list)
finished_reasons: list = field(default_factory=list)
decoded_texts: list = field(default_factory=list)
decode_ids_list: list = field(default_factory=list)
read_offsets: list = field(default_factory=list)
output_ids: list = field(default_factory=list)
Expand Down Expand Up @@ -515,7 +514,6 @@ def accept(self, *, req: Req) -> None:
# block. The parallel lists stay empty; the payload goes straight to
# `push_generation`, which only indexes the fields appended above.
self.http_worker_ipcs.append(req.http_worker_ipc)
self.decoded_texts.append(req.decoded_text)
decode_ids, read_offset = req.init_incremental_detokenize()
self.decode_ids_list.append(decode_ids[req.send_decode_id_offset :])
req.send_decode_id_offset = len(decode_ids)
Expand Down Expand Up @@ -738,7 +736,6 @@ def to_payload(
spec_cap_lens_histogram=self.spec_cap_lens_histogram,
time_stats=self.time_stats or None,
finished_reasons=self.finished_reasons,
decoded_texts=self.decoded_texts,
decode_ids=self.decode_ids_list,
read_offsets=self.read_offsets,
output_ids=self.output_ids,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,6 @@ def _make_batch_token_id_output(**overrides) -> BatchTokenIDOutput:
fields = dict(
rids=["r0", "r1"],
finished_reasons=[None] * n,
decoded_texts=["", ""],
decode_ids=[array("q", [1]), array("q", [2])],
read_offsets=[0] * n,
output_ids=None,
Expand Down
3 changes: 1 addition & 2 deletions test/registered/unit/managers/test_multi_tokenizer_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ def _make_batch_token_id_output() -> BatchTokenIDOutput:
spec_num_cap_tokens=[],
spec_cap_lens_histogram=[],
finished_reasons=[None, None],
decoded_texts=["first", "second"],
decode_ids=[[1], [2]],
read_offsets=[0, 1],
output_ids=[[1], [2]],
Expand Down Expand Up @@ -376,7 +375,7 @@ def test_router_groups_token_output_without_speculative_decoding(self):
self.assertEqual(len(sent), 1)
self.assertEqual(sent[0][0], "detok-a")
self.assertEqual(sent[0][1].rids, ["token-rid-0", "token-rid-1"])
self.assertEqual(sent[0][1].decoded_texts, ["first", "second"])
self.assertEqual(sent[0][1].prompt_tokens, [10, 20])
self.assertIsNone(sent[0][1].spec_verify_ct)

def test_embedding_split_preserves_per_request_fields(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ def __init__(
self.send_token_offset = 0
self.send_output_token_logprobs_offset = 0
self.send_decode_id_offset = 0
self.decoded_text = ""
self.origin_input_ids = []
self.reasoning_tokens = 0
self.cached_tokens = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def __init__(self, *, is_retracted: bool, max_new_tokens: int):
self.send_token_offset = 0
self.send_output_token_logprobs_offset = 0
self.send_decode_id_offset = 0
self.decoded_text = ""
self.origin_input_ids = []
self.reasoning_tokens = 0
self.cached_tokens = 0
Expand Down
10 changes: 0 additions & 10 deletions test/registered/unit/managers/test_stop_str_speculative.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,16 +145,6 @@ def test_stop_regex_end_anchored_midchunk(self):
self.assertEqual(req.finished_reason.matched, r"[.!?]\s*$")
self.assertEqual(req.finished_len, 2)

# --- decoded_text-only branch ---
def test_stop_str_only_in_decoded_text_sets_no_finished_len(self):
# Documents current behavior: when the stop is only in decoded_text (not
# the tail), the request finishes but finished_len is left unset.
req = _make_req([10, 11, 12], stop=["STOP"]) # no STOP in output tokens
req.decoded_text = "earlier STOP text"
req.update_finish_state(new_accepted_len=3)
self.assertTrue(req.finished())
self.assertIsNone(req.finished_len)


if __name__ == "__main__":
unittest.main()
Loading