fix(mm_schedule): port _item_overlap from upstream for vision-CP span collect

fd86688428 (vision CP single-owner encoding) cherry-pick used
_item_overlap in _collect_image_span_requests without the definition;
first multimodal prefill request killed every scheduler with NameError.
This commit is contained in:
2026-10-19 21:21:33 +08:00
parent f9056f0fcd
commit 068acff09d
+12
View File
@@ -431,6 +431,18 @@ def _batch_encode_per_image_misses(
return hash_to_embedding
def _item_overlap(
item: MultimodalDataItem, chunk_start: int, chunk_end: int
) -> Optional[int]:
"""Token count of an item with several runs, or None if none intersects the chunk."""
if len(item.offsets) == 1:
start, end = item.offsets[0]
return end - start + 1 if end >= chunk_start and start < chunk_end else None
if any(end >= chunk_start and start < chunk_end for start, end in item.offsets):
return sum(end - start + 1 for start, end in item.offsets)
return None
def _collect_image_span_requests(
per_image_requests: List[PerImageRequestInfo],
) -> List[ImageSpanRequest]: