Skip to content

Commit c0fa317

Browse files
committed
chore: add a check to make sure that the reasoning token is not being advanced
Signed-off-by: Aaron Pham <contact@aarnphm.xyz>
1 parent f60e62d commit c0fa317

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

vllm/v1/core/sched/scheduler.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,13 +655,26 @@ 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
659+
658660
if reasoner is None or request.reasoning_ended:
661+
# Reasoning was already off or never active
659662
advance_fsm = True
660-
elif reasoner.is_reasoning_end(request.all_token_ids):
661-
request.reasoning_ended = True
662-
advance_fsm = True
663+
else:
664+
# Reasoning is active, check if it ends now
665+
if reasoner.is_reasoning_end(request.all_token_ids):
666+
request.reasoning_ended = True
667+
is_reasoning_end_this_step = True
668+
# Don't advance FSM in the step the transition occurs,
669+
# as new_token_ids might contain the end marker.
670+
advance_fsm = False
671+
else:
672+
# Reasoning continues, don't advance FSM
673+
advance_fsm = False
663674

664-
if advance_fsm:
675+
# Only advance FSM if reasoning was already off OR
676+
# if we are not in the specific step where reasoning just ended.
677+
if advance_fsm and not is_reasoning_end_this_step:
665678
# NOTE: structured_output_request
666679
# should not be None if use_structured_output, we have
667680
# check above, so safe to ignore type warning

0 commit comments

Comments
 (0)