[Bugfix][Core] Check multimodal chunk boundaries before encoder cache reuse (#59721)

Signed-off-by: ztysth <rnk.liulw@gmail.com>
Signed-off-by: ztysth <166926442+ztysth@users.noreply.github.com>
Co-authored-by: OpenAI Codex <noreply@openai.com>
This commit is contained in:
ztysth
2026-10-12 19:25:35 +00:00
committed by GitHub
co-authored by OpenAI Codex
parent 08582942d8
commit 1bdd3fa2d5
2 changed files with 57 additions and 17 deletions
+17 -16
View File
@@ -1863,6 +1863,23 @@ class Scheduler(SchedulerInterface):
# already calculated encoder inputs and can skip here.
continue
# If no encoder input chunking is allowed, we do not want to
# partially schedule a multimodal item. If the scheduled range would
# only cover part of the mm input, roll back to before the mm item.
if (
self.scheduler_config.disable_chunked_mm_input
and num_computed_tokens < start_pos
and (num_computed_tokens + num_new_tokens)
< (start_pos + num_encoder_tokens)
):
# Account for EAGLE shift when rolling back to avoid
# encoder cache miss. This ensures the scheduled range
# stops before start_pos even with the shift.
num_new_tokens = max(
0, start_pos - (num_computed_tokens + shift_computed_tokens)
)
break
if not self.is_encoder_decoder:
# We are not using the encoder cache for encoder-decoder models,
# yet.
@@ -1902,22 +1919,6 @@ class Scheduler(SchedulerInterface):
# previous step.
continue
# If no encoder input chunking is allowed, we do not want to
# partially schedule a multimodal item. If the scheduled range would
# only cover part of the mm input, roll back to before the mm item.
if (
self.scheduler_config.disable_chunked_mm_input
and num_computed_tokens < start_pos
and (num_computed_tokens + num_new_tokens)
< (start_pos + num_encoder_tokens)
):
# Account for EAGLE shift when rolling back to avoid
# encoder cache miss. This ensures the scheduled range
# stops before start_pos even with the shift.
num_new_tokens = max(
0, start_pos - (num_computed_tokens + shift_computed_tokens)
)
break
if not self.encoder_cache_manager.can_allocate(
request, i, encoder_compute_budget, num_embeds_to_schedule
):