# MoA-Structured Decode Attention DNF Derivation, KV-Cache Accumulation, GQA/MQA, and OpenACC Kernel

arXiv: https://arxiv.org/abs/2607.19456 · HTML: https://mlsanity.com/paper/2607.19456/

## Key facts

- Cited by 1 papers in the map (data through 14 Oct 2026).
- Placed in KV cache optimization, one of 12 directions in Efficient LLM inference and serving.
- Builds on 7 of its 12 references that are in the map.
- First posted on arXiv 21 Jul 2026.

## Placed in

- Efficient LLM inference and serving / [KV cache optimization](https://mlsanity.com/inference/kv-cache-optimization/)

## Builds on (most cited first, 7 of 7)

- [Attention Is All You Need](https://mlsanity.com/paper/1706.03762/) (2017)
- [FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness](https://mlsanity.com/paper/2205.14135/) (2022)
- [FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning](https://mlsanity.com/paper/2307.08691/) (2023)
- [GQA: Training Generalized Multi-Query Transformer Models from Multi-Head Checkpoints](https://mlsanity.com/paper/2305.13245/) (2023)
- [Fast Transformer Decoding: One Write-Head is All You Need](https://mlsanity.com/paper/1911.02150/) (2019)
- [From array algebra to energy efficiency on GPUs: Data and hardware shapes with dimension-lifting to optimize memory-processor layouts](https://mlsanity.com/paper/2306.11148/) (2023)
- [Attention at the Theoretical Minimum: A Mathematics of Arrays Framework for Memory-Optimal Transformer Kernels](https://mlsanity.com/paper/2606.07713/) (2026)

## Built on by (most cited first, 1 of 1)

- [Validating Memory-Optimal Transformer Kernels on Real Hardware: From Formal Derivation to Measured Performance Across Two HPC Clusters](https://mlsanity.com/paper/2609.33916/) (2026)

## Abstract (arXiv)

We derive four memory-optimal inference artifacts for transformer attention using the Mathematics of Arrays (MoA), each following directly from the forward-pass Denotational Normal Form (DNF) of with the query-row index fixed to the current decode step. The artifacts are: (1)~a single-query decode DNF in which the psi-reduction eliminates the K^top buffer algebraically, achieving (dk + ndk+ ndv+ dv)×4,B Dynamic Random Access Memory (DRAM) traffic result numerically verified to |err|_≤2×10-7; (2)~a C/OpenACC Graphics Processing Unit (GPU) kernel with Operational Normal Form (ONF) stride arithmetic and hardware-coalesced memory access, verified to |err|_∞=0 (exact IEEE-754 floating-point arithmetic); (3)~a multi-step KV-cache with O(dk+dv) per-step append via MoA concatenation #; and (4)~Grouped-Query Attention (GQA) and Multi-Query Attention (MQA) derived via psi-selection, achieving a proven frac hq  hkv  reduction in KV traffic. All programs are verified against PyTorch scaleddotproductattention.
