huggingface / huggingface/diffusers

[core] refactor `attention_processor.py` the easy way

Offen
#10,022 6 Kommentare 0 Reaktionen 1 zugewiesene Person Beansprucht von @DN6 Auf GitHub ansehen
wip
Vorherrschende Sprache
Python
Sterne
34.5k
Forks
7.3k
Ø Merge
3 T. 3 Std.
Gemergte PRs (30 T.)
91

Beschreibung

With @DN6 we have been discussing an idea about breaking up `src/diffusers/models/attention_processor.py` as it's getting excruciatingly longer and longer. The idea is simple and won't very likely require multiple rounds of PRs.

* Create a module named `attention_processor`.
* Split the attention processor classes with respect to the model names they are used. This makes sense because pretty much most of the models (at least the widely used ones) have their own attention processors at this point. For example, `FluxAttnProcessor2_0`, `FluxAttnProcessor2_0_NPU`, `FusedFluxAttnProcessor2_0` could go to `attention_processor/flux_attention_processors.py`.
* Other attention processors (such as `AttnProcessor`, `AttnProcessor2_0`, etc.) which are shared across different models could live in a common file i.e., `attention_processor/common.py`.

Since `attention_prcoessor/` will have an init, I don't think there will be any breaking changes.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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