From 64e2b54a8f45fbbf537a9e966d6c4045e5820e65 Mon Sep 17 00:00:00 2001 From: Mick Date: Mon, 25 May 2026 09:10:25 +0800 Subject: [PATCH] [VLM] feat: accept grid_thws from preprocessed metadata for kimi (#26149) --- python/sglang/srt/models/kimi_k25.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/models/kimi_k25.py b/python/sglang/srt/models/kimi_k25.py index 832ee74dd..c1d134e8e 100644 --- a/python/sglang/srt/models/kimi_k25.py +++ b/python/sglang/srt/models/kimi_k25.py @@ -680,9 +680,13 @@ class KimiK25ForConditionalGeneration(nn.Module): pixel_values = torch.cat([item.feature for item in items], dim=0).to( device=device, dtype=target_dtype ) - grid_thws = torch.concat([item.image_grid_thw for item in items], dim=0).to( - device - ) + image_grid_thws = [] + for item in items: + grid_thw = item.model_specific_data.get("image_grid_thw") + if grid_thw is None: + grid_thw = item.model_specific_data["grid_thws"] + image_grid_thws.append(grid_thw) + grid_thws = torch.concat(image_grid_thws, dim=0).to(device) if self.use_data_parallel: image_embeds = run_dp_sharded_mrope_vision_model(