Skip to content

Commit

Permalink
Fix loading error when safetensors contains empty tensor (vllm-projec…
Browse files Browse the repository at this point in the history
  • Loading branch information
twaka authored Nov 16, 2023
1 parent baae8fa commit 3b3161d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion vllm/model_executor/weight_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,12 @@ def convert_pyslice_to_tensor(x: Any) -> torch.Tensor:
tensor first.
"""
if not isinstance(x, torch.Tensor):
x = x[:]
try:
x = x[:]
except IndexError:
# IndexError happens when the tensor is empty.
# transformer.h.0.attn.masked_bias is empty in some gpt2 models.
return torch.Tensor()
return x


Expand Down

0 comments on commit 3b3161d

Please sign in to comment.