Triton + SageAttention (ComfyUI acceleration)

Install Triton + SageAttention to accelerate ComfyUI (the sageattn attention_mode and inductor torch.compile used by WanVideoWrapper / many video graphs).

How to install

How to install

  1. Setup differs for this server — follow the Installation part of the README below.
  2. Claude Code: claude mcp add <name> -- <command>.
  3. Claude Desktop / Cursor: add it under mcpServers in the MCP config file.
Claude Code — installs the whole folder, not just SKILL.md
npx degit artokun/comfyui-mcp/plugin/skills/triton-sageattention#main ~/.claude/skills/triton-sageattention

For one project only, change the path to .claude/skills/triton-sageattention. This skill also uses main.py, pack.yaml — copying SKILL.md alone won't be enough. See the folder on GitHub.

This one runs on your machine and can reach your files. Read the README below before you connect it.

Not working?
  • Check which app you pasted it into — the steps above name the right one.
  • Some skills need the paid tier of Claude or ChatGPT.
Step-by-step guide with screenshots · Ask in the forum

Paste into Claude, ChatGPT or Cursor.

Show the full text380 lines
triton-sageattention/SKILL.md380 lines19.4 KBpushed 27d agoRawView on GitHub

Triton + SageAttention (ComfyUI acceleration)

See also comfyui-launch-flags for the full attention / VRAM / cache flag matrix. Note the Z-Image exception: Z-Image is broken under --use-sage-attention, so launch it with --use-pytorch-cross-attention instead.

Prefer kitchen INT8 attention when it is available

If kitchen action:"status" (or panel_kitchen) reports kitchen present and int8_attention_is_available on this GPU, launch with --use-ck-attention and skip the sageattention wheel dance. Kitchen INT8 attention is a ComfyUI flag; it does not need a version-matched sageattention wheel. Restart required, consent-gated like every restart.

Only fall through to the Triton + SageAttention install below when kitchen INT8 is unknown or not available. A failed kitchen probe is unknown, not a no.

Overview

Two optional accelerators that many modern video graphs (especially kijai's ComfyUI-WanVideoWrapper) reference by default:

  • SageAttention (import sageattention), a quantized attention kernel. Selected via a node's attention_mode = sageattn (WanVideoWrapper) or ComfyUI's --use-sage-attention startup flag. ~20 to 40% faster sampling on supported NVIDIA GPUs.
  • Triton, the GPU kernel compiler that inductor torch.compile needs. WanVideoWrapper's WanVideoTorchCompileSettings (and any torch.compile/ inductor node) compiles the model through Triton for another speedup.

The risk. Both are version-locked to your exact torch + CUDA + python. A wrong wheel does worse than fail to install. It can break the torch install (mismatched CUDA DLLs, ImportError, or silent NaNs). And the failure mode of not having them is a hard crash before any sampling: ValueError: Can't import SageAttention: No module named 'sageattention', or compile errors / triton: unavailable in the startup log. This is exactly the video-extend TRAP 5.

Therefore the default is to get a working render FIRST with the sdpa / no-compile fallback, then OFFER to install acceleration for speed. Never run a torch-breaking install unannounced to "fix" a workflow. Fall back, render, then ask.

Verification note (June 2026). Wheel sources, the triton↔torch table, and the live attention_mode enum below were verified against woct0rdho/triton-windows, woct0rdho/SageAttention releases, and WanVideoWrapper's nodes (see Sources). Versions move fast, so always re-read the live torch/CUDA/python first (commands below) and pick the wheel that matches. Flag anything you can't confirm rather than guessing.


Decide first: do you even need them?

Workflow crashes "No module named 'sageattention'"  ──┐
  or "triton: unavailable" / torch.compile error     ─┤
                                                       ▼
              1. APPLY THE SDPA / NO-COMPILE FALLBACK  → render works now
                                                       ▼
              2. OFFER acceleration, in this order:
                 a. If kitchen INT8 attention is available:
                    "Want --use-ck-attention? No sageattention wheel."
                 b. Else:
                    "Want me to install Triton + SageAttention for ~20–40%
                     faster sampling? It's a version-matched install that
                     touches your torch env — I'll verify torch/CUDA/python
                     first and can roll back."
                                                       ▼
              3. Only on YES → install per-OS below → verify → re-enable
                 sageattn + torch.compile in the workflow.

Mac (no CUDA): skip the install entirely. The answer is always sdpa/MPS.


The safe sdpa / no-compile fallback (DO THIS FIRST)

When Triton/SageAttention aren't installed, make the workflow run unaccelerated but correct by switching attention to sdpa (PyTorch's built-in scaled dot-product attention, always available, no extra deps) and removing the torch.compile/inductor wiring.

WanVideoWrapper (the common case):

  1. On every WanVideoModelLoader set attention_mode to sdpa.
    • Confirmed enum values: sdpa, flash_attn_2, flash_attn_3, sageattn, sparse_sage_attention. The examples ship with sageattn; sdpa is the universal safe one.
  2. Disconnect WanVideoTorchCompileSettings from each loader's compile_args input (or delete/bypass the node). No compile = no Triton needed.
  3. (If present) bypass any WanVideoSetRadialAttention / sparse_sage_attention node. Those also route through SageAttention.

