huggingface / huggingface/diffusers
wan2.1 vae take more gpu memory after compile
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 34.5k
- フォーク
- 7.3k
- 平均マージ
- 3日 3時間
- マージ済み PR(30日)
- 91
説明
### Describe the bug
After `torch.compile` wan2.1 vae consume more GPU memory than `no compilation`, which is unexpected in my opinion.
**compiled**
**no-compile**
### Reproduction
```python
import sys
import torch
from diffusers import AutoencoderKLWan
def compile_wan_vae(compile):
model_id = 'Wan-AI/Wan2.1-T2V-14B-Diffusers'
dtype = torch.float32
device = 'cuda'
torch.cuda.memory._record_memory_history()
vae = AutoencoderKLWan.from_pretrained(
model_id, subfolder="vae", torch_dtype=dtype
).to(device)
if compile:
vae.decoder = torch.compile(vae.decoder)
shape = (1, 16, 13, 120, 120)
with torch.no_grad():
latents = torch.randn(shape, device=device, dtype=dtype)
video = vae.decode(latents, return_dict=False)[0]
torch.cuda.empty_cache()
with torch.no_grad():
for _ in range(3):
latents = torch.randn(shape, device=device, dtype=dtype)
video = vae.decode(latents, return_dict=False)[0]
torch.cuda.memory._dump_snapshot(f"{compile}-compile.pickle")
if __name__ == '__main__':
compile_wan_vae(sys.argv[1] == 'compile')
```
### Logs
```shell
```
### System Info
- 🤗 Diffusers version: 0.34.0
- Platform: Linux-5.10.134-16.1.3.vip.an8.x86_64-x86_64-with-glibc2.39
- Running on Google Colab?: No
- Python version: 3.12.3
- PyTorch version (GPU?): 2.7.1+cu126 (True)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Huggingface_hub version: 0.34.2
- Transformers version: 4.54.0
- Accelerate version: 1.9.0
- PEFT version: 0.16.0
- Bitsandbytes version: not installed
- Safetensors version: 0.5.3
- xFormers version: not installed
- Accelerator: NVIDIA L20, 46068 MiB
NVIDIA L20, 46068 MiB
NVIDIA L20, 46068 MiB
NVIDIA L20, 46068 MiB
NVIDIA L20, 46068 MiB
NVIDIA L20, 46068 MiB
NVIDIA L20, 46068 MiB
NVIDIA L20, 46068 MiB
- Using GPU in script?:
- Using distributed or parallel set-up in script?:
### Who can help?
_No response_
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
提供された再現手順をAutoencoderKLWanで開始し、コンパイル済みと未コンパイルの vae.decoder パスについて torch.cuda のメモリスナップショットを比較します。vae.decode の呼び出しを繰り返したときに torch.compile がデコーダーにどのような影響を与えるかを調査し、その後、記載された PyTorch および GPU の構成で、コンパイル済みパスが予期せずより多くの GPU メモリを消費しなくなったことを確認します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python, pytorch
- 領域
- machine-learning, performance
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100