Improve downloads of sharded variants by DN6 · Pull Request #9869 · huggingface/diffusers (original) (raw)

What does this PR do?

Our current check for variants in variant_compatible_sibling downloads extra non variant files. See: #9253 (comment)

This is because we check if a non-variant filename has an equivalent variant filename. e.g. transformers/model-0003-0005.safetensors has transformers/model-fp16-0003-0005.safetensors in its variants. If it doesn't, we add the file to the list of allowed patterns to download.

This type of check doesn't work for sharded checkpoints since variants of smaller dtypes such as fp16 will always have a fewer number of shards. Therefore the non-variant shard file have no equivalent variant shard file.

This PR:
Changes the check to see if a variant exists for a pipeline component (regardless of whether it's sharded or not). If a variant exists for the component, we don't attempt to add any more files related to that component.

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.