Generic ComfyUI: don't launch with --use-sage-attention; bypass any TorchCompileModel / inductor node.

This costs you speed, not quality. Use create_workflow (action:"modify") / the panel's strip-and-re-point flow to flip the widget and drop the link, then enqueue. Once it renders, offer the install.

Cross-ref: video-extend documents this exact fix as TRAP 5 for the Pusa extension graph (both WanVideoModelLoaders → attention_mode=sdpa, disconnect WanVideoTorchCompileSettings).


Windows install (the priority)

Windows has no official Triton or SageAttention build. You use community prebuilt wheels, and they must match torch + CUDA + python exactly. The panel agent has a shell (Bash for Claude / exec for Codex). Use it to run these in the correct python, never the system python.

Step 1 — find the RIGHT python (NOT system python)

ComfyUI on Windows comes in three flavors; each has its own python whose pip you must target:

Variant Where its python lives How to invoke pip
Desktop (standalone) a standalone-env\ (or venv) beside the install, e.g. C:\Users\<you>\ComfyUI-Installs\ComfyUI\standalone-env\python.exe "<install>\standalone-env\python.exe" -m pip ...
Portable ComfyUI_windows_portable\python_embeded\python.exe "<...>\python_embeded\python.exe" -m pip ...
Manual venv the venv you created (venv\Scripts\python.exe) activate it, then python -m pip ...

Detect it from the live server, the surest way to hit the same python ComfyUI runs on:

  • install_comfyui (action:"environment") / get_system_stats report embedded_python (true → Portable), the python version and the pytorch_version (e.g. 2.10.0+cu130).
  • Inspect the running process's argv (from get_system_stats). The path to main.py reveals the install root; its sibling standalone-env / python_embeded holds the python.
  • Last resort, ask the user for their ComfyUI folder.

Installing into the wrong python (e.g. a global pip install) is the #1 Windows mistake. The package lands somewhere ComfyUI never imports from, so the loader still crashes "No module named 'sageattention'". Always use "<that python>" -m pip.

Step 2 — read the installed torch + CUDA + python

Run with the python you found:

"<python>" -c "import sys, torch; print(sys.version.split()[0], torch.__version__, torch.version.cuda)"

Example live output on this machine: 3.13.12 2.10.0+cu130 13.0, meaning python 3.13, torch 2.10, CUDA line cu130. You'll pick wheels for that triple.

Step 3 — install triton-windows (matched to torch)

Source: woct0rdho/triton-windows (the canonical Windows Triton fork; also on PyPI as triton-windows). The pin is an upper bound. pip resolves the right build for your torch:

"<python>" -m pip install -U "triton-windows<3.7"

Why <3.7: each torch minor pins a Triton minor. Verified table:

PyTorch triton-windows constraint to use
2.7 3.3 "triton-windows<3.4"
2.8 3.4 "triton-windows<3.5"
2.9 3.5 "triton-windows<3.6"
2.10 3.6 "triton-windows<3.7"

(torch 2.6 or older → triton 3.2 or earlier.) Pick the row for your torch.

  • CUDA toolkit: since triton-windows 3.2.0.post11 a minimal CUDA toolchain is bundled in the wheel, so you do NOT need a separate CUDA Toolkit install for Triton itself. (Triton 3.3 through 3.6 bundle the CUDA 12.8 line; works against cu12x/cu13x torch.)
  • MSVC / vcredist: Triton compiles C++ at runtime, so it needs the MSVC toolchain and "Visual C++ Redistributable 2015-2022" present. A TinyCC is bundled (since 3.2.0.post13) which covers many cases, but installing the Visual Studio Build Tools (C++ workload) plus the latest vcredist is the reliable fix if you hit compiler errors (see Traps).
  • Embedded/Portable python only: the embedded distro ships without C headers, so Triton can't compile. Download the matching python_<ver>_include_libs.zip from the triton-windows releases and copy its include and libs (note: libs, not lib) folders into python_embeded\. The Desktop standalone-env usually already has these.

Step 4 — install SageAttention (prebuilt wheel, matched to torch+CUDA)

Prefer the prebuilt wheel. Building from source needs the full CUDA Toolkit (nvcc) plus MSVC and often fails on Windows. Source: woct0rdho/SageAttention releases (Windows wheels; v2 = SageAttention 2.x).

Latest verified tag: v2.2.0-windows.post5, with these four wheels (all cp310-abi3, so they work on python 3.10 through 3.13+ via the stable ABI; one wheel covers all those pythons):

Wheel filename For
sageattention-2.2.0+cu128torch2.9.1.post5-cp310-abi3-win_amd64.whl CUDA 12.8 line, torch 2.9.x
sageattention-2.2.0+cu128torch2.10.0andhigher.post5-cp310-abi3-win_amd64.whl CUDA 12.8 line, torch ≥2.10
sageattention-2.2.0+cu130torch2.9.1.post5-cp310-abi3-win_amd64.whl CUDA 13.0 line, torch 2.9.x
sageattention-2.2.0+cu130torch2.10.0andhigher.post5-cp310-abi3-win_amd64.whl CUDA 13.0 line, torch ≥2.10

