arXiv:2610.23796cs.AIOct 2026

Manuscript Offprint

arXiv:2610.23796

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

Wei Wang

ABSTRACT

Transformer inference has different bottlenecks during prefill and decode. Prefill reuses weights across many tokens and is dominated by matrix multiplication and activation data movement. Single-token decode has limited data 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. CODA showed how to express Transformer training operators as GEMM-plus-epilogue programs. FUTRANSFORMER applies this principle to inference. It adds direct KV-cache placement, folds the fixed RMSNorm gain into weights, writes FP8 values directly from the producing epilogue using delayed scaling, and supports prefill without padding. For decode, FUTRANSFORMER uses INT4 projection weights and an INT4 copy of the KV cache. Keys and weights follow the Tensor Core fragment layout, so the kernels can dequantize them directly into MMA operands without creating full intermediate tiles. A block-diagonal Hadamard transform makes INT4 cache quantization less sensitive to outlier channels. On one H100, prefill is up to 1.48×1.48\times faster than compiled PyTorch FP8 and reaches 1.29 PFLOP/s. For the closest shared operation, gate/up projection followed by SwiGLU, the BF16 path is 1.13×1.13\times faster than the released CODA kernel at the 8B shape. Our FP8 inference path is 2.02−2.18×2.02-2.18\times faster than the evaluated BF16 CODA path. Across the 8B and 70B shapes at batch 1 to 32, INT4 decode is 1.3−2.4×1.3-2.4\times faster than whichever PyTorch decode block is faster at each point: 2.1−3.3×2.1-3.3\times faster than the compiled, CUDA-graphed BF16 block, and 1.3−6.3×1.3-6.3\times faster than the same block using PyTorch's INT4 projection kernel, which is built for a single query row and loses to its own BF16 block at batch 32. INT4 decode is also 31-51% faster than our FP8 decode path. For the complete Llama-3.1-8B model, one INT4 decode step takes 2.8 ms at batch one, compared with 8.1 ms for the compiled transformers implementation. On Llama-3.1-8B, decoding every WikiText-2 token through the INT4 weight path increases perplexity from 6.24 to 7.23 with round-to-nearest weights, or to 6.99 with GPTQ weights stored in the same format. The rotated INT4 cache adds another 0.20. The kernel path matches the quantized reference computation to within 0.001 perplexity.

1 INTRODUCTION

Matrix multiplication dominates Transformer FLOPs, but data movement and other operations also contribute to execution time. A decoder block also performs normalization, residual updates, position encoding, activation functions, precision conversion, and KV-cache updates. These operations perform little arithmetic but often read and write large intermediate tensors. As Tensor Cores become faster, this data movement takes a larger share of the total execution time.

CODA (Guo et al., 2026) addresses this problem for training by expressing many Transformer operators as GEMM-plus-epilogue programs. An optimized GEMM mainloop produces an output tile. A programmable epilogue then processes the tile while it is still on chip. This allows pairwise operations such as RoPE and SwiGLU, as well as residual updates, scaling, and partial reductions, to run without separate reads and writes to global memory.

FUTRANSFORMER uses the same GEMM-plus-epilogue principle for autoregressive inference. Inference adds two requirements. First, prefill must manage persistent state. It must write K and V directly to the KV cache, produce low-precision activations for later projections, and support requests of different lengths. Second, decode has too few rows to behave like a large GEMM. At small batch sizes, each layer reads its weights for only a few rows, and attention reads cached K and V values for every query. The decode path must therefore reduce the bytes read and prevent dequantization from delaying the main computation.

For prefill, FUTRANSFORMER uses persistent FP8 GEMMs with epilogue policies selected at compile time. These policies apply RoPE or SwiGLU, write K and V to the cache,

Correspondence to: Wei Wang wei.wang217@gmail.com.

collect RMSNorm statistics, restore scales, and optionally write FP8 output directly. Inference weights are fixed, so the learned RMSNorm gain can be folded into the next projection before quantization. The row-wise normalization factor is then applied in that projection's epilogue. This removes the normalized activation tensor while preserving the quantized computation. Packed inputs also remove padded projection rows from batches with different request lengths.

For decode, FUTRANSFORMER uses INT4 weights and an INT4 copy of the KV cache. Hopper has no INT4 Tensor Core MMA, and its FP8 MMA requires large warpgroup shapes that the few query rows in decode cannot fill. The kernel must therefore expand INT4 values before a 16-bit MMA. The main design choice is where to perform this expansion. FUTRANSFORMER stores keys and weights in the order required by the MMA fragments. A byte-indexed lookup converts packed cache values into FP16 pairs. A short sequence of logic and packed BF16 operations converts weight nibbles directly in registers. Group scales are applied after accumulation. Before cache quantization, a block-diagonal Hadamard transform spreads large channel values. Matching transforms on the query and attention output preserve the attention computation before quantization.

The main contributions are:

• Inference-specific GEMM epilogues. Starting from CODA’s GEMM-plus-epilogue formulation, FU-TRANSFORMER adds direct KV-cache placement, folds the fixed RMSNorm gain into weights, writes FP8 producer output with delayed scaling, and supports packed prefill.

• Fragment-aligned INT4 decode. INT4 weights and cache entries are packed in the layout required by the MMA fragments that consume them. Values are de-quantized in registers or through a small lookup table. Scales are applied outside the per-element inner loop.

• Outlier-aware cache quantization. A block-diagonal Hadamard transform reduces INT4 cache error when keys contain large channel outliers. Before quantization, the transform preserves the exact attention dot product.

• A final-result evaluation. We compare full prefill and decode layers with PyTorch. We also compare the complete Llama-3.1-8B model with PyTorch and the closest shared gate/up–SwiGLU stage with CODA. We report performance and numerical error, and label comparisons that use different precisions. Using a trained Llama-3.1-8B checkpoint, we decode every WikiText-2 token through the INT4 path and measure perplexity, per-layer error, and error accumulated across layers.