Skip to content

Commit

Permalink
fix: check dtype when loading models (#872)
Browse files Browse the repository at this point in the history
* fix: check dtype when loading models

* fix: black
  • Loading branch information
ZiniuYu authored Dec 7, 2022
1 parent c7af9f7 commit fd16e5a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion server/clip_server/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,9 @@ def load_openai_model(

# model from OpenAI state dict is in manually cast fp16 mode, must be converted for AMP/fp32/bf16 use
model = model.to(device)
if dtype == torch.float32 or dtype.startswith('amp'):
if dtype == torch.float32 or (
isinstance(dtype, str) and dtype.startswith('amp')
):
model.float()
elif dtype == torch.bfloat16:
convert_weights_to_lp(model, dtype=torch.bfloat16)
Expand Down

0 comments on commit fd16e5a

Please sign in to comment.