Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

672 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Hybrid-Sensitivity-Weighted-Quantization (HSWQ)

High-fidelity ConvRot INT8 and ConvRot NVFP4 quantization for SDXL, Flux1.dev, and Z Image Turbo diffusion models. HSWQ uses sensitivity and importance analysis instead of naive uniform cast.

  • ConvRot INT8 (SDXL V3.1): ComfyUI-compatible int8_tensorwise pack with FULL ConvRot on remaining Linear/Conv2d after DualMonitor + V4 weighted-histogram FP16 protection under a fixed 300 MiB budget. Keep ratio is 0 (r0); critical layers stay FP16 via automatic analysis, not a keep-ratio percentage. Pack path matches native_convert_int8_convrot.py.
  • ConvRot NVFP4 (SDXL): ComfyUI Load Diffusion Model nvfp4 pack with FULL ConvRot (Linear→NVFP4, Conv2d→INT8 int8_tensorwise) after DualMonitor + V4 pack-MSE FP16 protection under a fixed 600 MiB budget. Keep ratio is 0 (r0); calib writes NVFP4 .input_scale. Script: hswq_convert_nvfp4_convrot_1.0.py.
  • Z Image INT8 (HSWQ): Development and public release ended. For Z Image, native ConvRot INT8 already reaches roughly SSIM > 0.99 in general, so a separate HSWQ Z Image 8-bit line is no longer developed or published. Use native ConvRot INT8 for Z Image 8-bit; HSWQ INT8 work continues for SDXL.

Technical details (FP8): md/HSWQ_ Hybrid Sensitivity Weighted Quantization.mdFP8 development has ended; this document is retained as a technical asset.
Technical details (INT8 FP16-protect / pack overview — ConvRot pack guide not published yet): md/HSWQ_INT8_SDXL_Technical_Guide.md

ComfyUI Loader for ConvRot INT8 / INT8: To use these models in ComfyUI, please use this custom node: ComfyUI-nunchaku-unofficial-loader ComfyUI Loader for ConvRot NVFP4: To use these models in ComfyUI, please use this custom node: ComfyUI-HSWQ-Loader-and-Tools


How to quantize

Benchmark results:


Overview

Feature ConvRot INT8 (SDXL V3.1) ConvRot NVFP4
Compatibility ComfyUI int8_tensorwise / QUANT_ALGOS compatible ComfyUI Load Diffusion Model / QUANT_ALGOS nvfp4 compatible
File format INT8 weights + scale (int8_tensorwise); SDXL V3.1 packs remainder with FULL ConvRot Linear NVFP4 + Conv2d INT8 (int8_tensorwise); FULL ConvRot on eligible layers
Image quality (SSIM) 0.94–0.98 0.92-0.98
Mechanism Absmax + DualMonitor / V4 FP16 protect (r0); then FULL ConvRot on Linear/Conv2d remainder Absmax + DualMonitor / V4 FP16 protect (r0, 600 MiB); FULL ConvRot (Linear→NVFP4, Conv2d→INT8)
Keep ratio 0 (fixed) 0 (fixed)
Benchmark Measurable Measurable
Use case SDXL ConvRot INT8 distribution / kitchen loaders SDXL ConvRot NVFP4 distribution / native ComfyUI load

Note (Z Image 8-bit): HSWQ Z Image INT8 development and publication ended. Native ConvRot INT8 is sufficient for Z Image (typically SSIM > 0.99). HSWQ INT8 remains the SDXL path.

File size is reduced by about 30–40% vs FP16 while keeping best quality per use case.


Architecture

  1. Dual Monitor System — During calibration, two metrics are collected:

    • Sensitivity (output variance): layers that hurt image quality most if corrupted → kept in FP16 when selected by HSWQ. ConvRot INT8 / NVFP4 (SDXL): keep ratio 0; FP16 set comes from automatic analysis / budget ranking, not a keep-ratio %.
    • Importance: V1 uses per-channel input mean-abs; V4 uses per-element SVD leverage × RMS magnitude hybrid → weights of the weighted histogram. Technical details: Dual Monitor System — Technical Guide.
  2. Rigorous grid / pack simulation

    • ConvRot INT8 (SDXL): natural absmax pack point for the symmetric INT8 grid; V4 weighted-histogram MSE ranks FP16 protection candidates (does not choose pack amax). SDXL V3.1 then applies FULL ConvRot (Hadamard rotate → channelwise absmax) on remaining Linear/Conv2d, identical to native_convert_int8_convrot.py.
    • ConvRot NVFP4 (SDXL): absmax pack point for Linear→NVFP4 and Conv2d→INT8; V4 pack-MSE ranks FP16 protection under the 600 MiB budget, then FULL ConvRot on eligible remainder.
  3. Weighted MSE Optimization — Finds parameters that minimize quantization error using an importance-weighted histogram (not a plain frequency histogram).

    • V1 / Fast: per-channel importance (activation mean-abs) drives the histogram. Technical details: Weighted Histogram MSE — Technical Guide.
    • V4 (SVD × RMS hybrid): per-element importance blends SVD structural leverage (L(i,j)=(U_i\cdot\sigma)^2\cdot(V_j)^2) with RMS magnitude; (\alpha) tilts toward SVD on heavy-tailed layers. Used by SDXL ConvRot INT8 and ConvRot NVFP4 for FP16-candidate ranking at the absmax pack point. Technical details: HSWQ V4 SVD-RMS — Technical Guide.

