Calibrate MagCache for SDXL
The calibration node MagCache for SDXL won't work without (and what it's actually doing)
- model
- MODEL
This is the boring half of the MagCache for SDXL trick, but it's the mandatory one. The MagCache for SDXL node will not skip a single step until you've run this first. One input, one output, zero settings - the whole job is to babysit a single generation and write down what it learns.
What it does
It's a pass-through node: give it a MODEL and it hands back the same model, so you drop it between your loader and sampler like a patch cable. But during that run it's secretly recording something. It patches the UNet's forward pass to compute, at every step, the ratio of the residual output's magnitude compared to the previous step - separately for the conditional and unconditional passes (that's the cond_or_uncond split you'll see in the console logs). When the sampler finishes, it interleaves those ratios and writes them to a JSON file in the pack's magcache_data folder.
That JSON is the "calibration" - a fingerprint of how redundant your model's denoising actually is at each step. The MagCache node later reads it to decide when it's safe to skip a UNet call. The ratios are stored per-step but get interpolated at load time, so a calibration run at 20 steps still works if you later generate at 25.
The workflow
CheckpointLoaderSimple → Calibrate MagCache for SDXL → KSampler → VAE Decode
Then just run it once, to completion. You'll see a line in the console like [MagCache-SDXL] Calibration data saved to ... - that's your cue. The JSON is keyed by a hash of the checkpoint filename, so each model gets its own file, and the file lives inside the node's own folder, not your output directory.
Gotchas that will trip you
- Use
CheckpointLoaderSimple. The pack learns the model's name by monkey-patching that one loader on import. Load viaUNETLoaderor a custom loader and it can't tell which model it calibrated, so MagCache stays disabled. - One sampler, one JSON. The ratio fingerprint depends on the sampler's sigma schedule. Switch from e.g. DPM++ 2M to Euler and the old ratios are meaningless - delete the JSON from
magcache_dataand recalibrate. The README is explicit about this, and it's the most common way people get confusing results. - The calibration only matters if you finish. If you interrupt mid-run, no file gets written.
Once the JSON exists, swap this node out for the actual MagCache node and generate normally. And take the README's own advice to heart: the author notes Comfy-WaveSpeed beat this node in their experiments, so calibration is only worth it if you specifically want this cache approach.
Install
Same as the rest of the pack - zero dependencies, zero downloads:
cd /path/to/ComfyUI/custom_nodes
git clone https://github.com/Shiba-2-shiba/ComfyUI-Magcache-for-SDXL.git
Or search "MagCache" in ComfyUI Manager. Restart, and both nodes appear under the MagCache-SDXL category.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| model | MODEL | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| MODEL | MODEL | — |