Fast Polynomial Transcendentals for LLMs
Organizations: GRAPHCORE RESEARCH
Abstract
Graphics processing unit (GPU) generations scale matrix, special-function, and memory pipelines at different rates, so kernel bottlenecks move as hardware evolves. FlashAttention-4 exposed this imbalance inside attention on NVIDIA Blackwell. We test whether short polynomial programs can accelerate other special-function-unit (SFU) operations in large language models (LLMs). We first compare native PyTorch evaluation with packed fused multiply--add (FMA) programs in an isolated IEEE binary16 (FP16) sweep spanning L2-resident and high-bandwidth-memory (HBM)-resident working sets. We then replace native sigmoid, tanh, and sigmoid linear unit (SiLU) with degree-3 or degree-4 bfloat16 (BF16) programs in four GB200 integration tasks: dense SiLU, tanh-softcapped attention, sigmoid attention, and routed-expert Swish-gated linear unit (SwiGLU). The programs combine analytical symmetry, target-format rounding, and packed arithmetic inside consuming kernels. The isolated paths improve by 1.19--2.19x in L2 and 1.00--1.70x in HBM. The dense-SiLU, tanh-softcapped-attention, and routed-expert substitutions improve complete training-step throughput by 2.7%, 2.9%, and 8.0%, respectively. The sigmoid-attention substitution improves complete-attention forward by 7.4% and the complete GPU step by 0.3%. Same-checkpoint open-weight ablations and one paired pre-training comparison per task extend the evaluation to model behavior. At common horizons near 100 billion tokens, the final smoothed training-loss differences (polynomial minus native) range from to across the four tasks.
Figures & tables
| Case | Baseline | Polynomial intervention | Question |
|---|---|---|---|
| B1 | Native SiLU in dense MLPs | Packed D3 SiLU | Does packed SiLU increase dense-model training-step throughput? |
| B2 | Tanh-softcapped attention | D4 tanh inside FA4 | Does packed tanh reduce complete softcapped-attention runtime? |
| B3 | Native sigmoid attention | Direct D3 sigmoid and D4 derivative | Does polynomial sigmoid reduce complete sigmoid-attention runtime? |
| B4 | Native SiLU in routed experts | Fused D3 polynomial Swish-gated linear unit (SwiGLU) | Does packed SwiGLU increase routed-expert training-step throughput? |
| Maximum absolute error | ||||
|---|---|---|---|---|
| Direction | Function | Reduced program | Endpoint-constrained least squares | Sollya minimax |
| Forward | Sigmoid | D3, odd | 5.44 | 5.47 |
| Forward | Tanh | D4, odd | 9.61 | 7.22 |
| Forward | SiLU | D3, even | 21.74 | 19.95 |
| Forward | GELU | D5, even | 1.06 | 0.50 |
| Backward | Sigmoid | D4, even | 4.46 | 1.97 |
| Direction | Function | Polynomial program | 4M elements (L2 cache) | 268M elements (HBM) |
|---|---|---|---|---|
| Forward | Sigmoid | D3 polynomial | 1.702x | 1.249x |
| Forward | Tanh | D4 polynomial | 1.187x | 1.143x |
| Forward | SiLU | D3 polynomial | 1.536x | 1.267x |
| Forward | GELU | D5 polynomial | 1.673x | 1.702x |
| Backward | Sigmoid | D4 direct derivative | 2.135x | 1.004x |
| Backward | Tanh | D4 direct derivative | 2.184x | 1.003x |
| Case | Timed component | Program | Forward speedup | Backward speedup |
|---|---|---|---|---|
| B1 | One-kernel SiLU activation | D3 direct-fit probe | 1.055x | 1.007x |
| B2 | Complete causal GQA attention | D4 tanh softcap | 2.053x | 1.046x |
| B3 | Complete causal GQA attention | D3/D4 sigmoid | 1.074x | 1.001x |
| B4 | One-kernel expert activation | D3 SwiGLU | 1.003x | 1.005x |
| Case | Model / intervention | Forward speedup | Backward speedup | GPU-step speedup | Training-throughput ratio |
|---|---|---|---|---|---|
| B1 | Llama 3 8B, dense D3 SiLU | 1.005x | 1.038x | 1.027x | 1.027x |
| B2 | Llama 3 8B, D4 tanh softcap | 1.107x | 1.004x | 1.029x | 1.029x |
| B3 | Llama 3 8B, D3/D4 sigmoid attention | 1.011x | 0.997x | 1.003x | 1.002x |
| B4 | DeepSeek-V3 27A4B, expert D3 SwiGLU | 1.087x | 1.077x | 1.080x | 1.080x |
| Model | Operator | Fit method | Mean accuracy change (percentage points) | WikiText-2 word perplexity | Prefill throughput ratio | Decode throughput ratio |
|---|---|---|---|---|---|---|
| Qwen2.5 7B | Dense SwiGLU | Endpoint LS | -0.51 | 1.035x | 1.013x | |
| Sollya minimax | -39.80 | 1.036x | 1.015x | |||
| Qwen3 30B-A3B | Expert SwiGLU | Endpoint LS | -0.10 | 1.056x | 1.025x | |
| Sollya minimax | +0.04 | 1.051x | 1.025x | |||
| GLM-4.7 Flash | Expert SwiGLU + router sigmoid | Endpoint LS | -0.30 | 0.969x | 1.004x | |
| Sollya minimax | -0.18 | 0.966x | 1.003x |
| Case | Intervention | Shared horizon (billion tokens) | Native EWM training loss | Polynomial EWM training loss | Training-loss change |
|---|---|---|---|---|---|
| B1 | Dense D3 SiLU | 100.2701 | 2.6264 | 2.7050 | |
| B2 | D4 tanh softcap | 100.2701 | 2.5415 | 2.5439 | |
| B3 | D3/D4 sigmoid attention | 100.2701 | 4.9471 | 4.8397 | |
| B4 | Routed-expert D3 SwiGLU | 100.2439 | 2.1532 | 2.1560 |
Appendix figures & tables5 assets
Supplementary material from the paper’s appendix.
Appendix
| Family | Objective | Fractional core | Maximum relative error | Root-mean-square relative error |
|---|---|---|---|---|
| D1 | Endpoint constrained | 1 packed FMA | ||
| PWL2 | Least squares | 2 packed FMAs + hinge | ||
| PWL2 | Sampled minimax | 2 packed FMAs + hinge | ||
| D2 | Least squares | 2 packed FMAs | ||
| D2 | Sampled minimax | 2 packed FMAs | ||
| FA4 D3 | Sollya/minimax | 3 packed FMAs; |
| Measurement scope | FA4 D3 | PWL2 FP16 | D2 FP32 |
|---|---|---|---|
| Fractional core, repeated compute | – | 1.898x | – |
| Full , repeated compute | 0.884x | 0.863x | – |
| Full , 4 MiB input + 4 MiB output (L2-sized) | 0.995x | 1.002x | – |
| Full , 256 MiB input + 256 MiB output (HBM-sized) | 0.995x | 0.990x | – |
| Causal FA4 forward | 1.012x | 1.010x | 1.012x |
| Causal FA4 forward + backward | 1.001x | 1.005x | 1.006x |
| Measured quantity | FA4 D3 | PWL2 FP16 | D2 FP32 |
|---|---|---|---|
| Maximum over output and input-gradient tensors |
GPU Kernel Optimization
GPU kernel optimization improves the speed and memory efficiency of computations by tailoring code to GPU hardware and workloads.
See all 202 papers