Modes

ConvRot INT8 (SDXL)

  • Script: quantize_sdxl_hswq_v3.1.py (SDXL ConvRot INT8; 300 MiB FP16 budget; FULL ConvRot default ON).
  • SDXL V3.1 order: (1) FP16 keep via DualMonitor + analyze + V4 under the 300 MiB budget → (2) remaining Linear/Conv2d FULL ConvRot INT8 (native_convert_int8_convrot.py pack path). Card 1 / Card 2 forced OFF.
  • Tensorwise / channelwise: format tag int8_tensorwise. ConvRot layers use rotate → channelwise absmax; non-ConvRot remainder uses per-tensor absmax unless Card 3 is enabled.
  • Card 3 (--per_channel_int8): per-output-channel amax / scale for non-ConvRot plain packs (SDXL).
  • Keep ratio: 0 (fixed) — FP16 protection is automatic (analyze Hard VETO + DualMonitor + V4 ranking inside the FP16 budget), not a percentage keep-ratio.
  • Z Image INT8 (HSWQ): Ended — no further HSWQ Z Image 8-bit development or Hugging Face publication. Prefer native ConvRot INT8 for Z Image (typically SSIM > 0.99).

ConvRot NVFP4 (SDXL)

  • Script: hswq_convert_nvfp4_convrot_1.0.py (SDXL ConvRot NVFP4; 600 MiB FP16 budget; FULL ConvRot default ON).
  • Order: (1) FP16 keep via DualMonitor + analyze + V4 under the 600 MiB hard ceiling → (2) remaining eligible layers FULL ConvRot — Linear → NVFP4, Conv2d → INT8 (int8_tensorwise).
  • Loader / format: ComfyUI Load Diffusion Model / QUANT_ALGOS nvfp4; NVFP4 .input_scale from PTQ calib (--calib_file).
  • Keep ratio: 0 (fixed) — FP16 protection is automatic (analyze Hard VETO + DualMonitor + V4 pack-MSE ranking inside the FP16 budget), not a percentage keep-ratio.
  • Image quality (SSIM): 0.92-0.98.

Recommended Parameters

  • Samples: 32 (recommended) — number of calibration samples (same for FP8 and ConvRot INT8).
  • Steps: 25 — number of inference steps per sample during calibration (same for FP8 and ConvRot INT8).
  • ConvRot group size (SDXL V3.1): power of 4 (default from script CLI); --no-convrot disables FULL ConvRot (plain pack only).

Benchmark (Reference)

Model SSIM (Avg) File size Compatibility
Original FP16 1.0000 100% High
Naive FP8 0.75–0.93 50% High
HSWQ ConvRot INT8 0.94–0.98 68% (FP16 mixed) High (ComfyUI INT8)
HSWQ ConvRot NVFP4 0.92-0.98 60% (FP16 mixed) High (ComfyUI NVFP4)

HSWQ ConvRot INT8 targets SSIM 0.94–0.98; HSWQ ConvRot NVFP4 targets SSIM 0.92–0.98. Both keep full loader compatibility on their respective formats.


Changelog

Version history and release notes are in CHANGELOG.md.


Base Repositories

This project is built upon the following repositories:

Repository In-repo path Upstream
ComfyUI ComfyUI-master/ @Comfy-Org — The most powerful and modular diffusion model GUI, API and backend with a graph/nodes interface.

About

HSWQ is a novel ConvRot INT8/ConvRot NVFP4 quantization method that combines sensitivity analysis and importance-weighted histogram optimization, achieving superior quality compared to naive uniform quantization while maintaining standard loader compatibility.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages