-
Notifications
You must be signed in to change notification settings - Fork 6.6k
is_safetensors_compatible refactor #2499
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
is_safetensors_compatible refactor #2499
Conversation
aae7361 to
70e0d4d
Compare
|
The documentation is not available anymore as the PR was closed or merged. |
70e0d4d to
2fec244
Compare
| """ | ||
| Checking for safetensors compatibility: | ||
| - By default, all models are saved with the default pytorch serialization, so we use the list of default pytorch | ||
| files to know which safetensors files are needed. |
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.
Needed for?
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.
needed to qualify as being safetensors compatible
| - The model is safetensors compatible only if there is a matching safetensors file for at least one default pytorch | ||
| file. |
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.
Where do we look for this mapping? If it cannot be explained in one line, no need to include it then.
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.
at least one
Isn't that all default pytorch files ?
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 for doing this.
Maybe @Narsil also wants to give this a look?
Narsil
left a comment
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.
Looks good.
I was under the assumption diffusers was only using safetensors if all files where available in SF format.
Could be wrong as this seems very deliberate.
Nice PR !
| - The model is safetensors compatible only if there is a matching safetensors file for at least one default pytorch | ||
| file. |
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.
at least one
Isn't that all default pytorch files ?
pcuenca
left a comment
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 was under the same impression as @Narsil (we only downloaded safetensors if all files were available in safetensors format). Does this PR change that, or am I just confused?
|
I think this PR allows combining safetensors and non-safetensors files which is not what we want IMO. |
|
@pcuenca @patrickvonplaten @Narsil yep, my mistake will fix! #2499 (comment) |
2fec244 to
ffa6fbb
Compare
Fixed! Sorry for the confusion |
Narsil
left a comment
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.
LGTM
| "safety_checker/model.safetensors", | ||
| "vae/diffusion_pytorch_model.bin", | ||
| "vae/diffusion_pytorch_model.safetensors", | ||
| "text_encoder/pytorch_model.bin" "text_encoder/model.safetensors", |
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.
Isn't a comma missing there ?
patrickvonplaten
left a comment
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.
Nice refactor, LGTM.
Same comment as Nico though regarding the comma :-)
* is_safetensors_compatible refactor * files list comma
* is_safetensors_compatible refactor * files list comma
* is_safetensors_compatible refactor * files list comma
documented, tested, and refactored is_safetensors_compatible
This is my understanding of the logic from reading the function, please double check it!