r/StableDiffusion • u/gugmelik • 10h ago
Question - Help Why do we need ConvRot for diffusion model quantization?
I've been reading about ConvRot and its application to quantizing diffusion transformers.
I understand that it uses group-wise Hadamard rotations to redistribute outliers and reduce quantization errors. However, I'm still trying to understand its practical advantages over conventional quantization methods.
- Why is conventional INT8 or FP8 quantization insufficient for diffusion transformers?
- Why do we need rotation instead of simply using per-channel or group-wise quantization?
- How does ConvRot compare to SmoothQuant and QuaRot?
- Does the additional activation rotation introduce a significant computational overhead during inference?
- Is ConvRot particularly beneficial for INT4, or does it also provide substantial improvements for INT8?
I'd appreciate both mathematical explanations and practical experience, especially with models like FLUX and Qwen-Image.
38
u/Dr__Pangloss 10h ago
it's simple, the practical advantage is that quantizing with convrot is fast and very high quality. while smoothquant, gptq, awq etc. are better for quantizing WEIGHTS, they are too slow for quantizing ACTIVATIONS (meaning intermediate values)
within the diffusion model the costly operations are of the form
WEIGHTS (OPERATOR) ACTIVATIONS => ACCUMULATION
the best balance of speed and quality for the costliest ops are
int8 x int8 => bf16
so if you can quantize ACTIVATIONS quickly to int8, for example, you can do int8 . int8 matmul instead of int8 . bf16 matmul. this is exactly what comfyui's int8 matmul kernels do, and it explains about 50% of the speedup of adopting int8 for most users (the other 50% is that nvidia halved fp16 & bf16 ACCUMULATION
9
u/thebaker66 9h ago
Why are you framing it as 'need', it's not 'needed', it's just been found as optimal over other methods.
3
u/Altruistic-String891 9h ago edited 9h ago
rotation: when 1 activation output is very large, naive quantization squishes the other smaller values to 0. rotation, like you said, can redistribute the numbers so they're closer in scale. per-channel/group without rotation would still have that outlier affect the entire channel/group.
slower: slightly, 10% slower than naive int8 for me give or take on a low end nvidia gpu
int4: helps, but usually only takes it from "bad -> decent," not anything "good" you'd want to use
experience: I did small tests comparing fp8_e5m2, fp8_e4m3 (and their scaled versions), int8, int8_convrot, on PSNR, MS-SSIM, LPIPS, and time spent - int8_convrot comes out on top on quality preserved and is only slightly slower than int8, regardless of model.
3
u/FischiPiSti 9h ago
My question is (though it may be stupid), if higher precision has strong diminishing returns, why not train at lower precision to begin with?
6
u/VasaFromParadise 10h ago
Less loss of precision at the same size + works on older generations of rtx) And the speed is higher, because Nvidia cut performance in FP8, supposedly to protect gaming cards))
1
u/Conscious_Chef_3233 3h ago
why llm do not use convrot?
1
u/Apprehensive_Sky892 8h ago edited 8h ago
FP8 is sufficient, but only newer hardware have (40xx and above, RDNA4) native support for it. Older hardware only supports in8 and bf16.
int8convrot also have higher precision because it is 8bit magnitude + 8bit scaling factor, whereas fp8 is just 8bit for both mantissa and exponent.
INT8 alone is insufficient because without the rotation, vectors with wide range such as [5 6 7 1000] will just become [0 0 0 255]
Not sure, maybe because through rotation one can have a larger vector that can share the same scaling factor?
0
u/[deleted] 9h ago
[deleted] — view deleted comment