Validating Memory-Optimal Transformer Kernels on Real Hardware: From Formal Derivation to Measured Performance Across Two HPC Clusters
Abstract
We validate memory-optimal cost functions for transformer kernels derived via the Mathematics of Arrays (MoA). Companion Papers I-IV formally derive kernels for attention forward, backward, fused forward+backward, decode, and the complete block (RMSNorm, gated MLP) as a hardware-independent specification (DNF) transformed to a machine-specific realization (ONF) via gamma, with verification to machine precision against PyTorch. This paper checks those predictions against measured performance on two HPC clusters (Purdue Anvil, NCSA Delta) across CPU and GPU. Three results stand out. (1) We identify and fix a GPU regression: fusing forward+backward, proven to avoid materializing an O(n2) intermediate, initially ran slower than naive on GPU due to atomic contention. Profiling confirmed 2.00x more atomic instructions; a targeted ONF rewrite reversed it, yielding up to 2.5x speedup. (2) Identical derivations produce markedly different real costs by topology: 535x NUMA-locality penalty on one cluster vs <3x oversubscription on another, showing optimal deployment is a function of the machine's array structure. (3) We report a partially resolved anomaly: identical denotational computations run faster in C than Fortran on CPU but faster in Fortran than C on GPU, narrowed to one dominant kernel and one memory-latency stall mechanism (3.17x time gap matches 3.35x stall gap). We treat hardware-specific optimization as a routine ONF rewrite with fixed, verified DNF, a candidate methodology for scaling AI onto evolving hardware without re-deriving correctness.
Create a lesson
Metadata
- Categories
- cs.DC, cs.AI
- Comments
- Companion validation for Papers I-IV. Paper I arXiv:2606.07713, Paper II HAL:05659212, Paper III arXiv:2607.19456, Paper IV HAL:05734881 (https://hal.science/hal-05734881). 26 pages, 20 figures (placeholders in v1, real figures in v2). Implementation: https://github.com/womenflyplanes/moa-attention-verified-mullin. Allocation CIS261396 on Purdue Anvil and NCSA Delta via ACCESS
Related papers
EMA: Elastic and Performance Transparent Memory Across GPUs
Shared title terminologycs.DCYi Xu, Tian Xia, Ion Stoica
When Should a Delegated Wallet Send Its Second Payment? Measuring EIP-7702 In-Flight Limits Across Ethereum Clients
Shared title terminologycs.DCSuhua Wang, Ruixin Yu, Zifan Wang et al.
Omokage: Understanding How Agents Develop and Optimize HPC Kernels on GPUs
Shared title terminologycs.DCLingqi Zhang, Jens Domke, Chen Zhuang et al.
BudgetGT: Distributed Full-Graph Transformer on Large Graphs with Budgeted Attention and Memory
Shared title terminologycs.DCChu Zhao, Yuan Fang, Yuhai Zhao et al.
Joule is FLOP: Optimizing Tensor-Core Kernels Beyond Latency Hiding at the GPU Power Wall
Shared title terminologycs.DCTaowen Liu, Zhiwen Mo, Hongxiang Fan et al.
IndexerStage: Staging Indexer-K across Memory Tiers for Sparse-Attention LLM Serving
Shared title terminologycs.DCXin Zhang, Weifeng Zhang, Xianyan Xie et al.