arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.23796cs.AI
收藏

FuTransformer:面向Hopper架构的Llama风格推理的FP8预填充与INT4解码

FuTransformer: FP8 prefill and INT4 decode for Llama-style inference on Hopper

Wei Wang

AI总结:

提出面向Hopper的FuTransformer,采用FP8预填充与INT4解码技术,在Llama风格推理中,预填充、解码速度均优于现有方案,且保持极低的困惑度误差。

摘要:

Transformer预填充在不同token间复用权重,主要受矩阵乘法和激活数据移动主导;单token解码的复用性有限,主要受权重和KV缓存读取主导。本文提出FUTRANSFORMER,这是面向NVIDIA Hopper GPU的Llama风格Transformer块的CUDA实现。它采用CODA的GEMM加后处理方法进行推理,添加直接KV缓存放置功能,将固定RMSNorm增益折叠到权重中,通过延迟缩放直接写入FP8输出,并支持无填充的预填充。解码阶段使用INT4投影权重和INT4 KV缓存副本,权重和键遵循Tensor Core片段布局,可直接反量化为MMA操作数,无需完整中间块。块对角Hadamard变换可降低离群通道导致的缓存量化误差。在单块H100上,预填充速度比编译后的PyTorch FP8实现快达1.48倍,性能达1.29 PFLOP/s;对于8B规模的SwiGLU门控/上投影,其BF16路径比CODA快1.13倍,FP8路径比评估的BF16 CODA路径快2.02-2.18倍。在8B和70B规模、批次1-32的场景下,INT4解码速度比PyTorch的BF16和INT4块中较快者快1.3-2.4倍,比编译的CUDA图BF16实现快2.1-3.3倍,比使用PyTorch INT4投影内核(针对单查询行,批次32时性能弱于BF16)的同一块快1.3-6.3倍,比FP8路径快31-51%。完整Llama-3.1-8B解码在批次1时每步耗时2.8 ms,而编译的Transformer实现耗时8.1 ms。通过INT4权重路径解码每个WikiText-2 token时,采用四舍五入权重的困惑度从6.24升至7.23,采用同格式GPTQ的困惑度为6.99,旋转后的INT4缓存会增加0.20的困惑度;内核与量化参考计算的困惑度误差在0.001以内。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