Skip to content

Commit

Permalink
Fix image_offset for multi_images
Browse files Browse the repository at this point in the history
  • Loading branch information
kcz358 committed Aug 16, 2024
1 parent 840f971 commit 08db01a
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions python/sglang/srt/model_executor/forward_batch_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,19 @@ def init_multimuldal_info(self, batch: ScheduleBatch):
reqs = batch.reqs
self.pixel_values = [r.pixel_values for r in reqs]
self.image_sizes = [r.image_size for r in reqs]
self.image_offsets = [
(
(r.image_offset - len(r.prefix_indices))
if r.image_offset is not None
else 0
)
for r in reqs
]
self.image_offsets = []
for r in reqs:
if isinstance(r.image_offset, list):
self.image_offsets.append(
[
(image_offset - len(r.prefix_indices))
for image_offset in r.image_offset
]
)
elif isinstance(r.image_offset, int):
self.image_offsets.append(r.image_offset - len(r.prefix_indices))
elif r.image_offset is None:
self.image_offsets.append(0)

def compute_positions(self, batch: ScheduleBatch):
position_ids_offsets = batch.position_ids_offsets
Expand Down

0 comments on commit 08db01a

Please sign in to comment.