huggingface / huggingface/diffusers
`UNet2DConditionModel` : `qk_norm` setting in `config.json` is ignored
- Vorherrschende Sprache
- Python
- Sterne
- 34.5k
- Forks
- 7.3k
- Ø Merge
- 3 T. 3 Std.
- Gemergte PRs (30 T.)
- 91
Beschreibung
### Describe the bug
Adding eg `"qk_norm": "rms_norm"` to config.json for a `UNet2DConditionModel` has no effect.
This is because the value is not propagated by the `UNet2DContionalModel` initialization logic through to `Attention.__init__` in `src/diffusers/models/attention_processor.py`.
### Reproduction
Default behaviour with empty config dict:
```
from diffusers import UNet2DConditionModel
config_minimal = {}
model = UNet2DConditionModel.from_config(config_minimal)
print([n for n, _ in model.named_modules()
if 'attn1.norm_' in n])
# output: []
```
For supported models, QK norm modules show up as eg `... .attn1.norm_q` and `... .attn1.norm_k`. If we add `"qk_norm" : "rms_norm"` to the config then we should expect modules with these names to appear, but they don't:
```
config_minimal['qk_norm'] = 'rms_norm'
model = UNet2DConditionModel.from_config(config_minimal)
print([n for n, _ in model.named_modules()
if 'attn1.norm_' in n])
# expected output: ['down_blocks.0.attentions.0.transformer_blocks.0.attn1.norm_q', 'down_blocks.0.attentions.0.transformer_blocks.0.attn1.norm_k', ...]
# actual output: []
```
### System Info
diffusers main branch commit 0c71189abeaa8ab4b28dd7e5a309ac75c64968a2, macOS
### Who can help?
@DN6 @yiyixuxu @sayakpaul
Beitragsleitfaden
Rechercherichtung
Beginne mit dem Initialisierungspfad von UNet2DConditionModel und verfolge, wie qk_norm aus config.json Attention.__init__ in src/diffusers/models/attention_processor.py erreichen sollte. Führe das bereitgestellte from_config-Beispiel erneut aus und bestätige, dass qk_norm="rms_norm" die Module attn1.norm_q und attn1.norm_k anstelle einer leeren Liste erzeugt.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- machine-learning
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Klar beschrieben
- Anfängerfreundlichkeit
- 55/100