huggingface / huggingface/diffusers
Qwen Image prompt encoding is not padding to max seq len
- Lingua principale
- Python
- Stelle
- 34.5k
- Fork
- 7.3k
- Merge medio
- 3g 3h
- PR unite (30g)
- 91
Descrizione
### Describe the bug
The pipeline method for QwenImagePipeline.encode_prompts is not padding correctly; it's padding by the longest sequence length in the batch, which leaves very very short embeds that are out of distribution for the models' training set.
The padding should remain at 1024 tokens even after the system prompt is dropped. The attention mask has to be expanded too.
### Reproduction
Execute `QwenImagePipeline.encode_prompts()` and check resulting shape.
### Logs
```shell
prompt_embeds.shape=torch.Size([1, 1024, 3584]), prompt_embeds_mask.shape=torch.Size([1, 1024])
^ after fixing.
prompt_embeds.shape=torch.Size([1, 5, 3584]) prompt_embeds_mask.shape=torch.Size([1, 5])
^ before.
```
prompt was simply `minecraft`
this leads to extremely high loss at training time unless very-long prompts are used.
at inference time, it causes patch embed artifacts because the RoPE is not accustomed to these positions.
### System Info
Latest git main.
### Who can help?
_No response_
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da QwenImagePipeline.encode_prompts() e riproduci la forma riportata con il prompt `minecraft`. Verifica che gli embedding del prompt e la relativa maschera di attenzione mantengano una lunghezza di 1024 dopo la rimozione del prompt di sistema; il risultato atteso è la forma riportata [1, 1024, 3584] per entrambi.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, pytorch
- Ambito
- machine-learning
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Specificata chiaramente
- Idoneità per principianti
- 52/100