Skip to content

Conversation

@williamberman
Copy link
Contributor

documented, tested, and refactored is_safetensors_compatible

This is my understanding of the logic from reading the function, please double check it!

@williamberman williamberman force-pushed the is_safetensors_compatible_refactor branch from aae7361 to 70e0d4d Compare February 26, 2023 03:34
@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Feb 26, 2023

The documentation is not available anymore as the PR was closed or merged.

@williamberman williamberman force-pushed the is_safetensors_compatible_refactor branch from 70e0d4d to 2fec244 Compare February 26, 2023 05:45
"""
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.
Copy link
Member

Choose a reason for hiding this comment

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

Needed for?

Copy link
Contributor Author

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

Comment on lines 136 to 137
- The model is safetensors compatible only if there is a matching safetensors file for at least one default pytorch
file.
Copy link
Member

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.

Copy link
Contributor

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 ?

Copy link
Member

@sayakpaul sayakpaul left a 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?

Copy link
Contributor

@Narsil Narsil left a 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 !

Comment on lines 136 to 137
- The model is safetensors compatible only if there is a matching safetensors file for at least one default pytorch
file.
Copy link
Contributor

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 ?

Copy link
Member

@pcuenca pcuenca left a 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?

@patrickvonplaten
Copy link
Contributor

I think this PR allows combining safetensors and non-safetensors files which is not what we want IMO.

@williamberman
Copy link
Contributor Author

williamberman commented Feb 27, 2023

@pcuenca @patrickvonplaten @Narsil yep, my mistake will fix! #2499 (comment)

@williamberman williamberman force-pushed the is_safetensors_compatible_refactor branch from 2fec244 to ffa6fbb Compare February 28, 2023 00:01
@williamberman
Copy link
Contributor Author

@pcuenca @patrickvonplaten @Narsil yep, my mistake will fix! #2499 (comment)

Fixed! Sorry for the confusion

Copy link
Contributor

@Narsil Narsil left a 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",
Copy link
Contributor

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 ?

Copy link
Contributor

@patrickvonplaten patrickvonplaten left a 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 :-)

@williamberman williamberman merged commit 856dad5 into huggingface:main Mar 1, 2023
mengfei25 pushed a commit to mengfei25/diffusers that referenced this pull request Mar 27, 2023
* is_safetensors_compatible refactor

* files list comma
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
* is_safetensors_compatible refactor

* files list comma
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
* is_safetensors_compatible refactor

* files list comma
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.

6 participants