A high-throughput and memory-efficient inference and serving engine for LLMs
Mirrored from https://github.com/tduncan-lum/Nvidia-Optimization-Stack---VLLM.git
Synced Nov 11, 17:30 UTC
[Bugfix] Fix HunyuanOCR cross-image contamination in batch processing (#30344)
Signed-off-by: Lennart Brog <lennart.borg@list-ag.de> Signed-off-by: Anker <20343812+anker-c2@users.noreply.github.com>
Anker committed
Dec 10, 2025 at 19:09 UTC
e8e8cd73e5ddc4b56896e806066c37e9803e54b7
1 file changed
+9
-2
vllm/model_executor/models/hunyuan_vision.py
+9
-2
@@ -502,6 +502,7 @@ class HunYuanVisionTransformer(nn.Module):
502
cu_seqlens: list = [0]
503
504
hidden_states = x.to(device=self.device, dtype=self.dtype)
505
+ # embeddings = patch_embeds + patch_pos_embed
506
hidden_states = self.embeddings(hidden_states, grid_thw)
507
508
for t, h, w in grid_thw:
@@ -515,8 +516,14 @@ class HunYuanVisionTransformer(nn.Module):
516
517
hidden_states = hidden_states.reshape(seq_len, -1)
518
hidden_states = hidden_states.unsqueeze(0)
518
- for layer_num, layer in enumerate(self.layers):
519
- hidden_states = layer(hidden_states)
519
+
520
+ # build per-image lengths once
521
+ split_lengths = [int(h) * int(w) for (_, h, w) in grid_thw]
522
+ for layer in self.layers:
523
+ # hidden_states: (1, T_total, D)
524
+ parts = hidden_states.split(split_lengths, dim=1) # list of (1, L_i, D)
525
+ parts = [layer(p) for p in parts]
526
+ hidden_states = torch.cat(parts, dim=1)
527
528
# adapter
529
split_lengths = (cu_seqlens[1:] - cu_seqlens[:-1]).tolist()