Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion python/sglang/srt/multimodal/processors/base_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -1732,7 +1732,14 @@ def resolve_image_token_counts(self, images: List) -> List[int]:

"""
assert images is not None
image_sizes = [(image.height, image.width) for image in images]
image_sizes = [
(
tuple(image.shape[-2:])
if isinstance(image, torch.Tensor)
else (image.height, image.width)
)
for image in images
]
num_image_tokens = self._processor._get_num_multimodal_tokens(
image_sizes=image_sizes
).num_image_tokens
Expand Down
7 changes: 5 additions & 2 deletions test/registered/vlm/test_token_id_retokenize_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
original tokens verbatim and only expands the image placeholder, so prompt_tokens
stays faithful to what the client sent.

The test uses JPEG so CUDA decoding returns a CHW tensor, covering the same
exact-token path as PIL-backed images.

For each model we launch a real server twice with the same predefined,
non-canonical prompt ("Describe" split into "D"+"escribe") plus one image:

Expand Down Expand Up @@ -42,8 +45,8 @@
def _data_uri():
img = Image.new("RGB", (64, 64), (128, 128, 128))
buf = io.BytesIO()
img.save(buf, format="PNG")
return "data:image/png;base64," + base64.b64encode(buf.getvalue()).decode()
img.save(buf, format="JPEG")
return "data:image/jpeg;base64," + base64.b64encode(buf.getvalue()).decode()


def _build_drift_prompt(model, image_token):
Expand Down
Loading