ComfyUI Node

MagCache for SDXL

Free-ish speed by skipping UNet steps — once you've calibrated

By Shiba-2-shiba·Created about a year ago·Updated 11 months ago· 7
MagCache for SDXL
  • model
  • MODEL
enabledtrue
Magcache_thresh0.10
Magcache_K2
retention_ratio0.20
exclude_last_steptrue

This node makes SDXL generation faster by not running the UNet at all on some steps. No distilled model, no reduced step count, no CFG trickery - it just notices that a few steps in the denoise barely change anything, and reuses the previous step's output instead. It's an SDXL-only fork of Zehong-Ma's ComfyUI-MagCache, the mid-2025 "successor of TeaCache" line of step-skipping caches.

Set expectations now: it's experimental, it's fiddly, and the pack's own author says Comfy-WaveSpeed gave better results in their tests. So why would you reach for it? Because the acceleration is a pure win on your existing workflow - same sampler, same steps, same CFG - just fewer wasted UNet calls. LCM and Turbo buy you speed by changing the model; MagCache changes nothing about what you generate.

How it works

Denoising is mostly redundant. Steps 10–18 of a 25-step SDXL run usually move the image less than the first few do, and the UNet's residual output from step N is a great cheap stand-in for step N+1. MagCache exploits exactly that.

The flow is two-phase. First you run a calibration pass (the Calibrate MagCache for SDXL node) that records, for every step, the ratio of the residual magnitude between consecutive steps. Then this node reads those ratios, and during sampling it skips a UNet call whenever the accumulated error stays under a threshold - capped so it can't skip forever. On a skip, it returns the cached residual from the previous step; otherwise it runs the real forward pass and refreshes the cache. Steps at the very start (where structure locks in) are never skipped, and neither is the last step unless you tell it otherwise.

The inputs that matter

  • model - wire this from a CheckpointLoaderSimple. That loader specifically: the pack monkey-patches it on import to learn the model's filename, and if you use UNETLoader or a custom loader it can't, so it quietly disables itself.
  • enabled (default true) - a handy off switch that restores the original UNet forward and passes the model through untouched.
  • Magcache_thresh (default 0.1, 0–1) - how much accumulated error you'll tolerate before forcing a real UNet call. Lower = safer but fewer skips.
  • Magcache_K (default 2, 1–10) - the hard cap on consecutive skipped steps. This is your speed knob: push to 3–4 and you'll see it; push further and watch for artifacts.
  • retention_ratio (default 0.2) - the first 20% of steps never get cached, which protects the rough composition.
  • exclude_last_step (default true) - the final step is where fine detail lands; leave it on.

The single output is a MODEL, which you wire straight into your KSampler just like you would the loader's.

Installing it

No dependencies, no model files to download - it's plain Python on top of what ComfyUI already has. Either search "MagCache" in ComfyUI Manager, or:

cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/Shiba-2-shiba/ComfyUI-Magcache-for-SDXL.git

Then restart ComfyUI.

Where people get burned

  • It does nothing without calibration data. If there's no matching JSON in the pack's magcache_data folder, the node prints a warning and hands back the model unpatched. No crash, no error - just no speedup.
  • The calibration is per model and per sampler. Switch samplers on the same checkpoint and the ratios are stale; delete the JSON and recalibrate.
  • The loader patch is fragile. Any custom model loader sidesteps it and silently disables MagCache. If you see "Could not find patched model name" in the console, that's why.
  • It's genuinely experimental. Expect quality to soften on aggressive settings - that's the same trade every cache scheme makes, and it's why the author points you at WaveSpeed for production.
CategoryMagCache-SDXL

Inputs (6)

NameTypeDefaultDescription
modelMODEL
enabledBOOLEANtrue
Magcache_threshFLOAT0.100–1
Magcache_KINT21–10
retention_ratioFLOAT0.200–1
exclude_last_stepBOOLEANtrue

Outputs (1)

NameTypeDescription
MODELMODEL