Nodes/ComfyUI-GPTQ-Calibration/Calibration Data Collector
ComfyUI Node

Calibration Data Collector

Collect per-layer Hessians (and optionally activation amax) for external quantization. No weights are modified.

By ThunderFun·Created 2 months ago·Updated about a month ago· 0
Calibration Data Collector
  • model
  • conditioning
  • calibration_path
num_steps4
num_samples16
seed0
hessian_block_size128
hessian_formatdlr_nystrom
dlr_rank128
collect_amaxtrue
output_path/tmp/ComfyUI/output/calibration.pt
latent_height64
latent_width64
convrotfalse
rot_size256
rpbhfalse
rpbh_seed42
rpbh_block_size256
permuquantfalse
pisofalse
sigma_min0.00
sigma_max1.00
force_cpu_hookfalse
timestep_channel_amaxfalse
timestep_buckets4
Categorymodel/quantization

Inputs (24)

NameTypeDefaultDescription
modelMODELLoaded diffusion model (FP16/BF16/FP32).
conditioningCONDITIONINGPre-encoded conditioning from CLIPTextEncode or similar.
num_stepsINT41–50Denoising steps per sample.
num_samplesINT161–4096Independent samples to accumulate over. 16-128 recommended.
seedINT00–4294967295Seed for noise and timestep sampling.
hessian_block_sizeINT1280–10240 = full H (paper-accurate, auto memory-mapped to disk). 128 = diagonal blocks (default, saves RAM). Ignored when hessian_format='dlr'.
hessian_formatCOMBOdlr_nystromHessian storage format. 'block' = diagonal blocks (use hessian_block_size). 'full' = full Hessian (memory-mapped). 'dlr' = Diagonal + Low-Rank via FrequentDirections (streaming, exact diagonal, repeated SVD). 'dlr_nystrom' = DLR via randomized Nyström (streaming, exact diagonal, ~100× faster construction — recommended default).
dlr_rankINT1281–4096Rank for DLR Hessian (only used when hessian_format is 'dlr' or 'dlr_nystrom'). Same memory budget as block_size=rank. Recommended: 64-256.
collect_amaxBOOLEANtrueAlso collect max(abs(x)) per layer. Required for activation quantization; not used by weight-only GPTQ.
output_pathSTRING/tmp/ComfyUI/output/calibration.ptWhere to save the calibration .pt file.
latent_heightoptINT648–1024Latent spatial height. 128 for 1024px, 64 for 512px.
latent_widthoptINT648–1024Latent spatial width. 128 for 1024px, 64 for 512px.
convrotoptBOOLEANfalseEnable ConvRot Hadamard rotation. Collects Hessians in rotated space for better block-diagonal approximation.
rot_sizeoptINT25616–4096Hadamard group size (must be power of 2). 256 recommended for ConvRot.
rpbhoptBOOLEANfalseEnable RPBH (Randomized Permuted Block-Hadamard) rotation. Mutually exclusive with ConvRot. Spreads outliers via random permutation + block Hadamard + sign flip. Uses per-layer auto-detected block size (largest power-of-2 dividing in_features). Best paired with DLR Hessian format — block format is lossy because RPBH's permutation destroys block-diagonal structure. Not recommended with PermuQuant.
rpbh_seedoptINT420–2147483647Random seed for RPBH permutation and signs. The converter must use the same seed to regenerate matching rotation parameters for weight folding.
rpbh_block_sizeoptINT2560–65536RPBH Hadamard block size. 0 = auto-detect (largest power-of-2 dividing in_features, default). Set to 256 for uniform block size across all layers — smaller blocks give finer-grained outlier spreading. Must be a power of 2 if non-zero. The converter must use the same block size.
permuquantoptBOOLEANfalseEnable PermuQuant channel reordering. Runs a second calibration pass with channels sorted by second moment for better quantization.
pisooptBOOLEANfalseCollect Hessian diagonal for PiSO data-aware scale optimization. Adds a small overhead to store diag(X^T X) per layer, which the converter uses to compute optimal per-row scales instead of absmax.
sigma_minoptFLOAT0.000–1Lower bound of the sigma range to sample. Set to 0.875 with Wan 2.2 high-noise expert, or 0.0 for full range (default).
sigma_maxoptFLOAT1.000–1Upper bound of the sigma range to sample. Set to 0.875 with Wan 2.2 low-noise expert, or 1.0 for full range (default).
force_cpu_hookoptBOOLEANfalseForce hook-side processing to CPU. Enable only if you hit GPU OOM during calibration — the GPU-fast path uses ~20-50 MB of transient VRAM per layer.
timestep_channel_amaxoptBOOLEANfalseCollect per-timestep-bucket per-channel amax in addition to overall per-channel amax. Enables the converter to analyse time-varying channel imbalance for static-dynamic decomposition (ViDiT-Q Section 4.2). Automatically enables per-channel amax collection. Adds 'channel_amax_by_timestep' to the output.
timestep_bucketsoptINT41–64Number of timestep buckets for per-timestep channel amax. 4 = divide denoising into 4 equal ranges (ViDiT-Q paper default).

Outputs (1)

NameTypeDescription
calibration_pathSTRING