Skip to content

Conversation

@DN6
Copy link
Collaborator

@DN6 DN6 commented Feb 28, 2024

What does this PR do?

save_pretrained doesn't actually use torch_dtype to convert the checkpoint to fp16 before saving. This PR adds a fix to the convert script so that fp16 weights are saved correctly for AnimateDiff models

Fixes # (issue)

Before submitting

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.

@DN6 DN6 requested a review from sayakpaul February 28, 2024 06:24
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")
Copy link
Member

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

@HuggingFaceDocBuilderDev

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.

@DN6 DN6 merged commit 8f2d13c into main Feb 29, 2024
adapter.save_pretrained(args.output_path)
adapter.save_pretrained(args.output_path, variant="fp16", torch_dtype=torch.float16)

if args.save_fp16:
Copy link
Collaborator

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?

Copy link
Member

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.

@sayakpaul sayakpaul deleted the animatediff-conversion-script branch March 5, 2024 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants