Fix Hub download filtering for FlashPack pipelines#14166
Open
rumutaydin wants to merge 2 commits into
Open
Conversation
Pipelines saved with use_flashpack=True could not be loaded through the Hub download path: _get_ignore_patterns excluded all *.safetensors, so transformers components (text encoders) had no weights in the snapshot, and FlashPack files were missing from variant_compatible_siblings' weight names, so they never entered the allow patterns either. With use_flashpack=False, *.flashpack files were still downloaded despite the documented behavior. Judge safetensors compatibility over non-flashpack folders only, keep just the flashpack file inside flashpack-covered folders, register FlashPack files as weight names, and never download flashpack weights when use_flashpack is disabled.
from_pretrained popped use_flashpack but never passed it to download, so Hub-mediated loading never fetched FlashPack weights regardless of the flag.
This was referenced Jul 10, 2026
Contributor
|
Hi @rumutaydin, thanks for the PR! It does not appear to link an issue it fixes. If this PR addresses an existing issue, please add a closing keyword (e.g. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Pipelines saved with
save_pretrained(use_flashpack=True)currently cannot be loadedback through the Hub. Such a pipeline stores diffusers models as
model.flashpackandtransformers components (text encoders) as safetensors but the download path breaks
on this layout three ways:
_get_ignore_patternstakes theelif use_flashpack:branch and ignores all*.safetensors. Sinceuse_flashpackis only forwarded to diffusers models, textencoders can only load safetensors which are now missing from the snapshot:
With explicit
use_safetensors=Trueit raisesEnvironmentErrorinstead, becausethe flashpack-only folders make
is_safetensors_compatiblefail.FlashPack files are missing from
variant_compatible_siblings' weight names, sothey never enter the download allow-patterns combined with (1), a FlashPack
pipeline snapshot contains no weights at all.
use_flashpack=False: thedownloaddocstring says FlashPack weights "will neverbe downloaded", but
*.flashpackappears in no ignore pattern, so default users ofdual-format repos download FlashPack blobs they never read.
Fixes (issue)
judge safetensors compatibility over non-flashpack folders only, keep just the
flashpack file inside flashpack-covered folders (per-folder ignore patterns), register
FLASHPACK_WEIGHTS_NAMEas a weight name, ignore*.flashpackwheneveruse_flashpack=False, and forwarduse_flashpackfromfrom_pretrainedtodownload(it was popped but never passed on, so the flag had no effect on Hub downloads).
Repos with no FlashPack files behave exactly as before, with or without the flag.
Tests
an end-to-end regression test that saves a FlashPack pipeline, applies the real
allow/ignore download filter, and round-trips the filtered snapshot (fails on
main),plus direct
_get_ignore_patternscases for the mixed/dual/flashpack-only/no-flashpacklayouts and a test that
from_pretrainedforwards the flag.Related:
#12564, #12700.
Before submitting
.ai/review-rules.md?documentation guidelines, and
here are tips on formatting docstrings.
Who can review?
@DN6 @yiyixuxu