-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 fix #9741
Conversation
def test_diffusers_is_compatible_no_components(self): | ||
filenames = [ | ||
"diffusion_pytorch_model.bin", | ||
] | ||
self.assertFalse(is_safetensors_compatible(filenames)) | ||
|
||
def test_diffusers_is_compatible_no_components_only_variants(self): | ||
filenames = [ | ||
"diffusion_pytorch_model.fp16.bin", | ||
] | ||
self.assertFalse(is_safetensors_compatible(filenames)) |
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.
Would it also make sense to check the dummy repo here?
if not components: | ||
return any(".safetensors" in filename for filename in filenames) |
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.
Would also mention the description of this function because this is not accounted for there.
Converting default pytorch serialized filenames to safetensors serialized filenames: |
@@ -118,6 +118,10 @@ def is_safetensors_compatible(filenames, passed_components=None, folder_names=No | |||
components.setdefault(component, []) | |||
components[component].append(component_filename) | |||
|
|||
# If there are no component folders check the main directory for safetensors 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.
Is this sufficient as a check? 👁️
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. |
What does this PR do?
Caught during our release process. The following snippet fails
This is because:
https://huggingface.co/fusing/unet-ldm-dummy-update/tree/main
Doesn't have components in subfolders (which is what we usually expect for trying to load pipelines). The
is_safetensors_compatible
check was defaulting to True here because there were no components to iterate over.Changing so we have an additional check to handle this case by checking the main dir in the repo for safetensor files as well if there are no component folders.
Fixes # (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.