huggingface / huggingface/diffusers

CogvideoX VAE decoder consumes significantly more memory in the latest version

Offen
#10,091 6 Kommentare 0 Reaktionen 2 zugewiesene Personen Beansprucht von @yiyixuxu Auf GitHub ansehen
bug roadmap wip
Vorherrschende Sprache
Python
Sterne
34.5k
Forks
7.3k
Ø Merge
3 T. 3 Std.
Gemergte PRs (30 T.)
91

Beschreibung

### Discussed in https://github.com/huggingface/diffusers/discussions/10036

Originally posted by **ic-synth** November 27, 2024
### Describe the bug

The memory consumption for CogVideoX decoder in diffusers 0.31.0 version consumes significantly more memory. To the point where the model goes OOM even on 80G H100 GPUs with a relatively modest frame count.
I include two profiles for very small input tensors of only 5 frames where its visible how much larger the VAE memory consumption is.

Memory footprints for different input sizes are shown below. As you can see, with latest version memory keeps growing with frame count.
![diffusers version](https://github.com/user-attachments/assets/ce8524fb-2781-4a9a-91a7-9335f21884df)
![diffusers version 3](https://github.com/user-attachments/assets/eaafc484-96d0-4070-983e-ddba10be7e89)

### Reproduction

Run `CogVideoXDecoder3D` model with diffusers 0.30.3 and 0.31.0 on the inputs of the same shape and measure the memory consumption as the frame count increases.

```
# Code requires a GPU with 50+ gigabytes on RAM
import torch
import diffusers
from diffusers import AutoencoderKLCogVideoX

with torch.no_grad():
vae = AutoencoderKLCogVideoX().to(dtype=torch.bfloat16).eval()
vae.decoder = vae.decoder.to(device="cuda:0")
input_tensor = torch.randn(1,16,5,96,170).to(device="cuda:0", dtype=torch.bfloat16)
print("Decoding ... Input size:", input_tensor.shape, "Diffuser version", diffusers.__version__)
vae.decode(input_tensor)
print(torch.cuda.max_memory_allocated() / (1024 ** 3) , torch.cuda.max_memory_reserved() / (1024 ** 3))
```

### Logs

_No response_

### System Info

Python 3.11.
Diffusers 0.30.3 vs 0.31.0

### Who can help?

@sayakpaul @DN6 @yiyixuxu

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

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