Nodes/ComfyUI-HSWQ-Quantizer/SDXL HSWQ Calibration (DualMonitor V2)
ComfyUI Node

SDXL HSWQ Calibration (DualMonitor V2)

Teach HSWQ which SDXL layers matter — then convert smarter

By Shiba-2-shiba·Created 7 months ago·Updated 5 months ago· 3
SDXL HSWQ Calibration (DualMonitor V2)
  • model
  • model
save_folder_namehswq_stats
file_prefixsdxl_calib
session_idsession_01
save_every_steps50
reset_sessionfalse

This node is the first half of the HSWQ pipeline, and it's a strange one on purpose: you don't convert anything with it. Instead, you drop it into your SDXL workflow, generate normally, and it quietly watches every Linear and Conv2d layer in the UNet, recording which ones actually matter. The stats file it writes is the fuel for the pack's FP8 converter - the thing that lets it keep the sensitive layers in fp16 and only crush the rest to fp8.

Why bother, when you could just load a plain fp8 checkpoint and be done? Because a blanket cast doesn't know anything about your model or your prompts. HSWQ (Hybrid Sensitivity Weighted Quantization, originally by ussoewwin) is the argument that sensitivity isn't uniform across layers - a handful of them do disproportionate work, and if you measure which ones on your actual usage, you can keep those in full precision and still save most of the VRAM. That's the whole point of the calibration step. If your SDXL barely fits and you want the last drop of quality out of a quantization, this is the route; if you just want small-and-fine with no ceremony, a plain fp8 file gets you 90% of the way for far less effort.

How it works

The node hooks into the UNet's forward pass - Linear and Conv2d layers only, nothing else - and tracks two signals per layer:

  • Output sensitivity: the variance of each layer's output, accumulated in FP32 as a Python float so precision doesn't wash out over thousands of steps.
  • Input importance: the mean absolute value per input channel, which tells the converter which channels the layer actually leans on.

It uses a wrapper-based enable/disable so normal generation doesn't pay for the instrumentation - the hooks only fire while that model's forward runs, and stale hooks from previous runs are cleaned up automatically. Stats accumulate across runs into a session keyed by your folder/prefix/session names, cached in memory, restored from disk, and checkpointed atomically (a .tmp write followed by os.replace, so a crash mid-save can't corrupt the file) every save_every_steps.

Inputs and outputs

The only things you'll normally touch:

  • model - your SDXL UNet, wired onward into your KSampler. It's a pass-through; generation looks unchanged.
  • save_folder_name (default hswq_stats) and file_prefix (default sdxl_calib) - these become the output path.
  • session_id (default session_01) - part of the filename and the session key.
  • save_every_steps (default 50) - how often it checkpoint to disk. Lower if you're nervous about crashes, higher if you want less I/O noise.
  • reset_session - leave this off unless you mean it. With it true, every run wipes the session's accumulated stats and starts over; that's a "I want to recalibrate from scratch" button, not a daily setting.

Your stats land in output/<save_folder_name>/<file_prefix>_<session_id>.pt inside ComfyUI's output directory - so with defaults, output/hswq_stats/sdxl_calib_session_01.pt. The single model output goes to your KSampler; there's nothing else to wire.

Workflow and gotchas

Install once for the whole pack (ComfyUI Manager → search "HSWQ", or git clone https://github.com/Shiba-2-shiba/ComfyUI-Unofficial-HSWQ-QuantizerHSWQ-Quantizer into custom_nodes, restart). Then run a good number of generations with the node in the graph - the README suggests ~256 samples. Variety matters more than count: if you calibrate only on one style of prompt, that's what the model gets optimized for.

Two things bite people. First, the node has to actually execute - if you don't see [HSWQCollector] Armed N hooks in the console, it's not in the path and no stats are being collected. Second, keep the session names identical when you later feed them to the converter (hswq_stats / sdxl_calib / session_01), because a mismatch means the converter looks for a file that isn't there - and in this pack, a missing stats file fails silently, returning your model unconverted. If in doubt, check the console summary, not the preview.

CategoryQuantization

Inputs (6)

NameTypeDefaultDescription
modelMODEL
save_folder_nameSTRINGhswq_stats
file_prefixSTRINGsdxl_calib
session_idSTRINGsession_01
save_every_stepsINT501–10000
reset_sessionBOOLEANfalse

Outputs (1)

NameTypeDescription
modelMODEL