huggingface / huggingface/diffusers

Remove redundant comparison inside the diffusion loop of stable video diffusion pipeline

Offen
#9,425 8 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
stale
Vorherrschende Sprache
Python
Sterne
34.5k
Forks
7.3k
Ø Merge
3 T. 3 Std.
Gemergte PRs (30 T.)
91

Beschreibung

**Is your feature request related to a problem? Please describe.**
I found that the inside the `__call__` of stable video diffusion keeps doing async memcpy between host to device as attached.
Screenshot 2024-09-12 at 6 45 24 PM

**Describe the solution you'd like.**
The reason for that is actually coming from every time we get `self.do_classifier_free_guidance`, we compared tensor between `int` -> get boolean on device -> memcpy that boolean from gpu to cpu.

It'll be good to just assign a variable for it before the loop as the value won't change through the loop.

**Additional context.**
I'm glad to contribute this by opening a PR

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

Start at the stable video diffusion pipeline's __call__ method and inspect the diffusion loop where self.do_classifier_free_guidance is repeatedly evaluated. Cache the unchanged value before the loop, then verify the loop no longer performs that repeated comparison or associated host-device transfer.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python, pytorch
Bereich
machine-learning, performance
Issue-Typ
Refactoring
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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