Pick by your CUDA line (cu128 vs cu130, from torch.version.cuda: 12.8 → cu128, 13.0 → cu130) and torch minor. For the live machine above (torch 2.10.0+cu130, py3.13) that is the last wheel. Install by full URL:

"<python>" -m pip install "https://github.com/woct0rdho/SageAttention/releases/download/v2.2.0-windows.post5/sageattention-2.2.0+cu130torch2.10.0andhigher.post5-cp310-abi3-win_amd64.whl"
  • The cpXXX-abi3 tag means one wheel works across python ≥ its base (3.10+), so py3.13 is covered even though there's no cp313-specific wheel. This is expected, not a mismatch.
  • Always check the releases page for a newer tag than .post5 and newer torch variants. The filename pattern is stable (+cu<line>torch<minor>...abi3).
  • Don't build from source unless no wheel matches your torch/CUDA at all (then you need CUDA Toolkit plus MSVC; flag the cost to the user first).

Step 5 — verify (Windows)

"<python>" -c "import triton; print('triton', triton.__version__)"
"<python>" -c "import sageattention; print('sageattention OK')"
"<python>" -c "import torch; print('torch still ok', torch.__version__, torch.cuda.is_available())"

All three must succeed and torch must still import with CUDA. If the third line now fails, the install clobbered torch (see Traps, roll back). Then restart ComfyUI and confirm the startup log no longer prints Could not load sageattention / triton: unavailable. Finally re-enable in the workflow: WanVideoModelLoader.attention_mode = sageattn and reconnect WanVideoTorchCompileSettings, enqueue, and confirm it samples (a torch.compile node will spend extra time on the first run compiling, which is normal).


Linux install

Official builds exist here, so this is much simpler:

# Triton: official, pip-installable; torch usually already pulls a matching triton.
pip install -U triton          # or let torch's pinned triton stand; match torch minor

# SageAttention: pip, or build from source for your GPU arch
pip install sageattention      # if a matching wheel exists for your torch/CUDA
  • Use the python that runs ComfyUI (its venv/conda env), the same rule as Windows.
  • Version matching still applies. torch pins a triton minor (e.g. torch 2.9.x ↔ triton 3.5.x, torch 2.10 ↔ 3.6); patch versions within a minor are interchangeable. Don't pip install triton blindly if it would upgrade past what your torch pins.
  • Build deps (if building SageAttention from source): the CUDA Toolkit with nvcc (matching your torch CUDA line), gcc/g++, and the torch headers. If CUDA is in a nonstandard path, export PATH=/usr/local/cuda-<ver>/bin:$PATH so the right nvcc is found. Building is GPU-arch specific and slow, so prefer a matching prebuilt wheel when one exists.
  • Verify exactly as in Windows Step 5 (import triton, import sageattention, torch still imports with CUDA).

Mac

Triton and SageAttention are N/A on Mac. There is no CUDA. Do not attempt to install them. Use PyTorch sdpa attention (the fallback above is the permanent answer), which on Apple Silicon runs on the MPS backend. Set any attention_mode to sdpa, never load torch.compile/inductor (Triton) nodes, and run unaccelerated. If a workflow hard-requires sageattn, edit it to sdpa rather than trying to satisfy the dependency.


