Provedsampleability-lawgrouped-query-attentiondecode
GQA sharing penalty, upper: for H probability rows, (Σ_j √(Σ_h π_hj²))² ≤ |H|², so sharing never costs more gathers than separate sampling
For all and , if and (given and ), then
What the notation means · or point at any symbol
- Type
- Type: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Type) - x ∈ TVariables
- H, J range over Type: the statement must hold for every choice. (
(H J : Type)) - Fintype
- Fintype: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Fintype) - f(x)Function application
- Fintype applied to H. Lean writes f x; papers write f(x). (
Fintype H) - ∀For all
- The statement after the comma holds for every h, j. (
∀ h j, 0 ≤ π h j) - ⟹Implies
- If J, then ℝ. (Between types, A → B is the type of functions from A to B.) (
J → ℝ) - ∑Summation
- Add up π(h, j) for every j. (
∑ j, π h j) - =Equality
- ∑ j, π(h, j) and 1 are the same. (
∑ j, π h j = 1) - √Square root
- The non-negative number whose square is ∑ h, π(h, j)^2. (
Real.sqrt (∑ h, π h j ^ 2)) - ≤At most
- 0 is less than or equal to π(h, j). (
0 ≤ π h j) - RReal numbers
- The real numbers: every point on the number line. (
ℝ) - πPi
- The ratio of a circle's circumference to its diameter, ≈ 3.14159. (
π) - aᵇPower
- π(h, j) raised to the power 2. (
π h j ^ 2) - (x : T)As real numbers
- card(H) read as an element of real numbers. Mathematicians leave this implicit; Lean needs it to know which kind of number is meant. (
(Fintype.card H : ℝ)) - card
- Fintype.card: a definition from the library, not special notation. Its name is its meaning; open it in Lean to see how it is defined. (
Fintype.card)
theorem gs-sharing-penalty-upper {H J : Type} [Fintype H] [Fintype J] (π : H → J → ℝ) (hπ : ∀ h j, 0 ≤ π h j) (hrow : ∀ h, ∑ j, π h j = 1) :
(∑ j, Real.sqrt (∑ h, π h j ^ 2)) ^ 2 ≤ (Fintype.card H : ℝ) ^ 2√(Σ_h x²) ≤ Σ_h x for x ≥ 0 gives A ≤ |H|, so ρ = A²/|H| ≤ |H|. Consequence: at per-head accuracy ε a KV group needs ρF²/ε² shared key gathers against |H|F²/ε² for separate exact sampling; sharing saves the factor |H|/ρ ∈ [1, |H|] of decode KV traffic, maximal when the group's heads attend alike. Part of 'The Sampleability Law' (GQA decode-traffic extension).
How it was proved
- Proved
- 5 October 2026
- By
- Ajax, with the agent “Baguette math & proofs (Claude Code, 2026-10-03)”
- Checked by
- Lean's kernel (Lean 4.33.1, with Mathlib); the proof is signed and replays offline
- Axioms
- Classical.choice, Quot.sound, propext
- Proof
- 22 lines of Lean
Sign in to see the proofThe proof, its signed report and its history.