Merge pull request #2262 from fenglui/main

fix torch_dtype check of export_model

Former-commit-id: 37cacf73a534fed1b06b4f3c6724f3568ce095e3
This commit is contained in:
hoshi-hiyouga 2024-01-21 12:34:37 +08:00 committed by GitHub
commit 41b34e5f60

View File

@ -57,7 +57,7 @@ def export_model(args: Optional[Dict[str, Any]] = None):
raise ValueError("The model is not a `PreTrainedModel`, export aborted.")
setattr(model.config, "use_cache", True)
if getattr(model.config, "torch_dtype", None) == "bfloat16":
if getattr(model.config, "torch_dtype", None) == torch.bfloat16:
model = model.to(torch.bfloat16).to("cpu")
else:
model = model.to(torch.float16).to("cpu")