huggingface / huggingface/diffusers
`from_pipe` converts pipelines to float32 by default
- Lingua principale
- Python
- Stelle
- 34.5k
- Fork
- 7.3k
- Merge medio
- 3g 3h
- PR unite (30g)
- 91
Descrizione
### Describe the bug
Pipelines passed to `from_pipe()` are converted to float32 unless `torch_dtype` is specified, leading to higher memory usage and slower inference.
### Reproduction
```python
import torch
from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline
pipe = StableDiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch.float16).to("cuda")
print(f"Before: {pipe.dtype} - {torch.cuda.memory_allocated() // 1048576} MB")
i2i = StableDiffusionImg2ImgPipeline.from_pipe(pipe)
print(f"After: {pipe.dtype} - {torch.cuda.memory_allocated() // 1048576} MB")
```
### Logs
```
Loading pipeline components...: 0%| | 0/7 [00:00
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start at the `from_pipe()` entry point and reproduce the conversion with the StableDiffusionPipeline and StableDiffusionImg2ImgPipeline example from the issue. Compare the pipeline dtype and CUDA memory before and after conversion. Done means a pipeline passed through `from_pipe()` retains the source dtype by default without requiring `torch_dtype`.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- python, pytorch
- Ambito
- machine-learning, performance
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 38/100