-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
allow models to run with a user-provided dtype map instead of a single dtype #10301
base: main
Are you sure you want to change the base?
Conversation
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. |
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.
Thanks! Do we not have to handle the typecasts? I think for sharded checkpoints, we might have to.
sub_model_dtype = ( | ||
torch_dtype.get(name, torch_dtype.get("_", torch.float32)) | ||
if isinstance(torch_dtype, dict) | ||
else torch_dtype | ||
) |
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.
I feel like _
might be a bit unintuitive. Better to expose full dtype maps or in case partial ones are provided we default to torch.float32
for the rest of the components.
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.
Could be default
? Considering how it will work for integrations, instead of say {'transformer': torch.bfloat16, 'text_encoder': torch.float16, 'text_encoder_2': torch.float16, 'text_encoder_3': torch.float16}
for SD3 and {'transformer': torch.bfloat16, 'text_encoder': torch.float16, 'text_encoder_2': torch.float16}
for Flux. Not a big issue because components can be got from cls._get_signature_types()
.
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.
Yeah no strong opinions.
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.
For now it's renamed to default
to be clearer, we can remove later if its not needed.
Thanks for the review @sayakpaul. Will look into sharded checkpoints. |
HunyuanVideo is sharded so I think it's ok. |
What does this PR do?
Example
_
is used as a default dtype for components that are not specified, otherwise the current default oftorch.float32
is used.Haven't looked at
from_pipe
case yet and we'll need to add tests but ready for a first review in case there's something missing because it's simpler than expected.Fixes #10108
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.
cc @DN6 @sayakpaul @yiyixuxu