Skip to content

Commit

Permalink
QWEN: Fix unsupported ScalarType BFloat16 (ml-explore#187)
Browse files Browse the repository at this point in the history
Fix unsupported ScalarType BFloat16.
  • Loading branch information
yfyang86 authored Dec 25, 2023
1 parent c190af6 commit 447abb2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion llms/qwen/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def convert(args):
args.model, trust_remote_code=True, torch_dtype=torch.float16
)
state_dict = model.state_dict()
weights = {replace_key(k): v.numpy() for k, v in state_dict.items()}
weights = {replace_key(k): (v.numpy() if v.dtype != torch.bfloat16 else v.to(torch.float32).numpy()) for k, v in state_dict.items()}
config = model.config.to_dict()

if args.quantize:
Expand Down

0 comments on commit 447abb2

Please sign in to comment.