Skip to content

Commit a173473

Browse files
luccafongcharlifu
authored andcommitted
[bugfix] fix structured outputs key missing issue from vllm-project#24929 (vllm-project#25195)
Signed-off-by: Lu Fang <fanglu@fb.com> Signed-off-by: charlifu <charlifu@amd.com>
1 parent 1da205f commit a173473

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

vllm/v1/core/sched/scheduler.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,10 @@ def schedule(self) -> SchedulerOutput:
578578
scheduled_spec_decode_tokens,
579579
req_to_new_blocks,
580580
)
581+
scheduled_requests = (scheduled_new_reqs + scheduled_running_reqs +
582+
scheduled_resumed_reqs)
581583
structured_output_request_ids, grammar_bitmask = (
582-
self.get_grammar_bitmask(self.running,
584+
self.get_grammar_bitmask(scheduled_requests,
583585
scheduled_spec_decode_tokens))
584586
scheduler_output = SchedulerOutput(
585587
scheduled_new_reqs=new_reqs_data,

vllm/v1/structured_output/utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,14 @@ def apply_grammar_bitmask(
9090
seq = sorted(scheduler_output.structured_output_request_ids.items(),
9191
key=lambda x: x[1])
9292
for req_id, _ in seq:
93-
logit_index = struct_out_req_batch_indices[req_id]
9493
num_spec_tokens = len(
9594
scheduler_output.scheduled_spec_decode_tokens.get(req_id, []))
96-
for i in range(1 + num_spec_tokens):
97-
sorted_bitmask[logit_index + i] = \
98-
grammar_bitmask[cumulative_index + i]
99-
out_indices.append(logit_index + i)
95+
if req_id in struct_out_req_batch_indices:
96+
logit_index = struct_out_req_batch_indices[req_id]
97+
for i in range(1 + num_spec_tokens):
98+
sorted_bitmask[logit_index + i] = \
99+
grammar_bitmask[cumulative_index + i]
100+
out_indices.append(logit_index + i)
100101
cumulative_index += 1 + num_spec_tokens
101102
grammar_bitmask = sorted_bitmask
102103

0 commit comments

Comments
 (0)