FuTransformer:在Hopper架构上面向Llama风格推理的FP8预填充与INT4解码 FuTransformer: FP8 prefill and INT4 decode for Llama-style inference on Hopper 预印本

⚠️ 本文为 预印本(arXiv 公开版本),尚未经过正式同行评审。作者自发公开,结论未经期刊审稿验证,阅读时请知悉。
发布时间:2026-10-16
👁️ 预览文献
💡 AI 中文简介
该研究针对Llama风格Transformer在GPU上的推理效率问题,提出FuTransformer。预填充阶段重用权重,受矩阵乘法和激活数据移动主导;解码阶段重用有限,受权重和KV缓存读取主导。作者在NVIDIA Hopper GPU上实现CUDA版本,预填充采用FP8精度,解码采用INT4权重和KV缓存。在H100上,预填充比PyTorch FP8快1.48倍,达到1.29 PFLOP/s;INT4解码比PyTorch BF16和INT4块快1.3-2.4倍。完整Llama-3.1-8B解码每步仅2.8毫秒,比编译版transformers快近3倍,且精度损失可控。
领域深度学习系统与GPU推理优化
适合谁读需要一定专业背景(熟悉Transformer、GPU架构和量化技术)
核心贡献1. 针对Hopper GPU的Llama风格Transformer块,提出预填充用FP8、解码用INT4的混合精度CUDA实现,并引入直接KV缓存放置、权重折叠RMSNorm、延迟缩放写FP8输出等技术。2. 设计块对角Hadamard变换降低缓存量化误差,并利用Tensor Core片段布局实现权重和键的直接反量化,避免中间 tiles。
关键数据预填充速度达1.29 PFLOP/s,比编译PyTorch FP8快1.48倍;8B形状下BF16路径比CODA快1.13倍,FP8路径比BF16 CODA快2.02-2.18倍;INT4解码比PyTorch BF16/INT4块快1.3-2.4倍,比FP8路径快31-51%;Llama-3.1-8B解码每步2.8ms(对比8.1ms);WikiText-2困惑度从6.24升至7.23(INT4权重)或6.99(GPTQ),旋转INT4缓存增加0.20。
推荐理由如果你关注大模型推理加速,这篇工作展示了如何在Hopper上把FP8和INT4用到极致,实测数据亮眼,值得一读。
关键词["Transformer推理", "FP8预填充", "INT4解码", "Hopper GPU", "量化", "KV缓存"]

原文摘要

查看英文原文摘要

Transformer prefill reuses weights across tokens and is dominated by matrix multiplication and activation data movement; single-token decode has limited reuse and is dominated by weight and KV-cache reads. We present FUTRANSFORMER, a CUDA implementation of a Llama-style Transformer block for NVIDIA Hopper GPUs. It applies CODA's GEMM-plus-epilogue approach to inference, adding direct KV-cache placement, folding the fixed RMSNorm gain into weights, writing FP8 output directly with delayed scaling, and supporting prefill without padding. Decode uses INT4 projection weights and an INT4 KV-cache copy. Weights and keys follow Tensor Core fragment layouts for direct dequantization into MMA operands without full intermediate tiles. A block-diagonal Hadamard transform reduces cache quantization error from outlier channels. On one H100, prefill is up to 1.48x faster than compiled PyTorch FP8 and reaches 1.29 PFLOP/s. For gate/up projection with SwiGLU at the 8B shape, our BF16 path is 1.13x faster than CODA. Our FP8 path is 2.02-2.18x faster than the evaluated BF16 CODA path. Across 8B and 70B shapes at batches 1-32, INT4 decode is 1.3-2.4x faster than the faster of PyTorch's BF16 and INT4 blocks at each point: 2.1-3.3x faster than compiled, CUDA-graphed BF16 and 1.3-6.3x faster than the same block using PyTorch's INT4 projection kernel, which targets a single query row and loses to BF16 at batch 32. It is also 31-51% faster than our FP8 path. Complete Llama-3.1-8B decode takes 2.8 ms per step at batch one, versus 8.1 ms for the compiled transformers implementation. Decoding every WikiText-2 token through the INT4 weight path raises perplexity from 6.24 to 7.23 with round-to-nearest weights or 6.99 with GPTQ in the same format; the rotated INT4 cache adds 0.20. The kernels match a quantized reference computation within 0.001 perplexity.