Skip to content

Conversation

@DN6
Copy link
Collaborator

@DN6 DN6 commented Oct 22, 2024

What does this PR do?

Caught during our release process. The following snippet fails

python -c "from diffusers import DiffusionPipeline; pipe = DiffusionPipeline.from_pretrained('fusing/unet-ldm-dummy-update'); pipe()"

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

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.

Comment on lines +200 to +210
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))
Copy link
Member

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?

Comment on lines +122 to +123
if not components:
return any(".safetensors" in filename for filename in filenames)
Copy link
Member

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:

components.setdefault(component, [])
components[component].append(component_filename)

# If there are no component folders check the main directory for safetensors files
Copy link
Member

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? 👁️

@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 76c00c7 into main Oct 22, 2024
18 checks passed
@sayakpaul sayakpaul deleted the safetensors-compatible-fix branch October 22, 2024 14:30
sayakpaul pushed a commit that referenced this pull request Dec 23, 2024
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.

4 participants