Nodes/ComfyUI-Lightning/Apply MBCache and Skip Blocks for Sana
ComfyUI Node

Apply MBCache and Skip Blocks for Sana

Caching for NVIDIA's fast little DiT

By shenduldh·Created 2 years ago·Updated about a year ago· 225
Apply MBCache and Skip Blocks for Sana
  • model
  • MODEL
skip_blocks14,17
default_cache_threshold0.0002
block_cache_thresholds
start0.00
end1.00
max_consecutive_cache_hits-1

Sana is already the fast option - NVIDIA's small diffusion transformer that people have compared to "the SD 1.5 days" for how quickly it produces a 1024x1024 image. This node exists anyway, because "already fast" and "as fast as it could be" aren't the same thing, and MBCache's per-block caching trick works on Sana's architecture too. The README's headline claim for the whole Sana integration is 1024x1024 images in under 2 seconds - this node is part of how that number gets hit.

What it is and why you'd reach for it

This is the Sana-specific sibling of Apply MBCache and Skip Blocks, which does the same job for Flux. The underlying idea is identical: some blocks in the transformer barely change their contribution from one denoising step to the next, so instead of recomputing every block every step, you cache the output and reuse it when the step is similar enough to the last one. What's different is the architecture underneath it. Flux has the DoubleStreamBlocks/SingleStreamBlocks split from its dual-stream MMDiT design; Sana doesn't, so this node works off a single flat block list instead of two.

How it works

Sana's transformer blocks are numbered as one sequence rather than split into two stream types. You give it a list of block indices to skip outright, and a caching threshold - either one shared default or per-block overrides - that governs how aggressively steps get reused instead of recomputed.

The inputs and outputs that matter

  • skip_blocks (string, default "14,17") - the flat list of block indices to skip entirely, Sana's equivalent of the Flux nodes' dual skip lists. The default is the author's own tuned starting point.
  • default_cache_threshold (float, 0–1, default 0.0002) - notice how much smaller this is than the Flux version's 0.25 default. Sana's activations operate on a different scale, so don't reuse Flux intuition here - start from the default and nudge it, don't port a Flux threshold over.
  • block_cache_thresholds (string, default empty) - per-block override, same pattern as the Flux MBCache node: leave blank to use the single default threshold everywhere, or fill in specific blocks you want tuned differently.
  • start / end (0–1, defaults 0 and 1) - the portion of the sampling schedule caching is active over.
  • max_consecutive_cache_hits (int, default -1) - caps how many consecutive steps can reuse the cache before a fresh computation is forced.

Output is a patched MODEL, wired into your Sana sampler.

How to install it

  • ComfyUI Manager - search "ComfyUI-Lightning", install, restart.
  • Manual - cd ComfyUI/custom_nodes && git clone https://github.com/shenduldh/ComfyUI-Lightning, then restart.

This node needs a Sana model loaded to do anything, which means the Sana-specific downloads from the README: the Sana diffusion .pth from the Model Zoo into models/diffusion_models, the Gemma text encoder folder into models/text_encoders, and the DCAE VAE .safetensors into models/vae. See the pack's Sana loader nodes for the loading side of that - this node only patches the model once it's loaded.

Common issues & troubleshooting

I set the threshold like I would for Flux and quality tanked. That's the trap - default_cache_threshold's Sana default is 0.0002, four orders of magnitude smaller than Flux MBCache's 0.25. Reset to default and adjust in small steps from there rather than assuming the two nodes share a scale.

Speedup feels marginal given how fast Sana already is. That's somewhat expected - Sana is already sub-2-second per the README's own benchmark, so there's less headroom to claw back than on something as heavy as Flux. If your bottleneck is elsewhere (VAE decode, text encoding), this node alone won't move the needle much.

Output looks noticeably different from an uncached run. Try start/end narrowed to the middle of the schedule rather than the whole thing, or drop default_cache_threshold further - Sana's small models don't have as much redundancy to spare as a 12B-parameter Flux, so being conservative here is the safer default.

CategoryLightning/Sana

Inputs (7)

NameTypeDefaultDescription
modelMODEL
skip_blocksSTRING14,17
default_cache_thresholdFLOAT0.00020–1
block_cache_thresholdsSTRING
startFLOAT0.000–1
endFLOAT1.000–1
max_consecutive_cache_hitsINT-1

Outputs (1)

NameTypeDescription
MODELMODEL