huggingface / huggingface/diffusers

Cache text encoder embeds in pipelines

Aperta
#10,078 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub
community-examples stale
Lingua principale
Python
Stelle
34.5k
Fork
7.3k
Merge medio
3g 3h
PR unite (30g)
91

Descrizione

**Is your feature request related to a problem? Please describe.**

When reusing a prompt text encoder embeds are recomputed, this can be time consuming for something like T5-XXL with offloading or on CPU.

Text encoder embeds are relatively small, so keeping them in memory is feasible.
```python
import torch

clip_l = torch.randn([1, 77, 768])
t5_xxl = torch.randn([1, 512, 4096])
>>> clip_l.numel() * clip_l.dtype.itemsize
236544
>>> t5_xxl.numel() * t5_xxl.dtype.itemsize
8388608
```

**Describe the solution you'd like.**

MVP would be reusing the last text encoder embeds if the prompt hasn't changed, this behaviour is supported in community UIs. Ideally, supports multiple prompts, potentially serializable.

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Start by tracing the pipeline text-encoding path and how prompts are converted into text encoder embeds. Define the cache behavior for unchanged prompts before considering multiple prompts or serialization. Done means repeated pipeline use avoids recomputing unchanged embeds while preserving correct results when prompts change.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python, pytorch
Ambito
machine-learning, performance
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.