arXiv:2609.10937cs.MSSep 2026

Manuscript Offprint

arXiv:2609.10937

The Art of Closed-Formula Defaults: Search-Free Code Generation for Tensor Operators

Paolo D'Alberto, Ashish Sirasao

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Abstract

Agentic search and automated optimization of GPU kernels are powerful tools for large language model inference. Their effectiveness, however, depends not on the sophistication of the search itself, but on the clarity of the optimization problem being solved. We provide an application-first approach that drives a hierarchical code generation tool from operator specification down to GPU instructions, and show that a clearly defined computational model makes the optimization problem tractable.

For four core tensor operators (general matrix multiply, 2D convolution, softmax, and fused attention), a simple-to-describe, CU-centric model determines all tile sizes analytically, without search: local data share (LDS) capacity fixes the CU tile, the vector general-purpose register (VGPR) budget fixes the warp tile, and the number of compute units (CUs) bounds the minimum parallelism. When the problem is clearly stated, the solution is a closed formula. The resulting closed-formula defaults are correct by construction and derived once per hardware target; changing the hardware descriptor re-runs the same derivation for a different compute DNA (CDNA) GPU without any re-derivation by an expert. These defaults stand on their own or serve as warm starts for any subsequent automated search.

We validate on an AMD CDNA GPU. General matrix multiply achieves 12.3 TFLOPS (53% of the 23.1 TFLOPS MFMA peak) using FlyDSL as code generation backend. Fused attention with matrix fused multiply-add (MFMA) instructions for both internal matrix multiplications achieves 1.50×1.50\times over the unfused baseline at L=16384L=16384, d=128d=128, with 129×129\times less high-bandwidth memory (HBM) traffic; the speedup grows linearly with sequence length. Code is available upon request.

1 Introduction

Modern GPU kernel libraries for large language model inference (cuDNN, hipBLAS, Triton, fused attention [5]) achieve high performance through aggressive autotuning: exhaustive search over tile sizes, register blocking, and memory layouts. This approach yields excellent results and continues to improve with advances in automated search and machine learning compilers.

We complement this landscape by introducing a mathematical description of tensor operators combined with an abstracted, essential hardware descriptor: local data share capacity, vector register budget, matrix fused multiply-add instruction shape, and peak bandwidth. Together, operator and descriptor define the optimization problem precisely enough that tile sizes follow analytically, without search. The result is a default implementation that is correct, predictable, and immediately deployable.

*Advanced Micro Devices, Inc. This work was developed in active collaboration with Claude (Anthropic).

†^{\dagger}Advanced Micro Devices, Inc.

Thesis. For general matrix multiply (GEMM), 2D convolution, softmax, and fused attention, all tile sizes are determined by three hardware constraints applied in order. The local data share (LDS), the thread-shared memory space, fixes the reduction tile analytically. The vector general-purpose registers (VGPRs), the per-thread register space, fix the parallel tile in closed form from the hardware descriptor and the matrix fused multiply-add (MFMA) instruction shape. The number of compute units (CUs) determines occupancy and flags when tile choices under-utilize the device. The derivation is compositional and hierarchical: fused attention chains two GEMM operations with an online softmax, and the VGPR constraint must account for all live arrays at the synchronization point between the two GEMMs, the tightest register moment in the kernel. The tree-based algorithm description makes each constraint explicit, checkable, and composable across operator levels.

Contributions.

  • A hierarchical computational model (algorithm tree + visitor) that separates the description of an operator from its hardware mapping ( §2\S2).

  • A hardware descriptor abstraction (MFMAAtom, HardwareDescriptor) that encodes the essential hardware parameters and enables portability across CDNA GPUs ( §3\S3).

• Closed-formula tile derivation for GEMM, 2D convolution, softmax, and fused attention, connecting the two above ( §4–6\S4–6).

  • A FEASIBILITYVISITOR that checks VGPR and LDS constraints at each tree node and derives tile_Q_max and tile_KV_max parametrically ( §4\S4).

• Measurements on an AMD CDNA GPU validating the full derivation: GEMM at 12.3 TFLOPS (53% of MFMA peak); fused attention at 1.50×1.50\times over the unfused baseline at L=16384L=16384 with 129×129\times less high-bandwidth memory (HBM) traffic; and a documented correction to the matrix fused multiply-add register layout as described in the AMD instruction set architecture (ISA) reference ( §3.1\S3.1, §6.2\S6.2).

We are optimistic that the principal contribution of this work extends beyond the operators and the GPU we studied. The methodology rests on the ability of human and AI collaboration to produce precise mathematical descriptions of complex functions and clean, portable mappings to hardware. Given that description, the derivation is mechanical and the code follows.