Hybrid-Sensitivity-Weighted-Quantization (HSWQ)

High-fidelity FP8 quantization for diffusion models (Z Image). HSWQ uses sensitivity and importance analysis instead of naive uniform cast, and offers two modes: standard-compatible (V1) and high-performance scaled (V2).

Technical details: md/HSWQ_ Hybrid Sensitivity Weighted Quantization.md


Overview

Feature V1: Standard Compatible V2: High Performance Scaled
Compatibility Full (100%), any FP8 loader The scaled model does not perform well in the current ComfyUI.
File format Standard FP8 (torch.float8_e4m3fn) Extended FP8 (weights + .scale metadata)
Image quality (SSIM) ~0.89 (theoretical limit) ~Unable to measure at this time
Mechanism Optimal clipping (smart clipping) Full-range scaling (dynamic scaling)
Use case Distribution, general users In-house, max quality, server-side

File size is reduced by about 55% 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 β†’ top 25% kept in FP16.
    • Importance (input mean absolute value): per-channel contribution β†’ used as weights in the weighted histogram.
  2. Rigorous FP8 Grid Simulation β€” Uses a physical grid (all 0–255 values cast to torch.float8_e4m3fn) instead of theoretical formulas, so MSE matches real runtime.

  3. Weighted MSE Optimization β€” Finds parameters that minimize quantization error using the importance histogram.


Modes

  • V1 (scaled=False): No scaling; only the clipping threshold (amax) is optimized. Output is standard FP8 weights. Use when you need maximum compatibility.
  • V2 (scaled=True): Weights are scaled to FP8 range, quantized, and inverse scale S is stored in Safetensors (.scale). Use with HSWQLoader for best quality.

Recommended Parameters

  • Samples: 256 (minimum for reliable stats; 128 is insufficient).
  • Keep ratio: 0.10 (10%) β€” keeps critical layers in FP16; 0.10 has higher degradation risk.
  • Steps: 20–25 β€” to include early denoising sensitivity.

Benchmark (Reference)

Model SSIM (Avg) File size Compatibility
Original FP16 1.0000 100% (6.5GB) High
Naive FP8 0.82-0.83 50% High
HSWQ V1 0.88–0.89 55% (FP16 mixed) High
HSWQ V2 Unable to measure at this time 55% (FP16 mixed) Low (custom loader)

HSWQ V1 gives a clear gain over Naive FP8 with full compatibility; V2 targets maximum quality with a custom loader.

2. Setup

  • VAE: Use standard SDXL VAE (place in models/vae/)
Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support