How should `ModularPipeline` handle a component that failed to load?

Offen
#15,227 6 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Anfängerfreundlichkeit
15/100
Issue-Typ
Feature
Klarheit
Muss geklärt werden
Aktivitätsstatus
Aktiv
Tech-Stack
python, pytorch
Bereich
ai

Rechercherichtung

Start in ModularPipeline.load_components, where each component load sits inside a try/except that logs a warning and leaves None. The example reproduces through Qwen2VLProcessor raising an ImportError for missing torchvision, so trace how that error reaches the modular path. Done means maintainers have agreed on whether a failed load should raise, be marked as deferred, or stay a warning, and that decision is recorded in the thread before any code is written.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

idea-contribution-welcome
What happens today

ModularPipeline.load_components wraps every component load in try/except. When one fails, it logs a warning and carries on with the others, leaving None for the component that failed.

My motivation for this was that loading is a time-consuming process, and one failure should not force the user to load everything again. If the component is optional (e.g. a safety checker that needs an external dependency that is not installed), they can simply skip it. If it is required and failed for a legitimate reason (e.g. a missing dependency), it is better that they load it separately and pass it with update_components than reload everything.

The other side of this is that a warning is not loud enough. If you do not notice it, the failure comes back at run time as an AttributeError or TypeError on None inside a block, far from the warning that explained the cause. In diffusers we prefer things to be explicit, and silently carrying on with a None component is not.

Example

Qwen2VLProcessor bundles a video processor that only has a torchvision implementation, and torchvision is not installed by diffusers or transformers. In an environment without it:

from diffusers import ModularPipeline

pipe = ModularPipeline.from_pretrained("Qwen/Qwen-Image-Edit")
pipe.load_components(names=["tokenizer", "processor"])
# logs: Failed to create component processor: ... you can safely ignore this message ...
#       ImportError: Qwen2VLVideoProcessor requires the Torchvision library but it was not found in your environment.
print(pipe.processor)  # None

Running the pipeline afterwards fails in the text encoder block when it calls the None processor. Loading the same processor directly, or through DiffusionPipeline.from_pretrained, raises the ImportError right away, so this only happens on the modular path.

Feedback and suggestions welcome.

Opened by Claude on behalf of @yiyixuxu

Vorherrschende Sprache
Python
Sterne
35k
Forks
7.5k
Ø Merge
2 T. 22 Std.
Gemergte PRs (30 T.)
58

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus huggingface/diffusers

Alle Issues in huggingface/diffusers

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.