Automatically reusing components
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- huggingface, python
- Domain
- machine-learning
Research direction
Read the ComponentsManager guide and the Pika H3 Flex example linked in the issue to understand how components are currently shared. The proposal is to discuss opt-in reuse based on checkpoint weight hashes; this issue explicitly asks for feedback and use cases rather than a code change. Share a concrete concern, alternative, or experience with manual component reuse.
Written by the indexing model from the issue text.
Description
Diffusers pipelines often share components: the same text encoder or VAE across model families, a finetune reusing its base model's components, a LoRA-based model reusing the base transformer entirely. Loading each of them twice wastes time, and worse, it keeps two copies of the same model in memory. So we want to reuse the same components as much as possible.
What we have today
In Modular Diffusers, ComponentsManager manages components across pipelines. Load one pipeline through it, and a second pipeline can pick up what it needs from the manager instead of loading its own copy:
pika.update_components(transformer=manager.get_one(name="transformer", collection="minimax-h3"))
See the ComponentsManager guide and the Pika H3 Flex example, where a second pipeline is assembled from a loaded MiniMax-H3.
The reuse itself is still manual: you decide which components are shared and pass them over. What the manager gives you is bookkeeping so you can keep track of it. Each component is listed once with the pipelines that use it (when you register under a collection), offloading works across all of them, and the manager warns when two components were loaded from the same repo and subfolder. That warning is as far as duplicate detection goes today, and it comes after the second copy is already loaded.
The Hub now dedups on disk
With huggingface_hub>=1.32.0, identical Xet-backed files share one cached payload across repositories, shard by shard. Download the same text encoder from two repos and it lands on disk once. We could take advantage of that and go one step further: dedup the models we load into memory too.
Proposal
An opt-in setting on the manager. When a pipeline is about to load a component, the manager checks whether the same weights are already loaded, using the same idea the Hub uses to dedup: a content hash of the weights, stored with the checkpoint and compared before loading. If there is a match, the pipeline reuses the loaded component instead of loading again. No download, no second copy.
How to contribute
This issue carries the new idea-contribution-welcome label. For issues with this label we are not looking for a PR. We are looking for discussion: feedback on the proposal, alternatives, use cases we have not thought of, problems you ran into with the current manual way. We will write the PR ourselves, and anyone whose feedback shaped it will be added as a co-author.
Posted by Claude on behalf of @yiyixuxu. The text was drafted together and approved by yiyixuxu.
- Dominant language
- Python
- Stars
- 35k
- Forks
- 7.5k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 58
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from huggingface/diffusers
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
huggingface/diffusers#15436 · 1 comment ·
Maintainers usually reply within 1 day
-
InpaintProcessor crashes when padding_mask_crop is set and a dimension is omittedPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
huggingface/diffusers#15433 ·
Maintainers usually reply within 1 day
-
LTXEulerAncestralRFScheduler skips signal scaling with s_noise=0Possibly taken @hparik11 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
huggingface/diffusers#15423 · 2 comments ·
Maintainers usually reply within 1 day
-
Docs: 13 docstrings document parameters their functions don't havePossibly taken @M-Colley claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
huggingface/diffusers#15363 · 2 comments ·
Maintainers usually reply within 1 day
-
`ZImageImg2ImgPipeline` / `ZImageInpaintPipeline`: explicit height/width different from the input image raises RuntimeErrorPossibly taken @chessing234 claimed this 11 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
huggingface/diffusers#15337 · 3 comments ·
Maintainers usually reply within 1 day
All issues in huggingface/diffusers
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 79/100
developmentseed/titiler-covjson#164 ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
awslabs/visual-asset-management-system#2164 ·
Maintainers usually reply within 1 day
-
needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
MakazhanAlpamys/Soup#3589 ·
Maintainers usually reply within 1 day
-
channels status reports the wrong Enabled value for Feishu instances and default-enabled WebSocketOpen
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 1 day