-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix setting fp16 dtype in AnimateDiff convert script. #7127
Conversation
@@ -48,4 +48,4 @@ def get_args(): | |||
# skip loading position embeddings | |||
adapter.load_state_dict(conv_state_dict, strict=False) | |||
adapter.save_pretrained(args.output_path) | |||
adapter.save_pretrained(args.output_path, variant="fp16", torch_dtype=torch.float16) | |||
adapter.to(torch.float16).save_pretrained(args.output_path, variant="fp16") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be made configurable? Folks might not want to serialize the model in fp16.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
@@ -48,4 +49,6 @@ def get_args(): | |||
# skip loading position embeddings | |||
adapter.load_state_dict(conv_state_dict, strict=False) | |||
adapter.save_pretrained(args.output_path) | |||
adapter.save_pretrained(args.output_path, variant="fp16", torch_dtype=torch.float16) | |||
|
|||
if args.save_fp16: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are we missing an else
statement here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC the scrtipt always serializes in the full precision. I think the script additionally serializes in FP16 when args.save_fp16
is True.
What does this PR do?
save_pretrained
doesn't actually usetorch_dtype
to convert the checkpoint tofp16
before saving. This PR adds a fix to the convert script so thatfp16
weights are saved correctly for AnimateDiff modelsFixes # (issue)
Before submitting
documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.