Nodes/KJNodes for ComfyUI/WanVideo Mem Eff Sage Attention Patch
ComfyUI Node Runs on cloud

WanVideo Mem Eff Sage Attention Patch

Cut Wan attention VRAM

By kijai·Created 3 years ago·Updated 2 days ago· 3,011
WanVideo Mem Eff Sage Attention Patch
  • model
  • model

Attention is where video models eat VRAM. The sequence a video transformer attends over is huge (all those frames, all those tokens), and the attention step's memory scales badly with it. This node swaps Wan's self-attention over to a custom, memory-efficient SageAttention path to bring that peak down. It's one of the tools you stack when a Wan generation, especially a heavy edit, is spiking right past your card's limit.

It's from kijai's KJNodes. The KB records a user pairing this node with Wan Chunk FeedForward and saving "almost 4GB" of peak VRAM on a 1080p object-removal job, so this isn't a rounding error, it's real headroom on a consumer card.

How it works

SageAttention is a quantized/optimized attention kernel. This node activates a custom SageAttention implementation on Wan's self-attention specifically, overriding the model's normal attention mode to reduce peak memory. Model in, patched model out, wire it before your sampler.

Two warnings straight from the node's own description, and they matter:

  • It's EXPERIMENTAL. Treat it as a "make it fit" lever, not a default.
  • It requires the latest SageAttention version installed, and that's the part that bites people (see below).

The inputs and outputs that matter

  • model - the Wan model to patch. Patched model comes back out.

That's the entire interface, no tuning knobs. It either engages the efficient attention path or it doesn't. The design is deliberately dead simple: drop it in the model chain and it does its one job.

Installing it

The node ships with KJNodes, but the hard part is the SageAttention library, which is not installed by KJNodes' requirements.txt and does not always come as a prebuilt wheel. That's the real install story here.

  • KJNodes itself: ComfyUI Manager → search KJNodes for ComfyUI → install → restart. Or git clone https://github.com/kijai/ComfyUI-KJNodes into custom_nodes and pip install -r requirements.txt.
  • SageAttention: this is the one that's genuinely fiddly. On Linux, pip install sageattention often works for v1, but the newer versions frequently need compiling from source (git clone, then build), and there's often no prebuilt wheel. Community consensus is blunt about it, one widely-upvoted comment on a SageAttention release was simply "And still nobody knows how to get it running." Windows portable users typically hunt down a precompiled .whl matching their exact Python/CUDA/torch versions.

Common issues

ModuleNotFoundError: No module named 'sageattention'. The library isn't installed (or isn't installed into the same Python ComfyUI runs). This is the single most common failure with SageAttention-dependent nodes, people install KJNodes and assume the dependency came with it. It didn't. Install SageAttention into ComfyUI's environment specifically (in the portable build, use python_embeded\python.exe -m pip ...), then restart.

A stale reference to sageattention lingers after you remove the node. Reported in the wild: even after uninstalling/disabling the KJNodes patch, a workflow can still try to call the sageattention path (the attention override having been baked into a saved graph or a still-patched model). Reload ComfyUI fresh and rebuild the model chain from the loader so no patched model is cached.

Version mismatch. The node wants the latest SageAttention. An old version can load but misbehave or error at attention time. Match the library version to what the node expects.

Use it with, not instead of, the other memory nodes. This attacks attention memory; Wan Chunk FeedForward attacks the feedforward activations. Stack them (plus fp8 and block swapping) when you're really up against the wall, that's how the big VRAM savings actually add up.

CategoryKJNodes/wan

Inputs (1)

NameTypeDefaultDescription
modelMODEL

Outputs (1)

NameTypeDescription
modelMODEL