[Minor] Various small code cleanups/simplifications (#31508)

Signed-off-by: njhill <nickhill123@gmail.com>
This commit is contained in:
Nick Hill
2025-12-29 22:42:06 -08:00
committed by GitHub
parent f84bf7d79b
commit 3b312fb792
14 changed files with 29 additions and 55 deletions
+2 -11
View File
@@ -171,10 +171,7 @@ class PlaceholderRange:
@cached_property
def embeds_cumsum(self) -> torch.Tensor | None:
if self.is_embed is None:
return None
return self.is_embed.cumsum(dim=0)
return None if self.is_embed is None else self.is_embed.cumsum(dim=0)
@cached_property
def get_num_embeds(self) -> int:
@@ -308,13 +305,7 @@ def batched_tensors_equal(a: BatchedTensorInputs, b: BatchedTensorInputs) -> boo
Equality check between
[`BatchedTensorInputs`][vllm.multimodal.inputs.BatchedTensorInputs] objects.
"""
for k in a:
if k not in b:
return False
if not nested_tensors_equal(a[k], b[k]):
return False
return True
return all(k in b and nested_tensors_equal(a[k], b[k]) for k in a)
@dataclass