feat: renderer emits numpy, not torch — drop torch from renderer surface (#18)
Publish / publish (push) Canceled after 0s

This commit is contained in:
hallerite
2026-05-12 19:40:19 +02:00
committed by GitHub
parent 187f9d8588
commit 8d2a7d3d8e
4 changed files with 12 additions and 5 deletions
+9 -2
View File
@@ -263,8 +263,15 @@ def _build_qwen_vl_features(
image_items = mm_data.mm_items.get("image") or []
if image_items:
pixel_values = torch.cat([it["pixel_values"] for it in image_items], dim=0)
image_grid_thw = torch.cat([it["image_grid_thw"] for it in image_items], dim=0)
# mm_items now ship numpy arrays (the renderer is torch-free);
# convert at this vLLM-glue boundary where torch is already a
# hard dependency.
pixel_values = torch.cat(
[torch.as_tensor(it["pixel_values"]) for it in image_items], dim=0
)
image_grid_thw = torch.cat(
[torch.as_tensor(it["image_grid_thw"]) for it in image_items], dim=0
)
hf_inputs = BatchFeature(
data={"pixel_values": pixel_values, "image_grid_thw": image_grid_thw}
)
+1 -1
View File
@@ -621,7 +621,7 @@ class KimiK25Renderer:
img_proc = proc.image_processor
# Kimi's vision processor takes a media-dict shape, not raw PIL.
media_item = {"type": "image", "image": pil}
out = img_proc.preprocess([media_item], return_tensors="pt")
out = img_proc.preprocess([media_item], return_tensors="np")
# Patch count via the processor's own calculator (matches the
# model's per-patch attention count); kept for debugging.
num_patches = int(img_proc.media_tokens_calculator(media_item))
+1 -1
View File
@@ -182,7 +182,7 @@ class Qwen35Renderer:
out, num_image_tokens = cached
return pil, out, num_image_tokens, h
proc = self._get_processor()
out = proc.image_processor(images=[pil], return_tensors="pt")
out = proc.image_processor(images=[pil], return_tensors="np")
grid_thw = out["image_grid_thw"][0]
merge_size = proc.image_processor.merge_size
num_image_tokens = int(grid_thw.prod()) // (merge_size * merge_size)
+1 -1
View File
@@ -357,7 +357,7 @@ class Qwen3VLRenderer:
out, num_image_tokens = cached
return pil, out, num_image_tokens, h
proc = self._get_processor()
out = proc.image_processor(images=[pil], return_tensors="pt")
out = proc.image_processor(images=[pil], return_tensors="np")
grid_thw = out["image_grid_thw"][0]
merge_size = proc.image_processor.merge_size
num_image_tokens = int(grid_thw.prod()) // (merge_size * merge_size)