在消费级GPU上实现扩散Transformer的原生INT8计算:用于Ideogram 4.0的融合INT8 GEMM内核
Realizing Native INT8 Compute for Diffusion Transformers on Consumer GPUs: A Fused INT8 GEMM Kernel for Ideogram 4.0
AI总结:
针对消费级Ampere GPU上INT8量化比FP8/NF4更慢的问题,提出融合Triton INT8 GEMM内核,直接利用INT8张量核心,在Ideogram 4.0中实现2.8-4.2倍加速,端到端速度提升约10%,使1024px单卡可行。
摘要:
扩散Transformer的训练后INT8(W8A8)量化被广泛用作速度优化,但在消费级Ampere GPU上,它通常比它本应击败的FP8和NF4替代方案更慢。我们将此归因于一个软件伪影:生产中的“INT8”前向量化权重和激活,但立即将它们反量化回bf16并执行bf16矩阵乘法,从未使用GPU的INT8张量核心,因此硬件的计算优势完全未被利用。我们通过一个单一的融合Triton INT8 GEMM(在Ampere张量核心上执行int8xint8->int32,并在epilogue中融合每token乘每通道的反量化和偏置,针对每个GEMM形状自动调优)来弥补这一差距,将其插入Ideogram 4.0扩散Transformer的线性层中,替代反量化到bf16的路径。在该内核中,int8xint8->int32累加与torch._int_mm逐位精确,反量化输出与参考的余弦相似度为1.0且无NaN,每个GEMM的运行速度比bf16快2.8-4.2倍。端到端在768px分辨率下实现约1.1倍(约9-10%)的加速,在1024px分辨率下,单张RTX 3090上生成图像耗时156.5秒,快于单卡NF4(164.5秒)和FP8(172.9秒)基线,且在这些点估计(PickScore/CLIPScore)上无质量损失。因此,INT8从最慢的变体变为最快,1024px在单GPU上变得可行。主要速度标准(击败FP8,约9.5%)轻松满足;NF4的差距(约4.9%,单次运行n=4)在未量化的运行间方差内,最好理解为与达到扩展目标一致。最后我们给出一个诚实的部署图:该优势特定于消费级Ampere,在A100和B200上,相同内核会输给这些卡快速的本地bf16/FP8路径。
英文摘要:
Post-training INT8 (W8A8) quantization of diffusion transformers is widely deployed as a speed optimization, yet on consumer Ampere GPUs it is frequently slower than the FP8 and NF4 alternatives it is meant to beat. We trace this to a software artifact: the production "INT8" forward quantizes weights and activations only to immediately dequantize them back to bf16 and run a bf16 matrix multiply, never engaging the GPU's INT8 tensor cores, so the hardware's compute advantage is left entirely unrealized. We close this gap with a single fused Triton INT8 GEMM (int8xint8->int32 on Ampere tensor cores, with per-token x per-channel dequantization and bias folded into the epilogue, autotuned per GEMM shape) dropped into the Ideogram 4.0 diffusion transformer's linear layers in place of the dequantize-to-bf16 path. In the kernel, the int8xint8->int32 accumulation is bit-exact against torch._int_mm and the dequantized output matches the reference at cosine similarity 1.0 with no NaNs, running 2.8-4.2x faster than bf16 per GEMM. End to end it delivers a ~1.1x (~9-10%) speedup at 768px, and at 1024px it generates an image in 156.5 s on a single RTX 3090, faster than the single-card NF4 (164.5 s) and FP8 (172.9 s) baselines, at no measurable quality cost on these point estimates (PickScore/CLIPScore). INT8 thus goes from the slowest variant to the fastest, and 1024px becomes single-GPU feasible. The primary speed criterion (beat FP8, by ~9.5%) is comfortably met; the NF4 margin (~4.9%, single-run n=4) is within run-to-run variance we did not quantify and is best read as consistent with meeting the stretch target. We close with an honest deployment map: the win is specific to consumer Ampere, and on A100 and B200 the same kernel loses to those cards' fast native bf16/FP8 paths.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。