diff --git a/python/sglang/srt/managers/mm_schedule.py b/python/sglang/srt/managers/mm_schedule.py index 96c1e378ce..73177104a7 100644 --- a/python/sglang/srt/managers/mm_schedule.py +++ b/python/sglang/srt/managers/mm_schedule.py @@ -450,12 +450,19 @@ def _collect_image_span_requests( for req_info in per_image_requests: chunk_start = req_info.extend_prefix_len chunk_end = chunk_start + req_info.extend_seq_len # exclusive + # PerImageRequestInfo.overlapping is the 4-tuple (idx, item, start, end) + # convention shared with _batch_encode_per_image_misses / + # _assemble_per_image_chunk; the span cache key is the item's full + # token count, matching cache_key = (item.hash, end - start + 1). req_info.overlapping = [ - (idx, item, token_count) - for idx, item in enumerate(req_info.items) - if (token_count := _item_overlap(item, chunk_start, chunk_end)) is not None + (idx, item, start, end) + for idx, (item, (start, end)) in enumerate( + zip(req_info.items, req_info.items_offset) + ) + if _item_overlap(item, chunk_start, chunk_end) is not None ] - for _idx, item, token_count in req_info.overlapping: + for _idx, item, start, end in req_info.overlapping: + token_count = end - start + 1 span = spans.get((item.hash, token_count)) if span is None: spans[(item.hash, token_count)] = ImageSpanRequest(