Skip to content

Commit 0e699ec

Browse files
committed
chore: move reasoning_ended to so_request
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
1 parent 30b0cd3 commit 0e699ec

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

vllm/reasoning/abs_reasoning_parsers.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# SPDX-License-Identifier: Apache-2.0
22

3+
from __future__ import annotations
4+
35
import os
46
from abc import abstractmethod
57
from collections.abc import Sequence
@@ -33,7 +35,7 @@ def vocab(self) -> dict[str, int]:
3335
return self.model_tokenizer.get_vocab()
3436

3537
@abstractmethod
36-
def is_reasoning_end(self, input_ids: list[int]) -> bool:
38+
def is_reasoning_end(self, input_ids: Sequence[int]) -> bool:
3739
"""
3840
Check if the reasoning content ends in the input_ids.
3941

vllm/v1/core/sched/scheduler.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -655,21 +655,19 @@ def update_from_output(
655655
if new_token_ids and request.use_structured_output:
656656
advance_fsm = False
657657
reasoner = self.structured_output_manager.reasoner
658-
is_reasoning_end_this_step = False # Flag the transition
658+
so_request = request.structured_output_request
659+
is_reasoning_end_this_step = False
659660

660-
if reasoner is None or request.reasoning_ended:
661-
# Reasoning was already off or never active
661+
if reasoner is None or so_request.reasoning_ended: # type: ignore[union-attr]
662662
advance_fsm = True
663-
else:
664-
# Reasoning is active, check if it ends now
663+
else: # type: ignore[union-attr]
665664
if reasoner.is_reasoning_end(request.all_token_ids):
666-
request.reasoning_ended = True
665+
so_request.reasoning_ended = True # type: ignore[union-attr]
667666
is_reasoning_end_this_step = True
668667
# Don't advance FSM in the step the transition occurs,
669668
# as new_token_ids might contain the end marker.
670669
advance_fsm = False
671670
else:
672-
# Reasoning continues, don't advance FSM
673671
advance_fsm = False
674672

675673
# Only advance FSM if reasoning was already off OR

vllm/v1/request.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ def __init__(
3737
self.eos_token_id = eos_token_id
3838
self.lora_request = lora_request
3939
self.structured_output_request = structured_output_request
40-
self.reasoning_ended: bool = False
4140

4241
self.status = (RequestStatus.WAITING_FOR_FSM
4342
if sampling_params.guided_decoding is not None else

vllm/v1/structured_output/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ def grammar_bitmask(
129129
assert so_request is not None and so_request.grammar is not None
130130

131131
apply_bitmask = (self.reasoner is None
132-
or full_request.reasoning_ended
132+
or so_request.reasoning_ended
133133
or self.reasoner.is_reasoning_end(
134134
full_request.all_token_ids))
135135

vllm/v1/structured_output/request.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class StructuredOutputRequest:
2020
sampling_params: SamplingParams
2121
_grammar: Optional[Union[Future[StructuredOutputGrammar],
2222
StructuredOutputGrammar]] = None
23+
reasoning_ended: bool = False
2324

2425
def _check_grammar_completion(self) -> bool:
2526
# NOTE: We have to lazy import to gate circular imports

0 commit comments

Comments
 (0)