feat: renderer emits numpy, not torch — drop torch from renderer surface (#18)
Publish / publish (push) Canceled after 0s
Publish / publish (push) Canceled after 0s
This commit is contained in:
+9
-2
@@ -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}
|
||||
)
|
||||
|
||||
@@ -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
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user