Nodes/flow2-wan-video/Wan Model Patcher
ComfyUI Node

Wan Model Patcher

SageAttention, TeaCache and compile in one node

By jinnin0105·Created about a year ago·Updated about a year ago· 17
Wan Model Patcher
  • model
  • patch
  • model
sage_attention
teacache
compile_model

Wan Model Patcher (WanVideoModelPatcher_F2) is where the flow2-wan-video pack's speed lives. It takes the model from the loader, applies the sampling tweaks from the Configure node, and then - if you ask it to - straps on the three accelerators the Wan community actually runs: SageAttention, TeaCache, and torch.compile. One dropdown each, all in a row. This is the node that turns a 40-minute clip into a 10-minute one, or a 10-minute one into a "why is it skipping steps" one, depending on what you enable.

How it works

First, the always-on part: it applies the Configure node's flow_shift to the model using ComfyUI's ModelSamplingSD3 patch, then optionally applies enhance_strength (the FETA temporal-attention enhancement), skip_layer guidance, and cfg_zero_steps (the CFG-Zero star trick borrowed from KJNodes). None of that is optional to opt out of via this node - those come from the Configure node's advanced settings, and this node is the mechanism that actually patches them in.

Then the three accelerators, which are the reason you're reading this:

  • sage_attention - disabled / auto / triton. It swaps ComfyUI's attention function for the SageAttention implementation. auto uses the standard sageattn kernel; triton uses the int8-QK/fp16-PV Triton variant. Big speedup on cards it supports, and the single most painful dependency in the pack, because SageAttention needs Triton - on Windows that's a genuinely notorious install. The pack ships triton_installer scripts in the repo (they remove old Triton/SageAttention, install Visual Studio Build Tools, then the triton-windows packages) precisely because everyone kept getting this wrong.
  • teacache - disabled / normal / retention. Temporal caching that skips redundant transformer work across similar frames. The pack ships per-model coefficients for Wan T2V 1.3B/14B and I2V 480p/720p 14B, and retention is the variant that keeps more detail at a slightly higher cost. Moderate speedup, minor quality impact - the community notes disabling TeaCache improves face consistency at the cost of speed, so treat it as a lever, not a free lunch.
  • compile_model - disabled / default. torch.compile per transformer block with the inductor backend. Real per-frame speedup after a one-time compile overhead, and the pack routes the inductor/triton cache dirs into your ComfyUI folder so recompiles stay warm.

One quirk to know: skip_layer guidance from the Configure node requires TeaCache to be enabled - the source raises a ValueError if it isn't, because it reads per-step timing out of the TeaCache transformer options. If you enable skip-layer and get an error, that's what it's telling you.

Wiring it up

Inputs: model (from the loader), patch (from the Wan Configure node - without it, the node returns the model untouched), then the three dropdowns. Output is a single model, which feeds the Wan Sampler. If patch isn't connected, the whole node is a no-op, which is a confusing failure mode for beginners - the Configure node isn't optional.

Installing

Part of the flow2-wan-video pack (ComfyUI Manager search flow2-wan-video, or git clone https://github.com/Flow-two/flow2-wan-video.git into custom_nodes + pip install -r requirements.txt). Base requirements are light, but SageAttention/Triton are not in requirements.txt - that's why the triton_installer folder exists. Linux users mostly get Triton via their package manager; Windows users get the script.

Troubleshooting

  • SageAttention produces corrupted output (matrix-code lines, black frames) on some models - the KB has it documented for Z-Image Base, and the pattern is "Sage broke my output." Disable it here and the problem goes away.
  • Triton missing → the patcher just prints an error and falls back to stock attention; nothing explodes, you just don't get the speedup.
  • TeaCache on a model it has no coefficients for (e.g., an unusual fine-tune) prints teacache model_type is None and skips - harmless.
  • And the pack-wide one: this pack monkey-patches global attention functions when its SageAttention path runs, which is exactly the kind of global surgery that has broken native ComfyUI Wan workflows for other users. If your other workflows misbehave while this pack is installed, that's the suspect.
CategoryFlow2/Wan 2.1

Inputs (5)

NameTypeDefaultDescription
modelMODEL
patchPATCH
sage_attentionCOMBO3 options: disabled, auto, triton
teacacheCOMBO3 options: disabled, normal, retention
compile_modelCOMBO2 options: disabled, default

Outputs (1)

NameTypeDescription
modelMODEL