Verification checklist (any OS)

  1. import triton succeeds and prints a version matching your torch (table above).
  2. import sageattention succeeds.
  3. torch STILL imports and torch.cuda.is_available() is True (the install didn't break the env).
  4. ComfyUI startup log: no Could not load sageattention, no triton: unavailable.
  5. In the graph: attention_mode = sageattn loads without the No module named 'sageattention' ValueError; a torch.compile/WanVideoTorchCompileSettings node completes its (slow) first-run compile and then samples.
  6. A real render completes and looks correct (SageAttention can rarely introduce NaN/noise on some GPUs; if output degrades vs. sdpa, fall back to sdpa).

Traps

  • Wrong python / global pip. Installing into system python (or the wrong venv) means ComfyUI never imports it, so the loader still crashes. Always "<that exact python>" -m pip; for Portable that's python_embeded\python.exe, for Desktop the standalone-env\python.exe. Verify with pip show sageattention run by that python.
  • torch / CUDA / python wheel mismatch breaks torch. Installing a cu128 wheel on a cu130 torch (or a torch2.9 wheel on torch2.10) can drag in mismatched CUDA DLLs and break import torch itself, or show up as a runtime DLL error. Match cu12812.x / cu13013.0 and the torch minor exactly. Pin and verify: before installing, record pip freeze | grep -i torch; after, confirm torch still imports with CUDA. If broken, roll back (pip install torch==<old>+cu<line> --index-url https://download.pytorch.org/whl/cu<line>, or uninstall the bad wheel) and re-apply the sdpa fallback.
  • Stale Triton cache after a torch/GPU/driver change. Triton caches compiled kernels in ~/.triton (%USERPROFILE%\.triton on Windows). After upgrading torch, swapping GPUs, a driver update, or a failed compile, that cache can go stale and cause torch.compile/SageAttention runs to fail even though the install is correct. Symptoms are recurring compile errors, RuntimeError in a Triton kernel, or a hang on the first sample. Fix: clear the cache and re-run (Triton recompiles fresh):
    # Windows
    rmdir /s /q "%USERPROFILE%\.triton"
    # macOS / Linux
    rm -rf ~/.triton
    
    Safe to delete; it's a pure cache. Do this BEFORE assuming the wheel is wrong (it's a much cheaper fix than a reinstall or roll-back). If it recurs every run, the install is mismatched (see the wheel-mismatch trap above).
  • MSVC missing (Windows Triton). torch.compile/Triton errors like "Microsoft Visual C++ ... required", cl.exe not found, or PY_SSIZE_T_CLEAN/DLL load failures usually mean no MSVC toolchain. Install Visual Studio Build Tools (C++ workload) plus the latest "Visual C++ Redistributable 2015-2022"; copying msvcp140.dll/vcruntime140*.dll into the python folder is the documented last-resort fix.
  • Embedded python has no headers. Portable's python_embeded lacks include/libs, so Triton can't compile and torch.compile fails. Copy the matching python_<ver>_include_libs.zip include and libs (not lib) folders from the triton-windows releases into python_embeded\.
  • py3.13 "no wheel" panic. SageAttention's Windows wheels are cp310-abi3, so one wheel covers py3.10 through 3.13+. The absence of a cp313 filename is normal; do not conclude "no wheel for 3.13." (Source builds, by contrast, can lag on the newest python, another reason to use the abi3 wheel.) Triton-windows does ship py3.13-specific builds.
  • CUDA line confusion. torch.version.cuda is the source of truth: 12.8 → pick cu128 wheels, 13.0cu130. Don't read the system CUDA driver version. Match what torch was built against.
  • "Install can break torch." Treat every acceleration install as risky to the env. Get a working sdpa render first, capture the torch version, install, re-verify torch, and be ready to roll back. Never leave the user with a broken torch and no render.
  • SageAttention numerical artifacts. On some GPUs (reported on H100/Hopper) sageattn produces noise that sdpa doesn't. If a render looks worse than the sdpa version, switch that workflow back to sdpa. Correctness over speed.
  • First torch.compile run is slow. Inductor compiles on the first sample (tens of seconds to minutes); that's expected, not a hang. Subsequent runs are fast. Don't "fix" it by ripping out compile unless it actually errors.

See also

  • video-extend. TRAP 5 is the canonical example. The Pusa graph ships with attention_mode=sageattn and WanVideoTorchCompileSettings; this skill is how you either satisfy or safely fall back from that. Read its TRAP 5 for the exact node-by-node sdpa fix.
  • troubleshooting. "Torch / CUDA Version Errors" and "Missing Nodes" sections for diagnosing a torch env that an install broke.
  • installer-packs. Packs note SageAttention/ Triton requirements in pack.yaml notes/post_install; acceleration is an opt-in post-install step, never baked into a model download.

Sources

1---
2name: triton-sageattention
3description: Install Triton + SageAttention to accelerate ComfyUI (the sageattn attention_mode and inductor torch.compile used by WanVideoWrapper / many video graphs). Windows-first (triton-windows + woct0rdho prebuilt SageAttention wheels matched to torch/CUDA/python into the RIGHT python), plus Linux (official triton + build) and Mac (N/A → sdpa/MPS). Also covers the SAFE sdpa / no-compile fallback so an example that assumes sageattn + torch.compile still runs when these aren't installed (video-extend TRAP 5). Use when a loader crashes with "No module named 'sageattention'" or reports triton unavailable, when asked to speed up Wan/video workflows, or when deciding whether to install acceleration vs. fall back.
4globs:
5 - "**/*.json"
6 - "**/packs/**"
7---
8 
9# Triton + SageAttention (ComfyUI acceleration)
10 
11> See also [`comfyui-launch-flags`](../comfyui-launch-flags/SKILL.md) for the full
12> attention / VRAM / cache flag matrix. Note the Z-Image exception: Z-Image is
13> broken under `--use-sage-attention`, so launch it with
14> `--use-pytorch-cross-attention` instead.
15 
16## Prefer kitchen INT8 attention when it is available
17 
18If `kitchen` action:"status" (or `panel_kitchen`) reports kitchen present and
19`int8_attention_is_available` on this GPU, launch with **`--use-ck-attention`**
20and **skip the sageattention wheel dance**. Kitchen INT8 attention is a ComfyUI
21flag; it does not need a version-matched `sageattention` wheel. Restart
22required, consent-gated like every restart.
23 
24Only fall through to the Triton + SageAttention install below when kitchen INT8
25is **unknown** or **not available**. A failed kitchen probe is unknown, not a no.
26 
27## Overview
28 
29Two optional accelerators that many modern video graphs (especially kijai's
30ComfyUI-WanVideoWrapper) reference by default:
31 
32- SageAttention (`import sageattention`), a quantized attention kernel.
33 Selected via a node's `attention_mode = sageattn` (WanVideoWrapper) or ComfyUI's
34 `--use-sage-attention` startup flag. ~20 to 40% faster sampling on supported
35 NVIDIA GPUs.
36- Triton, the GPU kernel compiler that inductor `torch.compile` needs.
37 WanVideoWrapper's `WanVideoTorchCompileSettings` (and any `torch.compile`/
38 inductor node) compiles the model through Triton for another speedup.
39 
40> **The risk.** Both are version-locked to your exact torch + CUDA + python.
41> A wrong wheel does worse than fail to install. It can break the torch install
42> (mismatched CUDA DLLs, `ImportError`, or silent NaNs). And the failure mode of
43> not having them is a hard crash before any sampling:
44> `ValueError: Can't import SageAttention: No module named 'sageattention'`, or
45> compile errors / `triton: unavailable` in the startup log. This is exactly the
46> [`video-extend`](../video-extend/SKILL.md) TRAP 5.
47 
48> **Therefore the default is to get a working render FIRST with the
49> [sdpa / no-compile fallback](#the-safe-sdpa--no-compile-fallback-do-this-first),
50> then OFFER to install acceleration for speed.** Never run a torch-breaking
51> install unannounced to "fix" a workflow. Fall back, render, then ask.
52 
53> **Verification note (June 2026).** Wheel sources, the triton↔torch table, and
54> the live `attention_mode` enum below were verified against
55> `woct0rdho/triton-windows`, `woct0rdho/SageAttention` releases, and
56> WanVideoWrapper's nodes (see [Sources](#sources)). Versions move fast, so always
57> re-read the live torch/CUDA/python first (commands below) and pick the wheel
58> that matches. Flag anything you can't confirm rather than guessing.
59 
60---
61 
62## Decide first: do you even need them?
63 
64```
65Workflow crashes "No module named 'sageattention'" ──┐
66 or "triton: unavailable" / torch.compile error ─┤
67
68 1. APPLY THE SDPA / NO-COMPILE FALLBACK → render works now
69
70 2. OFFER acceleration, in this order:
71 a. If kitchen INT8 attention is available:
72 "Want --use-ck-attention? No sageattention wheel."
73 b. Else:
74 "Want me to install Triton + SageAttention for ~20–40%
75 faster sampling? It's a version-matched install that
76 touches your torch env — I'll verify torch/CUDA/python
77 first and can roll back."
78
79 3. Only on YES → install per-OS below → verify → re-enable
80 sageattn + torch.compile in the workflow.
81```
82 
83Mac (no CUDA): skip the install entirely. The answer is always sdpa/MPS.
84 
85---
86 
87## The safe sdpa / no-compile fallback (DO THIS FIRST)
88 
89When Triton/SageAttention aren't installed, make the workflow run unaccelerated
90but correct by switching attention to sdpa (PyTorch's built-in scaled
91dot-product attention, always available, no extra deps) and removing the
92`torch.compile`/inductor wiring.
93 
94WanVideoWrapper (the common case):
95 
961. On every `WanVideoModelLoader` set `attention_mode` to `sdpa`.
97 - Confirmed enum values: `sdpa`, `flash_attn_2`, `flash_attn_3`, `sageattn`,
98 `sparse_sage_attention`. The examples ship with `sageattn`; `sdpa` is the
99 universal safe one.
1002. Disconnect `WanVideoTorchCompileSettings` from each loader's `compile_args`
101 input (or delete/bypass the node). No compile = no Triton needed.
1023. (If present) bypass any `WanVideoSetRadialAttention` /
103 `sparse_sage_attention` node. Those also route through SageAttention.
104 
105Generic ComfyUI: don't launch with `--use-sage-attention`; bypass any
106`TorchCompileModel` / inductor node.
107 
108This costs you speed, not quality. Use `create_workflow (action:"modify")` / the panel's
109strip-and-re-point flow to flip the widget and drop the link, then enqueue. Once
110it renders, offer the install.
111 
112> Cross-ref: [`video-extend`](../video-extend/SKILL.md) documents this exact fix
113> as TRAP 5 for the Pusa extension graph (both `WanVideoModelLoader`s →
114> `attention_mode=sdpa`, disconnect `WanVideoTorchCompileSettings`).
115 
116---
117 
118## Windows install (the priority)
119 
120Windows has no official Triton or SageAttention build. You use community
121prebuilt wheels, and they must match torch + CUDA + python exactly. The panel
122agent has a shell (Bash for Claude / `exec` for Codex). Use it to run these in
123the correct python, never the system `python`.
124 
125### Step 1 — find the RIGHT python (NOT system python)
126 
127ComfyUI on Windows comes in three flavors; each has its own python whose `pip` you
128must target:
129 
130| Variant | Where its python lives | How to invoke pip |
131|---|---|---|
132| **Desktop (standalone)** | a `standalone-env\` (or `venv`) beside the install, e.g. `C:\Users\<you>\ComfyUI-Installs\ComfyUI\standalone-env\python.exe` | `"<install>\standalone-env\python.exe" -m pip ...` |
133| **Portable** | `ComfyUI_windows_portable\python_embeded\python.exe` | `"<...>\python_embeded\python.exe" -m pip ...` |
134| **Manual venv** | the venv you created (`venv\Scripts\python.exe`) | activate it, then `python -m pip ...` |
135 
136Detect it from the live server, the surest way to hit the same python ComfyUI
137runs on:
138 
139- `install_comfyui (action:"environment")` / `get_system_stats` report `embedded_python` (true →
140 Portable), the python version and the `pytorch_version` (e.g. `2.10.0+cu130`).
141- Inspect the running process's `argv` (from `get_system_stats`). The path to
142 `main.py` reveals the install root; its sibling `standalone-env` / `python_embeded`
143 holds the python.
144- Last resort, ask the user for their ComfyUI folder.
145 
146> Installing into the wrong python (e.g. a global `pip install`) is the #1
147> Windows mistake. The package lands somewhere ComfyUI never imports from, so the
148> loader still crashes "No module named 'sageattention'". Always use
149> `"<that python>" -m pip`.
150 
151### Step 2 — read the installed torch + CUDA + python
152 
153Run with the python you found:
154 
155```bash
156"<python>" -c "import sys, torch; print(sys.version.split()[0], torch.__version__, torch.version.cuda)"
157```
158 
159Example live output on this machine: `3.13.12 2.10.0+cu130 13.0`, meaning
160python 3.13, torch 2.10, CUDA line cu130. You'll pick wheels for that triple.
161 
162### Step 3 — install **triton-windows** (matched to torch)
163 
164Source: `woct0rdho/triton-windows` (the canonical Windows Triton fork; also on
165PyPI as `triton-windows`). The pin is an upper bound. pip resolves the right
166build for your torch:
167 
168```bash
169"<python>" -m pip install -U "triton-windows<3.7"
170```
171 
172Why `<3.7`: each torch minor pins a Triton minor. Verified table:
173 
174| PyTorch | triton-windows | constraint to use |
175|---|---|---|
176| 2.7 | 3.3 | `"triton-windows<3.4"` |
177| 2.8 | 3.4 | `"triton-windows<3.5"` |
178| 2.9 | 3.5 | `"triton-windows<3.6"` |
179| **2.10** | **3.6** | **`"triton-windows<3.7"`** |
180 
181(torch 2.6 or older → triton 3.2 or earlier.) Pick the row for your torch.
182 
183- CUDA toolkit: since `triton-windows 3.2.0.post11` a minimal CUDA toolchain
184 is bundled in the wheel, so you do NOT need a separate CUDA Toolkit install for
185 Triton itself. (Triton 3.3 through 3.6 bundle the CUDA 12.8 line; works against
186 cu12x/cu13x torch.)
187- MSVC / vcredist: Triton compiles C++ at runtime, so it needs the MSVC
188 toolchain and "Visual C++ Redistributable 2015-2022" present. A TinyCC is
189 bundled (since 3.2.0.post13) which covers many cases, but installing the
190 Visual Studio Build Tools (C++ workload) plus the latest vcredist is the reliable
191 fix if you hit compiler errors (see Traps).
192- Embedded/Portable python only: the embedded distro ships without C headers,
193 so Triton can't compile. Download the matching `python_<ver>_include_libs.zip`
194 from the triton-windows releases and copy its `include` and `libs`
195 (note: `libs`, not `lib`) folders into `python_embeded\`. The Desktop
196 `standalone-env` usually already has these.
197 
198### Step 4 — install **SageAttention** (prebuilt wheel, matched to torch+CUDA)
199 
200Prefer the prebuilt wheel. Building from source needs the full CUDA
201Toolkit (`nvcc`) plus MSVC and often fails on Windows. Source:
202`woct0rdho/SageAttention` releases (Windows wheels; v2 = SageAttention 2.x).
203 
204Latest verified tag: `v2.2.0-windows.post5`, with these four wheels (all
205`cp310-abi3`, so they work on python 3.10 through 3.13+ via the stable ABI; one
206wheel covers all those pythons):
207 
208| Wheel filename | For |
209|---|---|
210| `sageattention-2.2.0+cu128torch2.9.1.post5-cp310-abi3-win_amd64.whl` | CUDA 12.8 line, torch 2.9.x |
211| `sageattention-2.2.0+cu128torch2.10.0andhigher.post5-cp310-abi3-win_amd64.whl` | CUDA 12.8 line, torch ≥2.10 |
212| `sageattention-2.2.0+cu130torch2.9.1.post5-cp310-abi3-win_amd64.whl` | CUDA 13.0 line, torch 2.9.x |
213| `sageattention-2.2.0+cu130torch2.10.0andhigher.post5-cp310-abi3-win_amd64.whl` | **CUDA 13.0 line, torch ≥2.10** |
214 
215Pick by your CUDA line (`cu128` vs `cu130`, from `torch.version.cuda`: `12.8`
216→ cu128, `13.0` → cu130) and torch minor. For the live machine above
217(torch 2.10.0+cu130, py3.13) that is the last wheel. Install by full URL:
218 
219```bash
220"<python>" -m pip install "https://github.com/woct0rdho/SageAttention/releases/download/v2.2.0-windows.post5/sageattention-2.2.0+cu130torch2.10.0andhigher.post5-cp310-abi3-win_amd64.whl"
221```
222 
223- The `cpXXX-abi3` tag means one wheel works across python ≥ its base (3.10+),
224 so py3.13 is covered even though there's no `cp313`-specific wheel. This is
225 expected, not a mismatch.
226- Always check the releases page for a newer tag than `.post5` and newer torch
227 variants. The filename pattern is stable (`+cu<line>torch<minor>...abi3`).
228- Don't build from source unless no wheel matches your torch/CUDA at all (then
229 you need CUDA Toolkit plus MSVC; flag the cost to the user first).
230 
231### Step 5 — verify (Windows)
232 
233```bash
234"<python>" -c "import triton; print('triton', triton.__version__)"
235"<python>" -c "import sageattention; print('sageattention OK')"
236"<python>" -c "import torch; print('torch still ok', torch.__version__, torch.cuda.is_available())"
237```
238 
239All three must succeed and torch must still import with CUDA. If the third
240line now fails, the install clobbered torch (see Traps, roll back). Then restart
241ComfyUI and confirm the startup log no longer prints `Could not load
242sageattention` / `triton: unavailable`. Finally re-enable in the workflow:
243`WanVideoModelLoader.attention_mode = sageattn` and reconnect
244`WanVideoTorchCompileSettings`, enqueue, and confirm it samples (a torch.compile
245node will spend extra time on the first run compiling, which is normal).
246 
247---
248 
249## Linux install
250 
251Official builds exist here, so this is much simpler:
252 
253```bash
254# Triton: official, pip-installable; torch usually already pulls a matching triton.
255pip install -U triton # or let torch's pinned triton stand; match torch minor
256 
257# SageAttention: pip, or build from source for your GPU arch
258pip install sageattention # if a matching wheel exists for your torch/CUDA
259```
260 
261- Use the python that runs ComfyUI (its venv/conda env), the same rule as Windows.
262- Version matching still applies. torch pins a triton minor (e.g. torch 2.9.x
263 ↔ triton 3.5.x, torch 2.10 ↔ 3.6); patch versions within a minor are
264 interchangeable. Don't `pip install triton` blindly if it would upgrade past
265 what your torch pins.
266- Build deps (if building SageAttention from source): the CUDA Toolkit with
267 `nvcc` (matching your torch CUDA line), `gcc/g++`, and the torch headers. If
268 CUDA is in a nonstandard path, `export PATH=/usr/local/cuda-<ver>/bin:$PATH` so
269 the right `nvcc` is found. Building is GPU-arch specific and slow, so prefer a
270 matching prebuilt wheel when one exists.
271- Verify exactly as in Windows Step 5 (`import triton`, `import sageattention`,
272 torch still imports with CUDA).
273 
274---
275 
276## Mac
277 
278Triton and SageAttention are N/A on Mac. There is no CUDA. Do not attempt to
279install them. Use PyTorch sdpa attention (the fallback above is the permanent
280answer), which on Apple Silicon runs on the MPS backend. Set any
281`attention_mode` to `sdpa`, never load `torch.compile`/inductor (Triton) nodes,
282and run unaccelerated. If a workflow hard-requires `sageattn`, edit it to `sdpa`
283rather than trying to satisfy the dependency.
284 
285---
286 
287## Verification checklist (any OS)
288 
2891. `import triton` succeeds and prints a version matching your torch (table above).
2902. `import sageattention` succeeds.
2913. torch STILL imports and `torch.cuda.is_available()` is `True` (the install
292 didn't break the env).
2934. ComfyUI startup log: no `Could not load sageattention`, no `triton: unavailable`.
2945. In the graph: `attention_mode = sageattn` loads without the `No module named
295 'sageattention'` ValueError; a `torch.compile`/`WanVideoTorchCompileSettings`
296 node completes its (slow) first-run compile and then samples.
2976. A real render completes and looks correct (SageAttention can rarely introduce
298 NaN/noise on some GPUs; if output degrades vs. sdpa, fall back to sdpa).
299 
300---
301 
302## Traps
303 
304- **Wrong python / global pip.** Installing into system python (or the wrong
305 venv) means ComfyUI never imports it, so the loader still crashes. Always
306 `"<that exact python>" -m pip`; for Portable that's `python_embeded\python.exe`,
307 for Desktop the `standalone-env\python.exe`. Verify with `pip show sageattention`
308 run by that python.
309- **torch / CUDA / python wheel mismatch breaks torch.** Installing a `cu128` wheel
310 on a `cu130` torch (or a torch2.9 wheel on torch2.10) can drag in mismatched CUDA
311 DLLs and break `import torch` itself, or show up as a runtime DLL error. Match
312 `cu128``12.x` / `cu130``13.0` and the torch minor exactly. Pin and verify:
313 before installing, record `pip freeze | grep -i torch`; after, confirm torch
314 still imports with CUDA. If broken, roll back (`pip install
315 torch==<old>+cu<line> --index-url https://download.pytorch.org/whl/cu<line>`,
316 or uninstall the bad wheel) and re-apply the sdpa fallback.
317- **Stale Triton cache after a torch/GPU/driver change.** Triton caches compiled
318 kernels in `~/.triton` (`%USERPROFILE%\.triton` on Windows). After upgrading torch,
319 swapping GPUs, a driver update, or a failed compile, that cache can go stale and
320 cause `torch.compile`/SageAttention runs to fail even though the install is
321 correct. Symptoms are recurring compile errors, `RuntimeError` in a Triton
322 kernel, or a hang on the first sample. Fix: clear the cache and re-run (Triton
323 recompiles fresh):
324 ```
325 # Windows
326 rmdir /s /q "%USERPROFILE%\.triton"
327 # macOS / Linux
328 rm -rf ~/.triton
329 ```
330 Safe to delete; it's a pure cache. Do this BEFORE assuming the wheel is wrong
331 (it's a much cheaper fix than a reinstall or roll-back). If it recurs every run,
332 the install is mismatched (see the wheel-mismatch trap above).
333- **MSVC missing (Windows Triton).** `torch.compile`/Triton errors like "Microsoft
334 Visual C++ ... required", `cl.exe not found`, or `PY_SSIZE_T_CLEAN`/DLL load
335 failures usually mean no MSVC toolchain. Install Visual Studio Build Tools (C++
336 workload) plus the latest "Visual C++ Redistributable 2015-2022"; copying
337 `msvcp140.dll`/`vcruntime140*.dll` into the python folder is the documented
338 last-resort fix.
339- **Embedded python has no headers.** Portable's `python_embeded` lacks
340 `include`/`libs`, so Triton can't compile and `torch.compile` fails. Copy the
341 matching `python_<ver>_include_libs.zip` `include` and `libs` (not `lib`)
342 folders from the triton-windows releases into `python_embeded\`.
343- **py3.13 "no wheel" panic.** SageAttention's Windows wheels are `cp310-abi3`, so
344 one wheel covers py3.10 through 3.13+. The absence of a `cp313` filename is normal;
345 do not conclude "no wheel for 3.13." (Source builds, by contrast, can lag on the
346 newest python, another reason to use the abi3 wheel.) Triton-windows
347 does ship py3.13-specific builds.
348- **CUDA line confusion.** `torch.version.cuda` is the source of truth: `12.8`
349 pick `cu128` wheels, `13.0``cu130`. Don't read the system CUDA driver
350 version. Match what torch was built against.
351- **"Install can break torch."** Treat every acceleration install as risky to the
352 env. Get a working sdpa render first, capture the torch version, install,
353 re-verify torch, and be ready to roll back. Never leave the user with a broken
354 torch and no render.
355- **SageAttention numerical artifacts.** On some GPUs (reported on H100/Hopper)
356 `sageattn` produces noise that `sdpa` doesn't. If a render looks worse than the
357 sdpa version, switch that workflow back to `sdpa`. Correctness over speed.
358- **First torch.compile run is slow.** Inductor compiles on the first sample
359 (tens of seconds to minutes); that's expected, not a hang. Subsequent runs are
360 fast. Don't "fix" it by ripping out compile unless it actually errors.
361 
362---
363 
364## See also
365 
366- [`video-extend`](../video-extend/SKILL.md). TRAP 5 is the canonical
367 example. The Pusa graph ships with `attention_mode=sageattn` and
368 `WanVideoTorchCompileSettings`; this skill is how you either satisfy or safely
369 fall back from that. Read its TRAP 5 for the exact node-by-node sdpa fix.
370- [`troubleshooting`](../troubleshooting/SKILL.md). "Torch / CUDA Version Errors"
371 and "Missing Nodes" sections for diagnosing a torch env that an install broke.
372- [`installer-packs`](../installer-packs/SKILL.md). Packs note SageAttention/
373 Triton requirements in `pack.yaml` `notes`/`post_install`; acceleration is an
374 opt-in post-install step, never baked into a model download.
375 
376## Sources
377 
378- **Official:** triton-windows https://github.com/woct0rdho/triton-windows and SageAttention Windows wheels https://github.com/woct0rdho/SageAttention/releases; ComfyUI `--use-ck-attention` in `comfy/cli_args.py`; comfy-kitchen `int8_attention_is_available()` at https://github.com/Comfy-Org/comfy-kitchen
379- **Empirical:** sdpa / no-compile fallback, wheel-matching recipes, and WanVideoWrapper attention_mode notes from observed loader crashes.
380 

Discussion

Alternatives

Also in Illustration & art