BLAS has a fourth level now because the hardware grew one.
Every level of the Basic Linear Algebra Subprograms was a response to the widening gap between how fast a machine computes and how fast it can move data. Level 4 is the response to the gap that opened after 2016.
The BLAS hierarchy has been climbing an arithmetic-intensity ladder — flops performed per byte of memory traffic — since 1979. Level 1 (Lawson–Hanson–Kincaid–Krogh, 1979) standardized vector operations like axpy and dot: O(n) work on O(n) data, intensity O(1). Level 2 (1988) added matrix–vector operations like gemv: O(n²) on O(n²), still intensity O(1) — enough work per call to keep a Cray's vector pipelines full. Level 3 (1990) added matrix–matrix operations like gemm: O(n³) work on O(n²) data, the first level with intensity O(n) — the level where cache blocking lets each byte be reused ~n times. That single property is what made LAPACK and the cache-based machines of the late 1980s fit each other.
The pattern is explicit in the literature: each level raised flops-per-byte to track hardware whose compute outgrew its memory. Level 4 continues it. We define it as the operations that perform Θ(n⁴) arithmetic while touching only Θ(n²) data — intensity Θ(n²), quadratically above gemm.
| Level | Year | Archetype | Work | Data | Intensity | flop/byte @ n=1024 |
|---|---|---|---|---|---|---|
| BLAS-1 | 1979 | axpy, dot | O(n) | O(n) | O(1) | ~0.17 |
| BLAS-2 | 1988 | gemv | O(n²) | O(n²) | O(1) | ~0.5 |
| BLAS-3 | 1990 | gemm | O(n³) | O(n²) | O(n) | ~341 |
| BLAS-4 | 2026? | pairreduce | Θ(n⁴) | Θ(n²) | Θ(n²) | ~349,000 |
Intensities at fp16 (2 bytes/element); a BLAS-3 kernel stays compute-bound only by growing n without bound, while a BLAS-4 kernel is compute-bound at modest working-set sizes because its intensity climbs with n².
Why now: eight years where compute outran bandwidth 10-to-1
Between 2016 and 2024, dense half-precision matrix throughput rose about 106× (P100's 21 TFLOPS to B200's 2,250 TFLOPS) while HBM bandwidth rose only about 10.5× (0.73 → 7.7 TB/s). The machine balance point — the flop/byte ratio above which a kernel is compute-bound — marched from ~29 to ~295, and to ~584 (FP8) and ~1,169 (FP4) at the precisions Blackwell is built to sell. Any kernel that cannot supply hundreds of flops per byte is bandwidth-bound silicon.
gemm: name it, standardize it, and let hardware–software co-design converge on it.The n⁴ interactions must be a law, not a table.
A generic stored order-4 tensor is explicitly disqualified. The discipline that defines Level 4 is that every one of the n⁴ interactions is generated on the fly, by index and coordinate arithmetic, from Θ(n²) stored values.
The canonical skeleton is
with an associative — and normally commutative — reduction ⊕, so GPU tiles can stream sources through shared memory while a bounded output-accumulator state stays register-resident. A stored 4-tensor Tijkl fails on the spot: it is n⁴ data, and contracting it runs at memory speed. The whole value of Level 4 is that the n⁴ never exists in memory at all.
Scrub the problem size and watch the two regimes diverge. The materialized tensor grows as n⁴; the implicit generator's footprint stays at Θ(n²).
Two associativity properties do all the work. Commutativity + associativity of ⊕ license partitioning the source axis into arbitrary blocks, tree-combining partial states, and splitting the reduction across thousands of GPU cores — none of which is legal for an operation that must see all sources at once. This is exactly the algebra a semiring or a monoid provides, and it is why the accumulator can be a small, register-resident state rather than a full row of the interaction matrix.
One associative state turned attention compute-bound.
FlashAttention is a single hardcoded instance of the Level-4 skeleton. Watch the mechanism: source tiles stream once through shared memory while a three-number accumulator per query row absorbs the whole interaction — and the n² score matrix is never written.
The accumulator is a commutative monoid. For softmax it is the triple (m, ℓ, o) = (running max score, rescaled denominator, rescaled weighted value), merged between any two blocks by
m = max(m₁, m₂) ℓ = e^(m₁−m)·ℓ₁ + e^(m₂−m)·ℓ₂ o = e^(m₁−m)·o₁ + e^(m₂−m)·o₂
Swap that monoid for sum and you get a kernel matrix–vector product; for (min, argmin) you get k-nearest-neighbors; for logsumexp you get a Sinkhorn optimal-transport step or a kernel-density estimate. Same dataflow, same register discipline, different three-line merge. That interchangeability is the thesis of the whole report — and the reason a single primitive can stand behind a dozen named operations.
B4MR: one map-reduce skeleton, three output ranks.
The proposal survives adversarial verification largely intact. Its unifying object is a fused all-pairs interaction plus an associative reduction over n² resident objects — parameterized by a generator F, a monoid ⊕, a finalizer, and one selector for whether each output is a scalar, a vector, or a rank-1 operator update.
// B4MR — the Level-4 map-reduce. Sources never leave the tile pipeline. b4mr( targets X[M, d], sources Z[N, d], values V[N, e], theta, F: (x_p, z_q, v_q; theta) -> partial, // implicit interaction, c_F flops OPLUS: (state, partial) -> state, // associative, bounded O(1) state PHI: (state) -> out, // per-target finalize rank: { VECTOR | SCALAR | OP1 } // output shape / epilogue ) -> Y // rank = VECTOR : Y[M,m] — PAIRREDUCE / implicit-operator apply (attention, kernel sums, N-body) // rank = SCALAR : Y[b] — QFORM: fuse a final DOT / LSE / histogram, zero extra traffic // rank = OP1 : Y[n,n] — OUTERACC: each pair contributes a rank-1 update u_q u_qᵀ // Monoids ship as a tested enum: // SUM · LOGSUMEXP (online m,ℓ state) · MIN/MAX (+ argmin/argmax) · PROD // F ships from a fixed generator catalog (Gaussian, Coulomb, inner-product-then-monoid); // a JIT tier exposes user F for the open family — labeled library-level, not the ABI.
Verification forced one refinement to the original five-candidate proposal. The all-pairs core is genuinely a family — PAIRREDUCE is the general primitive, implicit-kernel apply is its coordinate/law-generated form, and the scalar QFORM is its terminal epilogue, not a separate operation. What robustly earns its own entry point beyond the core is the non-separable trilinear lift (TRIATTN) and the already-shipping scientific instance (the SYM2E Fock build). The shift- and group-indexed members and the time-indexed recurrence are structured-index or serial-composition variants whose high-value instances fall to FFT, doubling, or low-rank shortcuts.
Twelve operations, ranked by what survives the shortcuts.
Each candidate was expanded into a full dossier, then attacked by two independent skeptics — a complexity theorist hunting sub-quartic algorithms, and a library architect judging whether it could ship. Every candidate passed the validity gate; the discriminators are usefulness, shortcut-resistance, and hardware fit. Scores below are the conservative minimum of the two verifiers on each axis.
Composite = 0.4·usefulness + 0.3·shortcut-resistance + 0.2·hardware-fit + 0.1·generality, on a 0–10 scale. You can re-weight these in §7.
The core, up close
Change the semiring, change the meaning.
The clearest way to feel why the reduction operator is worth standardizing: hold the dataflow fixed — a kernel sliding over a grid, every input pair touched exactly once — and swap the algebra. Blur becomes dilation becomes erosion becomes a Minkowski sum. This is 2-D semiring convolution, the one candidate whose hard (tropical) case is conjecturally Θ(n⁴)-optimal.
Over an ordinary ring, the FFT demolishes this in O(n² log n) — direct n⁴ is indefensible past moderate n. But the (min,+) and (max,+) tropical semirings have no additive inverses, so no transform applies; under the standard MinConv conjecture the arbitrary-cost tropical case admits nothing substantially below Θ(n⁴). It is the only candidate in the roster carrying a hardness certificate — and the reason a semiring flag, not just a faster convolution, is the right abstraction. The same move GraphBLAS made for sparse matrix multiply.
Three public operations. Everything else is a configuration.
The standardization win of a new BLAS level is a small, testable API surface. The verification collapses the roster to one core skeleton plus two irreducible extensions — with QFORM, SYM2E, OUTERACC, BICOLL, PAIRREDUCE, and implicit-apply all expressed as configurations of the core.
b4tri earns a separate entry point because its reduction index is an ordered pair of sources and, under softmax, the trilinear score provably does not factor — so the direct n³·d form is forced for the exact variant. b4conv is standardized only for semirings without additive inverses, where FFT and NTT do not apply; for the ordinary ring case the library must dispatch to cuFFT/cuDNN. Deliberately excluded: the fused recurrence (a serial fold with Θ(n) critical-path depth, dominated by repeated squaring) and span-DP (a recurrence over its own outputs) — both ship as library-level recipes, not primitives.
Try the ranking yourself. The four axes are the discriminators the skeptics scored; drag the weights to your own priorities and watch the order re-settle. The default weighting reproduces the panel's ranking exactly.
What Level 4 is — and the four gates that decide it.
The instructive rejections sharpen the definition more than the acceptances do. A candidate is a Level-4 standard operation only if it clears four gates. Pick one and run it through.
The gates read: (1) implicit generation — are the n⁴ interactions generated from Θ(n²) data, never stored? (2) one-shot fold — is it a single associative reduction over stored inputs, not a serial composition or a recurrence over its own outputs? (3) shortcut-proof at scale — does real workload survive FFT / FMM / low-rank / doubling, or do shortcuts dominate almost everywhere? (4) bounded state — does a fixed-size accumulator stream on the GPU without atomics or serial depth? The rejections each fail a different gate, which is precisely their instructive value: Level 4 is a one-shot associative fold over stored inputs — not a serial composition, not a shortcut-dominated structured index, not a recurrence over its own outputs.
The name is unclaimed. The demand is not.
Searches across arXiv, the ACM DL, and netlib find no established use of "Level-4 BLAS" — the standard stops at Level 3. The nearest informal "fourth level," Batched BLAS, does not raise arithmetic intensity at all: a batch of B independent k×k GEMMs is still O(k) intensity, just wider. But the surrounding software landscape is a decade of the community rebuilding GEMM internals to fuse exactly this pattern.
The orthogonal effort is tensor-contraction standardization — cuTENSOR, TAPP, GETT, TBLIS, the Tensor Contraction Engine. But a general contraction of stored order-4 tensors materializes O(n⁴) data, which is precisely what the disqualification rule forbids; those operations remain BLAS-3-like in flops-per-byte-of-materialized-data. Level 4 is the genuinely higher rung: the n⁴ exists only in flight.
The candidate set and every score were produced by a multi-agent research workflow, not a single pass. 5 deep-dive agents expanded the seed proposals; 4 domain scouts (physics/chemistry, ML/statistics, algorithms/graphs, signal/geometry) hunted new candidates; a prior-art agent verified the BLAS history and the GPU datasheet numbers against vendor sources; and every surviving candidate was attacked by 2 independent adversarial verifiers — a complexity theorist tasked to find sub-quartic shortcuts, and a library architect tasked to judge shippability — before a synthesis pass ranked the field. Forty agents completed across the run.
One correction applied by hand: the source dossiers reported the materialized-tensor size as "40 TB at n=316," which is off by ~1000× (n⁴·4 bytes at n=316 is 40 GB). The §02 ledger computes the figure live and correctly — tens of terabytes require n ≈ 1500+. The GPU balance points, FlashAttention peak fractions, and complexity claims were checked against the cited sources and stand.