Skip to content

Commit

Permalink
Simplify
Browse files Browse the repository at this point in the history
Signed-off-by: DarkLight1337 <[email protected]>
  • Loading branch information
DarkLight1337 committed Nov 29, 2024
1 parent f73282e commit e1ca1f0
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions vllm/model_executor/models/adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
_T = TypeVar("_T", bound=type[nn.Module])


def _is_paramless(module: nn.Module):
# NOTE: all([]) returns True
return all(False for _ in module.parameters())


def as_embedding_model(cls: _T) -> _T:
"""Subclass an existing vLLM model to support embeddings."""
# Avoid modifying existing embedding models
Expand Down Expand Up @@ -77,7 +72,7 @@ def load_weights(self, weights: Iterable[tuple[str, torch.Tensor]]):
if hasattr(self, "model") and hasattr(self.model, "load_weights"):
# Whether only `self.model` contains parameters
model_is_only_param = all(
name == "model" or _is_paramless(child)
name == "model" or next(child.parameters(), None) is None
for name, child in self.named_children())

if model_is_only_param:
Expand Down

0 comments on commit e1ca1f0

Please sign in to comment.