Spaces:
Running on Zero
Running on Zero
force the memory-efficient SDPA backend on sm_120
Browse files
app.py
CHANGED
|
@@ -29,6 +29,15 @@ import os
|
|
| 29 |
# allocator. Set it explicitly so a platform default cannot turn it back on.
|
| 30 |
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:False"
|
| 31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
import queue
|
| 33 |
import shutil
|
| 34 |
import subprocess
|
|
|
|
| 29 |
# allocator. Set it explicitly so a platform default cannot turn it back on.
|
| 30 |
os.environ["PYTORCH_CUDA_ALLOC_CONF"] = "expandable_segments:False"
|
| 31 |
|
| 32 |
+
# wan21_patches/modules/attention.py pins SDPA's backend order with cuDNN first,
|
| 33 |
+
# from timings taken on an sm_100 B200 with torch 2.13. This Space is sm_120 on
|
| 34 |
+
# torch 2.11, where that order falls through to the MATH backend: it materialises
|
| 35 |
+
# the whole [B, 12, 2760, 29440] score matrix, and one block forward peaks at
|
| 36 |
+
# 44.2 GB against a 47.4 GB slice. The memory-efficient fused kernel handles both
|
| 37 |
+
# shapes this model attends over -- unmasked self-attention against the K/V cache,
|
| 38 |
+
# and key-padded cross-attention -- in linear memory.
|
| 39 |
+
os.environ.setdefault("WAN_SDPA_BACKEND", "EFFICIENT_ATTENTION")
|
| 40 |
+
|
| 41 |
import queue
|
| 42 |
import shutil
|
| 43 |
import subprocess
|