Nifty Wan Video SLG
STG guidance for CFG=1, flicker be damned
- model
- MODEL
SLG stands for Skip Layer Guidance, but the technique this node wraps is really STG - Spatiotemporal Skip Guidance, from a CVPR 2025 paper (arxiv 2411.18664). Same family as NAG: guidance that isn't CFG. Where NAG pushes against a negative reference in attention space, STG measures what changes when you skip part of the model and steers with that difference. It works at CFG=1, which is the whole point - the fastest, most distilled Wan setups (LightX2V, few-step Lightning) run at CFG=1 and have no guidance budget left. STG gives them steering back, with no TeaCache required.
This is Nifty's WAN-native implementation, forked from KJNodes and reworked. You feed it your Wan model, it returns a patched model, and the sampler handles the rest.
How it works
The node patches a post_cfg_function onto the model. On every denoising step, it runs a second conditional pass through the model where your chosen blocks have been sabotaged - and the difference between the sabotaged output and the normal output becomes the correction, scaled and added to the result. It's guidance by subtraction: "here's what the model thinks without these blocks; steer toward the difference."
Two sabotage modes, and this is the main design decision you'll make:
- STG-A (default) - zeroes only the self-attention in the chosen blocks. Cross-attention and the feed-forward network still run. Less perturbation, lower flicker risk. Recommended for Wan at few steps.
- STG-R - the entire block becomes identity. Stronger correction, but noticeably more prone to flicker at 2–3 steps.
Inputs that matter
- model - the Wan model to patch. enabled - master switch; when
Falsethe model passes through untouched. - blocks - comma-separated block indices, defaults to
9, 10, and supports ranges like9-11. WAN 2.2 has 40 layers, and blocks 9/10 are the empirically recommended targets. The tooltip's advice for flicker is golden: start with10alone. Fewer blocks = safer. - mode - STG-A or STG-R, above.
- scale - guidance strength, default
1.0. For LightX2V (2–3 HN steps), STG-A maxes out around 2.0–2.5 and STG-R around 1.5 before quality falls apart. - start_percent / end_percent - the active range as a fraction of the full denoising schedule (HN + LN combined, so the percentages are absolute). Default is fully active (
0.0→1.0). The formula to remember:end_percent = HN_steps / total_steps. A 4-step run split 2+2 means HN does half the work, so set0.5to confine STG to the high-noise pass where it has the most structural impact.
Optional extras: rescaling_scale (default 0) normalizes the correction's std against the normal prediction's std before scaling - set 0.3–0.5 if high scale makes it flicker. scale_end (default 0, disabled) linearly fades the scale from scale at the start to scale_end at the end, so you can run strong early and back off as noise clears.
Output is a single MODEL - the patched model, straight to your sampler.
Wiring it in
The workflow shape is: Wan model → Nifty Wan Video SLG → sampler at CFG=1. That's the entire integration. It composes with NAG too - different guidance families, and plenty of people run both - but start with one. SLG is the one that pairs with distilled/few-step models because it doesn't need a negative slot at all.
Installing it
Part of Nifty Nodes for ComfyUI (Stibo/comfyui-nifty-nodes). ComfyUI Manager → search "Nifty Nodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Stibo/comfyui-nifty-nodes
Restart. Needs a current ComfyUI (v3 API, comfy_api.latest) and a Wan 2.1/2.2 model. No pip packages, no model downloads from the pack.
The honest troubleshooting bit
STG's main failure mode is flicker, and it's fixable in this order: fewer blocks (10 alone), lower scale, then rescaling_scale at 0.3–0.5, then STG-A if you were on STG-R. If it's still dancing, your end_percent is probably too high - confine it to the HN phase. That ladder handles nearly every "it flickers" report, and it's all in the tooltips if you forget.
Inputs (9)
| Name | Type | Default | Description |
|---|---|---|---|
| enabled | BOOLEAN | true | When false, node is a no-op and passes the input model unchanged. |
| model | MODEL | — | |
| blocks | STRING | 9, 10 | Comma-separated block indices. Supports ranges: '9-11' = 9, 10, 11. WAN 2.2 = 40 layers. Blocks 9, 10 empirically recommended. Fewer blocks = safer. Start with '10' alone if flickering occurs. |
| mode | COMBO | STG-A (default): zeros self-attention only — cross-attn and FFN still run. Less perturbation, lower flickering risk. Recommended for WAN + few-step. STG-R: entire block becomes identity. Stronger but more flickering at 2-3 steps. | |
| scale | FLOAT | 1.000–10 | Guidance strength. Works at CFG=1. LightX2V (2-3 HN steps): STG-A max ~2.0–2.5, STG-R max ~1.5. Use rescaling_scale to push higher without flickering. |
| start_percent | FLOAT | 0.0000–1 | Start of active range as fraction of the FULL denoising schedule (HN + LN samplers combined). Percentages are ABSOLUTE. |
| end_percent | FLOAT | 1.0000–1 | End of active range. Formula: HN_steps / total_steps. 4-step (2+2): 0.5. 6-step (3+3): 0.5. Default 1.0 = active for all sigmas this model processes. |
| rescaling_scaleopt | FLOAT | 0.000–1 | Normalizes correction std to match cond_pred std before scale. 0.0 = disabled. 0.3–0.5 = recommended if scale causes flickering. 1.0 = fully normalized. |
| scale_endopt | FLOAT | 0.000–10 | Sigma-adaptive scale: linearly interpolates from 'scale' (at sigma_start) to 'scale_end' (at sigma_end). 0.0 = disabled (constant scale). Example: scale=2.0, scale_end=0.5 — stronger guidance at high noise, fading toward low noise. Useful since STG has most structural impact early. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |