FlashAttention and Optimized Kernels
Block-wise exact attention is an algorithm; making it fast is a kernel. Both measured, plus an honest account of what could not be run here.
I implemented causal attention block by block in plain PyTorch, using online softmax, the mathematical technique behind FlashAttention. At 8,192 tokens in fp16, here is how it compared with direct attention and with one of PyTorch’s own fused kernels:
| Implementation | Extra peak allocation | Time |
|---|---|---|
| Direct attention (full score matrix) | 3,148 MiB | 67–71 ms |
| My block-wise version, plain PyTorch | 15.8 MiB | 1.12–1.21 s |
| PyTorch’s memory-efficient SDPA kernel (forced) | 12.0 MiB | 5.5–8.6× faster than direct |
(Extra peak allocation: additional PyTorch-allocated tensor memory during the call. Across 1,024–8,192 tokens, the fused kernel’s speed-up over direct attention ranged from 5.5× to 13.5×.)
The block-wise version used about 200 times less memory than direct attention, and ran 16–18 times slower. The fused kernel saved the same memory and was much faster.
All three compute the same causal attention, up to floating-point rounding, but they do not do the same work:
- Direct attention builds the full score and probability matrices and masks the future afterwards.
- My block-wise version keeps only small tiles and skips blocks entirely in the future, but every tile operation is a separate PyTorch call.
- The fused kernel does the tiling inside one compiled GPU kernel, avoiding both the big intermediates and the dispatch overhead.
So an algorithm, a framework implementation of it, and a compiled kernel are three different things to benchmark.
One limitation up front: FlashAttention itself was not run. With PyTorch 2.6.0+cu124 on the RTX 2060 (compute capability 7.5), PyTorch reported that it was not compiled with FlashAttention. Every timing here is either the plain-PyTorch tiling or the separate memory-efficient SDPA backend. Published FlashAttention results belong to their authors, not to this machine.
Where this sits
Attention and Its Computational Cost showed that direct attention materialises large score and probability tensors, and that the memory-efficient backend avoids that. Memory Bandwidth and Compute Bottlenecks built a three-term cost model and showed that fusion can remove an intermediate. This chapter asks two separate questions:
- Can online softmax compute attention without keeping the full score matrix? A question of mathematics and storage.
- Can an implementation make that fast? A question of execution.
The Inference Lab gains a readable, deliberately unfused tiled_attention, the partial-result combiner merge_partials, a simplified traffic model, an SDPA backend probe, and splitkv_decode, which demonstrates splitting the keys for decode without claiming the performance of a fused Flash-Decoding kernel. (The numerical reference throughout is direct attention in float64; tiled_attention is an inspectable implementation, not an oracle.)
For the Pi series, this is why long retrieved contexts, tool transcripts and conversation histories create a kernel-level cost that no algorithm name fixes by itself. Block-wise attention cuts temporary storage, but latency still depends on which kernel is available, the sequence shape, batching and the rest of the model. Record which attention implementation actually ran, and on what workload.
The online softmax
The problem. To compute attention in blocks, you need softmax over each query’s scores. But softmax divides by a sum over every visible key, and after seeing only the first block of keys you don’t know that sum yet. Storing all the scores until the end would defeat the point of blocking.
The idea. Keep a small running summary per query row, and correct it each time a new block arrives.
The summary. For a nonempty set of visible keys \(J\) (finite scores; masked keys excluded):
Combining two summaries. For two disjoint, nonempty key sets, rescale both to a common maximum and add:
What follows. Because merging is commutative and associative in exact arithmetic, blocks can be combined in any order, or in parallel. In floating point, different orders need not give identical bits. (The unit tests check two-way merges against ordinary softmax and with the operands swapped; a three-part associativity test, and handling of empty or fully masked partials, are still missing.)
Numerical stability. This is the stable softmax of Tokens, Embeddings and Probability, made incremental: whenever a block contains a new maximum, the factor \(e^{m_{\text{old}}-m_{\text{new}}}\) rescales what has accumulated, so nothing is exponentiated at a large positive value. With queries scaled by 30, the GPU test stayed within \(4.7\times10^{-5}\) of the float64 reference; a CPU unit test scales them by 40. Those are stability checks for finite inputs, not proof for every non-finite input or mask.
The algorithm. For each tile of \(B_q\) queries, sweep over blocks of \(B_k\) keys:
m, l, acc = -inf, 0, 0
for each tile of B_k keys (skip tiles wholly in the future if causal):
s = q_tile @ k_tile^T / sqrt(d) # [B_q, B_k], never written to main memory in a fused kernel
m' = max(m, rowmax(s))
p = exp(s - m')
l = l * exp(m - m') + rowsum(p)
acc = acc * exp(m - m') + p @ v_tile
m = m'
output_tile = acc / l
Only one \(B_q\times B_k\) score tile exists at a time. (Tiles wholly in the future can be skipped, but tiles on the diagonal still need masking inside.) In a fused kernel those intermediates stay on chip. In this book’s plain-PyTorch version, every line is an ordinary tensor and a separate operation. The same pseudocode explains both the memory saving and the slowness.
It is exact
The check. One sequence, 12 heads of dimension 64, causal attention, four tile shapes, \((B_q,B_k)\) of \((32,512)\), \((64,64)\), \((128,128)\) and \((256,64)\), at 512 and 2,048 tokens. Each output is compared with direct attention computed in float64 on the same already-rounded inputs.
| Precision | Maximum absolute output difference against float64 reference, across tested shapes and lengths |
|---|---|
| fp32 | \(8.2\times10^{-7}\) to \(1.25\times10^{-6}\) |
| fp16 | \(9.3\times10^{-4}\) to \(9.7\times10^{-4}\) |
The errors stay in the same narrow range across all four tile shapes, which supports numerical equivalence for these configurations. (It does not show identical intermediate precision across kernels, and the fp16 errors are not shown to come only from output rounding. Decoding, other masks, dropout and other head sizes were not covered. Stronger regression tests would add relative error, finiteness checks, several seeds and token decisions near argmax ties.)
The causal saving, counted. Key tiles entirely in a query tile’s future can be skipped. At 2,048 positions, 128×128 blocks visited 136 of 256 possible tile pairs (53.125%), and 64×64 blocks visited 528 of 1,024 (51.5625%). These are counts of tiles visited, not executed FLOPs or memory traffic: diagonal tiles still hold masked entries. So the arithmetic saving approaches one half for long sequences, but the time saved depends on the implementation, as Attention and Its Computational Cost showed.
What it saves: traffic
The argument. Direct attention writes the \(T\times T\) score and probability matrices to high-bandwidth memory (HBM) and reads them back several times. Tiling avoids that. How much traffic does that save?
A simplified model. The Lab counts selected reads and writes per head and sequence. This is a modelled count, not a measured trace.
For direct attention (dense, even with a causal mask):
For an ideal fused causal kernel, Q and O move once, and K and V are re-read once for each query tile; a tile ending at position \(e\) reads only the first \(e\) keys:
The Lab’s counting functions give, in fp16 MiB per head:
| Tokens | Naive | Tiled, \(B_q = 64\) | \(B_q = 128\) | \(B_q = 256\) |
|---|---|---|---|---|
| 1,024 | 12.5 MiB | 2.4 MiB (5.3×) | 1.4 MiB (9.1×) | 0.9 MiB (14.3×) |
| 4,096 | 194 MiB | 33.5 MiB (5.8×) | 17.5 MiB (11.1×) | 9.5 MiB (20.4×) |
| 8,192 | 772 MiB | 131 MiB (5.9×) | 67 MiB (11.5×) | 35 MiB (22.1×) |
| 16,384 | 3,080 MiB | 518 MiB (5.9×) | 262 MiB (11.8×) | 134 MiB (23.0×) |
(Modelled transfers, not allocations or measured traffic.)
Why not just use enormous tiles? Real kernels are constrained by shared memory and registers, occupancy, tensor-core tile shapes, masking and scheduling. Doubling \(B_q\) is not always possible, or twice as effective, and the model ignores spilling, extra passes and L2 reuse. This is FlashAttention’s IO-awareness in simplified form, not the paper’s full analysis. The memory-efficient backend measured below does not report its tile sizes, so \(B_q=128\) is an illustration, not a known implementation detail.
What it saves: the numbers
The set-up. fp16, batch 1, 12 heads of dimension 64, causal, 1,024–8,192 tokens. Direct attention, plain-PyTorch tiled_attention with 128×128 blocks, and the forced SDPBackend.EFFICIENT_ATTENTION, all on the same inputs, with warm-ups and CUDA-event timing (ten samples for direct and fused, four for tiled). The command ran twice. Memory is extra peak PyTorch allocation above the inputs, not HBM traffic or total device memory.
| Tokens | Naive | Block-wise in plain PyTorch (128 × 128) | Fused memory-efficient kernel |
|---|---|---|---|
| 1,024 | 1.07 ms, 50.5 MiB | 23 – 24 ms, 5.3 MiB | 0.14 ms, 1.5 MiB |
| 2,048 | 5.7 ms, 200 MiB | 74 – 79 ms, 6.8 MiB | 0.42 ms, 3.0 MiB |
| 4,096 | 18.6 ms, 790 MiB | 282 – 318 ms, 9.8 MiB | 1.97 – 1.98 ms, 6.0 MiB |
| 8,192 | 67 – 72 ms, 3,148 MiB | 1,124 – 1,205 ms, 15.8 MiB | 7.8 – 13.0 ms, 12.0 MiB |
Memory: both tiled implementations avoid the full score tensor, so their peaks stay small.
Time: the plain-PyTorch version took 13.1–22.7 times as long as direct attention. The fused kernel ran about 7.8–13.5 times faster for 1,024–4,096 tokens and 5.5–8.6 times faster at 8,192. (These ranges belong to this build and GPU.) Notice that the fastest implementation was neither the reference formula nor the readable loop, but a separately compiled kernel that ran only because the experiment explicitly requested it.
Why is plain-PyTorch tiling so slow?
Count the work. At 8,192 tokens with 128×128 blocks, the loop visits 2,080 causal tile pairs, and each pair runs several PyTorch operations: matrix products, masking, reductions, exponentials and updates to the running statistics. Each can launch its own GPU kernel and create a temporary tensor. At an informal estimate of about fourteen operations per pair, that is tens of thousands of framework operations for one attention call.
(That is an estimate, not a measured kernel count: some operations may fuse or take different paths, and the per-call dispatch costs measured in earlier chapters cannot be applied here as a constant. A CPU/GPU timeline or kernel trace would be needed to attribute the 1.12–1.21 seconds.)
So: eager tiling cuts peak memory, but guarantees neither less total traffic nor less time. It reads and writes its small tile tensors and running statistics over and over. A fused kernel can keep that state on chip and avoid the dispatch overhead. Even fusion is not a universal speed-up: shape, occupancy, memory hierarchy and kernel availability decide. What this comparison shows directly is the memory saving; what it shows empirically is a large timing difference associated with fusion. Neither implementation’s HBM traffic was measured.
Does the traffic model predict the speed-up?
At \(B_q=128\), the model’s naive-to-tiled ratios are 9.1, 10.3, 11.1 and 11.5 at 1,024, 2,048, 4,096 and 8,192 tokens. The measured direct-to-fused time ratios were about 7.8–7.9, 13.5, 9.4–9.5 and 5.5–8.6.
Same order of magnitude, but not the same trend: the model’s ratio rises with length, while the measured ratio falls at 8,192. The magnitude is consistent with avoiding score-matrix materialisation; nothing more. The agreement does not validate the assumed tile size, or show that time is proportional to modelled traffic. Direct attention also pays for dense arithmetic, masking and launches, while the fused kernel may skip triangular work and use different instructions. And the fused 8,192-token time alone varied from 7.77 to 12.95 ms between runs. Treat this as a consistency check until hardware counters and kernel identification are available.
Which kernel ran
scaled_dot_product_attention is an interface, not a promise about which CUDA kernel runs. The availability command forces each backend in turn, on fp16, batch 1, 12 heads, 256 tokens, dimension 64, and records whether it ran and what PyTorch said:
| Forced SDPA backend | Probe result | Relevant message from PyTorch 2.6.0+cu124 |
|---|---|---|
| Math | ran | No refusal |
| Memory-efficient | ran | No refusal |
| FlashAttention | unavailable | “Torch was not compiled with flash attention.” |
| cuDNN attention | unavailable | “cuDNN MHA only supports gpu architectures in the range [sm80, sm90]. Attempting to run on a sm 7.5 gpu.” |
(The probe also logged messages about other backends being disabled by the forced selection; those are not reasons for the failures.)
Reading the refusals. The FlashAttention refusal, as reported, is about how this PyTorch build was compiled. The cuDNN refusal, as reported, is about the RTX 2060’s sm 7.5 capability. Neither establishes whether separately distributed FlashAttention kernels support this GPU, and neither should be extrapolated to later PyTorch releases. These results describe eligibility for the probed shape in this environment; other masks, dtypes and shapes can change dispatch. (The Chapter 8 measurements were already labelled as not FlashAttention, so nothing there needs reclassifying.) A reproducible backend report includes the tested shape, dtype, mask settings, software build and selection mechanism alongside the message.
What the published papers report (their results, on their hardware, not measured here):
- FlashAttention (Dao and collaborators, NeurIPS 2022) established IO-aware exact attention and reported gains on its evaluated hardware.
- FlashAttention-2 (ICLR 2024) improved work partitioning and reduced non-matmul overhead; the authors report roughly 2× over the first version and 50–73% of theoretical arithmetic peak on an NVIDIA A100.
What this Lab establishes is narrower: a forced, fused memory-efficient SDPA kernel computed the tested causal attention quickly while avoiding a quadratic peak allocation. Chapter 8’s estimate for it, about 17.3 TFLOP/s, used a causal-pair counting convention and was about 55% of the best fp16 matrix-product rate measured in Matrix Multiplication and GPU Execution. That estimate rests on Chapter 8’s 5.97 ms timing at 8,192 tokens; this chapter’s runs of the same backend and shape took 7.77–12.95 ms, so the rate is session-dependent. It is also a ratio between a modelled rate and an observed one, not hardware utilisation and not a FlashAttention measurement; the backend and counting convention must always travel with the number.
The decode shape: splitting the keys
The question. In Attention and Its Computational Cost, one-query decode attention at batch 1 reached only about 50 GB/s (nominal KV-cache bytes divided by time, not a hardware counter). One possible reason is too little parallel work: only 12 heads to spread across the GPU. Can splitting the keys create more?
The idea. The Flash-Decoding approach (described in an article by the PyTorch team) divides the keys and values into segments, computes a partial online-softmax summary for each segment in parallel, and merges them with exactly the rule above. This chapter tests the numerics with ordinary PyTorch operations; it does not implement or benchmark the article’s fused kernels.
The numerics hold. splitkv_decode agreed with direct float64 attention to within about \(2.5\times10^{-5}\) to \(2.2\times10^{-4}\) in the recorded sweeps. That is equivalence within observed tolerance, not bit-exactness: the code casts partial probabilities to the value dtype before its matrix product. CPU unit tests cover 1, 2, 3, 4, 8, 12 and 96 splits.
The speed does not show a clear pattern. The implementation reshapes keys into a split axis and uses separate PyTorch operations for the products and the merge. Nothing guarantees that the splits become independent, well-occupied GPU work in the way Flash-Decoding intends. Across two runs:
| Key length | Batch | Forced memory-efficient SDPA | Eager split-KV, across 1–64 splits |
|---|---|---|---|
| 1,024 | 1 | 88–99 µs | 412–724 µs |
| 4,096 | 1 | 252–253 µs | 583–856 µs |
| 16,384 | 1 | 992–998 µs | 571–767 µs |
| 16,384 | 4 | 1,158–1,162 µs | 993–1,066 µs |
At 1,024 and 4,096 keys, eager split-KV was slower than the fused kernel. At 16,384 keys it was faster, but it was faster even with one split, so the gain cannot be credited to splitting. The number of splits showed no robust trend, and the fastest split count changed between runs.
So the occupancy hypothesis remains untested. This experiment neither validates split-KV parallelism nor refutes the published approach. Plain-PyTorch overhead, different matrix-product shapes, temporary storage and the merge all affect it. (For scale: 48 MiB of nominal batch-1 cache traffic at about 300 GB/s is about 0.17 ms, an illustrative bandwidth term, not a bound on the full operation.) A decisive test would keep the kernel family and inputs fixed and record kernel launches, occupancy, HBM and L2 bytes and end-to-end latency as the split count changes.
One measured reversal remains. At 16,384 keys, batch 1, the eager version with a single split took about 571–751 µs, against 992–998 µs for the forced fused kernel. As nominal bytes per second, that is about 67–88 GB/s against 50 GB/s (derived ratios, not measured throughput). Matrix-product scheduling, allocation, caching or other effects could explain it. Without instrumentation, it is a measured reversal with no established cause.
Other kernels
The same principle, avoiding intermediates and separate dispatches, applies well beyond attention. These are possible fusion opportunities, not speed-ups measured here, and each is valid only if the fused version keeps the intended numerical semantics:
- residual addition with the following layer normalisation;
- bias and GELU after a matrix product;
- query/key/value projection with layout changes and related pointwise operations, where shapes allow;
- rotary position transforms, for architectures that use them (GPT-2 in this Lab does not);
- packed-weight dequantisation inside the matrix product, the missing path identified in Quantization and Numerical Precision;
- token filtering and sampling, where extra sorting or intermediates can be avoided without changing the sampling rule.
Memory Bandwidth and Compute Bottlenecks measured one concrete case: a fused multiply-add about 1.54–1.59× faster than two separate operations on large vectors, close to its predicted ratio. That motivates this list; it does not establish a speed-up for any item on it. For each, the Lab should first specify mathematical equivalence, then record numerical error, backend availability, intermediate allocation, time, and hardware and shape constraints.
Inference Lab increment
The Lab now has:
tiled_attention(q, k, v, causal, block_q, block_k): an eager block-wise reference that reports visited and possible tile pairs. It assumes equal query and key lengths and ordinary multi-head shapes.merge_partials(m1, l1, o1, m2, l2, o2): the online-softmax merge. Tests cover two-way equivalence and swapped order; a three-way associativity test is still needed.splitkv_decode(q, k, v, splits): an eager one-query split formulation tested against direct attention, not a fused Flash-Decoding kernel.naive_hbm_elements,tiled_hbm_elementsandtraffic_ratio: simplified transfer counts, not measured HBM activity.availability,exactness,traffic,python_tiledandsplitkv: reproducible commands for this chapter’s probes and tables, subject to backend and hardware availability.
The standing rule for attention results: report (1) the mathematical operation and error tolerance, (2) the concrete implementation and the forced or verified backend, (3) the input shape and environment, and (4) time and memory, each with its definition. A proof that scores need not be materialised is not a speed-up. One fast implementation does not make every kernel in its family fast. And an unavailable backend is a fact about that build and probe, not a verdict on the hardware.
Limits of this chapter’s evidence
About the set-up
- No FlashAttention run. Only eager tiling and the forced memory-efficient SDPA backend were timed.
- One machine, one build. RTX 2060 (sm 7.5), PyTorch 2.6.0+cu124, Windows WDDM; a different build or mask can change dispatch.
- Fixed shapes. fp16, batch 1, 12 heads of dimension 64, causal; split-KV adds batches 1 and 4. Forward inference only: no backward pass, dropout, ragged batches, grouped-query attention, scheduler or multi-GPU runs.
About the measurements
- Traffic is modelled. No memory-controller counters; the model omits temporaries, mask bytes, caching, spilling and tile resources. The fused kernel’s tile sizes are unknown.
- Allocator peaks are not physical memory or traffic.
- Timing varied. At 8,192 tokens the fused kernel gave 7.77 ms in one run and 12.95 ms in the other; the cause was not isolated.
- Operation counts for eager tiling are estimates; kernels and host scheduling were not traced.
About the numerics and the hypothesis
- Limited numerical scope. Fixed inputs and few shapes; three-way associativity, empty sets, NaN/Inf and end-to-end token decisions not tested comprehensively.
- The split-KV occupancy hypothesis is untested: no fused split-KV kernel, occupancy counters or controlled scaling study.
What you should now be able to do
- Derive the online-softmax summary and the two-part merge, and prove the merge associative over nonempty key sets in exact arithmetic.
- Distinguish that mathematical associativity from bit-for-bit order independence in floating point.
- Compute the modelled direct-versus-fused traffic ratio, and say what the model leaves out.
- Explain how eager tiling can cut peak memory and still run slower, through many separate operations.
- Report a forced SDPA backend together with the shape, dtype and mask used to probe it.
- Compare a fused output with direct float64 attention against a stated tolerance.
- Explain why split-KV is an exact decomposition that still does not guarantee a speed-up without real GPU parallelism.
- Keep local measurements, analytic estimates, untested hypotheses and published FlashAttention results apart.
So far, every cache in this book has been one contiguous block of memory per sequence. With many sequences of unpredictable length, that wastes space. PagedAttention borrows paging from operating systems to allocate the KV cache in small blocks instead, and measures what that saves and what it costs.
Key terms
- Online softmax: maintaining a running maximum and normaliser while processing scores in blocks.
- Partial result: the triple \((m,\ell,o)\) for a nonempty key subset: maximum, unnormalised exponential sum and unnormalised value-weighted sum.
- Merge rule: reweighting partial numerators and denominators to a common maximum before adding them.
- Tile: a block of query or key/value positions selected to exploit a memory hierarchy and available parallelism.
- IO-aware: an algorithm or kernel design that explicitly accounts for transfer costs between device-memory levels.
- Peak allocated tensor memory: the largest PyTorch-managed live allocation over a measurement interval, not measured HBM bytes transferred.
- Fused kernel: a compiled GPU execution path that combines operations while reducing intermediate materialisation or separate dispatches.
- Split-KV decoding: distributing key/value attention over partial key ranges and combining their normalised contributions.
- SDPA backend: a particular implementation eligible behind PyTorch’s attention API for the tested inputs.
- Effective byte rate: a modeled byte count divided by measured time; not a hardware counter.
Reader exercises
- Prove algebraically that
merge_partialsis associative for three nonempty key sets with finite scores. Then add an explicit \((A\oplus B)\oplus C\) versus \(A\oplus(B\oplus C)\) test. Report bitwise agreement separately from numerical tolerance. - Run
availabilityon your hardware with exactly the chapter’s fp16 shape. Repeat with fp32, causal masking and another head dimension; record the software build and each refusal reason. - Use \(6B_q/d\) to predict the asymptotic modeled traffic ratio for several tile sizes. Explain why a measured timing speed-up cannot uniquely identify the actual tile size.
- Instrument eager
tiled_attentionusing a trace that records CUDA kernels and host-to-device scheduling. Compare actual kernel counts with the rough 2,080-pair operation estimate. - Repeat the eager attention test with 64, 256 and 512 query tiles, controlling for masking and memory use. Where do reduced iteration counts stop helping?
- Add tests for all-masked or empty partials, extreme finite scores and changes in merge order; decide whether the API should reject or explicitly handle each case.
- Repeat
splitkvwith repeated process runs and a controlled split-count sweep. Add a genuinely fused variant if your environment supports one; measure hardware occupancy and the memory hierarchy before attributing gains to splitting. - Check the published FlashAttention and FlashAttention-2 claims against the hardware and kernel versions they actually report; distinguish their measured speed-ups from this chapter’s forced memory-efficient SDPA results.
References
The three primary research papers for this chapter are:
- Milakov and Gimelshein (2018), Online normalizer calculation for softmax — establishes the stable online normaliser and associative partial reduction in exact arithmetic; this Lab extends the partial state with a value-weighted numerator.
- Dao et al. (2022), FlashAttention: Fast and Memory-Efficient Exact Attention with IO-Awareness — IO-aware attention tiling, its HBM/SRAM reasoning and an exact fused implementation. Its kernel was not run here.
- Dao (2023; ICLR 2024), FlashAttention-2: Faster Attention with Better Parallelism and Work Partitioning — reduces non-matmul overhead and improves work partitioning; the reported A100 gains belong to that paper, not this GPU.
Additional implementation context: Rabe and Staats (2021), Self-attention Does Not Need O(n²) Memory distinguishes memory complexity from runtime; PyTorch SDPA API documents backend eligibility and numerical differences; PyTorch Flash-Decoding describes split-key parallelism, which this Lab did not reproduce as a fused kernel.
Evidence in this chapter
| Claim | Status and evidence boundary |
|---|---|
| Online softmax merges nonempty partial results without changing the attention function in exact arithmetic | Established by the online-normaliser and FlashAttention research; two-way merge tested locally; three-way associativity test still needed |
| Eager tiled attention matches the float64 direct formula to the reported fp16/fp32 tolerances | Local GPU results, two lengths and four tile shapes |
| Causal blocking skips wholly future tile pairs | Local block-count result; pair counts are not executed FLOP counters |
| \(4Td+6T^2\) versus \(2Td+\sum 2ed\) and limiting ratio \(6B_q/d\) | Simplified analytical element-transfer model; not measured physical HBM traffic |
| At 8,192 tokens, eager tiling uses 15.8 MiB versus 3,148 MiB for direct attention and is approximately 16–18× slower | Local result; peak PyTorch allocated tensor memory and CUDA-event time |
| Forced memory-efficient SDPA is 5.5–13.5× faster than direct attention across tested lengths | Local result; not a FlashAttention measurement; 8,192 timings varied between runs |
| FlashAttention backend refused because of the PyTorch build; cuDNN attention refused due to sm 7.5 | PyTorch warnings for the specific probe shape and software environment |
| FlashAttention-2 provides approximately 2× the first version and 50–73% peak on an A100 | External paper’s published result; not reproduced locally |
| Split-KV results agree numerically with a float64 reference | Local results with the stated tolerances; not bitwise identity |
| More key splits improve batch-1 occupancy and performance | Hypothesis not established by the eager-PyTorch implementation |
| At 16,384 keys, single-split eager PyTorch was faster than forced efficient SDPA | Local timing comparison; explanation and actual memory-traffic difference unmeasured |
| Fused split-KV, hardware counter attribution, training/backward, GQA, general hardware | Not measured |