Spaces:
Sleeping
Sleeping
Commit ·
000cfc0
1
Parent(s): 312e1b4
Enable FA3 attention and torch.compile for faster inference
Browse filesReplaces the ZeroGPU-era no-ops with real optimizations suitable for
dedicated GPU deployment: FA3 processor on all 60 transformer blocks
(with graceful fallback), and torch.compile(mode="reduce-overhead") on
the transformer for kernel fusion and CUDA graph capture.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
app.py
CHANGED
|
@@ -86,9 +86,18 @@ pipe = QwenImageEditPlusPipeline.from_pretrained(
|
|
| 86 |
_hb.set()
|
| 87 |
print(f"[startup] pipeline loaded in {time.perf_counter()-_t1_load:.1f}s", flush=True)
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
with open("examples.json") as _f:
|
| 94 |
EXAMPLES_CONFIG = json.load(_f)
|
|
|
|
| 86 |
_hb.set()
|
| 87 |
print(f"[startup] pipeline loaded in {time.perf_counter()-_t1_load:.1f}s", flush=True)
|
| 88 |
|
| 89 |
+
try:
|
| 90 |
+
from qwenimage.qwen_fa3_processor import QwenDoubleStreamAttnProcessorFA3
|
| 91 |
+
_fa3_processor = QwenDoubleStreamAttnProcessorFA3()
|
| 92 |
+
for _block in pipe.transformer.transformer_blocks:
|
| 93 |
+
_block.attn.processor = _fa3_processor
|
| 94 |
+
print("[startup] FA3 attention processor enabled.", flush=True)
|
| 95 |
+
except Exception as _fa3_err:
|
| 96 |
+
print(f"[startup] FA3 not available ({_fa3_err}), using default attention processor.", flush=True)
|
| 97 |
+
|
| 98 |
+
print("[startup] applying torch.compile to transformer (mode=reduce-overhead)...", flush=True)
|
| 99 |
+
pipe.transformer = torch.compile(pipe.transformer, mode="reduce-overhead")
|
| 100 |
+
print("[startup] torch.compile done.", flush=True)
|
| 101 |
|
| 102 |
with open("examples.json") as _f:
|
| 103 |
EXAMPLES_CONFIG = json.load(_f)
|