@tduncan / Nvidia-Optimization-Stack-VLLM Mirror · read-only / commits / 490f17d0c7
Fork 0

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 5, 09:45 UTC

[Multimodal] Fix nested_tensors_equal: add length check for lists and tuple support (#38388)

Signed-off-by: khairulkabir1661 <khairulkabir1661@users.noreply.github.com> Co-authored-by: khairulkabir1661 <khairulkabir1661@users.noreply.github.com>

Khairul Kabir committed Apr 8, 2026 at 21:40 UTC 490f17d0c7e21c3a4cd4c8e13b0e40840fc754c1
1 file changed +21 -4
vllm/multimodal/inputs.py
+21 -4
@@ -238,12 +238,29 @@ def nested_tensors_equal(a: NestedTensors, b: NestedTensors) -> bool:
238 return isinstance(a, torch.Tensor) and torch.equal(b, a)
239
240 if isinstance(a, list):
241 - return isinstance(b, list) and all(
242 - nested_tensors_equal(a_, b_) for a_, b_ in zip(a, b)
241 + return (
242 + isinstance(b, list)
243 + and len(a) == len(b)
244 + and all(nested_tensors_equal(a_, b_) for a_, b_ in zip(a, b))
245 )
246 if isinstance(b, list):
245 - return isinstance(a, list) and all(
246 - nested_tensors_equal(b_, a_) for b_, a_ in zip(b, a)
247 + return (
248 + isinstance(a, list)
249 + and len(b) == len(a)
250 + and all(nested_tensors_equal(b_, a_) for b_, a_ in zip(b, a))
251 + )
252 +
253 + if isinstance(a, tuple):
254 + return (
255 + isinstance(b, tuple)
256 + and len(a) == len(b)
257 + and all(nested_tensors_equal(a_, b_) for a_, b_ in zip(a, b))
258 + )
259 + if isinstance(b, tuple):
260 + return (
261 + isinstance(a, tuple)
262 + and len(b) == len(a)
263 + and all(nested_tensors_equal(b_, a_) for b_, a_ in zip(b, a))
264 )
265
266 # Both a and b are scalars