Float bounds of reductions: any tree, butterflies of any width, block trees, mean, variance, max-subtracted exponential sums, the compiled exponential and log-softmax
Lean: MojoProof/Float/Tree.lean, MojoProof/Float/Halve.lean, MojoProof/Float/Stats.lean,
MojoProof/Float/ExpSum.lean, MojoProof/Float/Ex2.lean and the additions to
MojoProof/Sem/Bfly.lean and MojoProofTest/Bfly.lean. Instances: MojoProofTest/FloatTree.lean,
MojoProofTest/FloatStats.lean and MojoProofTest/FloatEx2.lean. Welford's one-pass mean and
variance are in docs/proofs/float-welford.md, layer norm's and RMS norm's outputs in
docs/proofs/float-norm.md. Floats are FloatLib's
Model fmt words; u = Model.unitRoundoffAt fmt is FloatLib's unit roundoff and
η = Model.underflowErrorAt fmt its underflow allowance. MixedError x x₀ r a is FloatLib's
|x - x₀| ≤ r · |x₀| + a with r, a ≥ 0 (FloatLib/Numerics/MixedError/Basic.lean).
Every statement here is about words and the trees of operations a kernel performs on them, as
functions of the inputs. That a grid run of a kernel performs those operations is not proved here
(see "Not proved"). The statements hold in every IEEE format (fmt.isIEEE = true), for every
length and every tree as stated; none of them is about one program.
The shape of every bound
Each headline result has the shape of a kernel theorem's float clause (matmul_error in
MojoProofTest/NaiveKernel.lean): for every input meeting the premises, if the computed word is
finite then its real value is within the stated bound of the exact real value, and that exact
value is TorchLean's real specification where TorchLean has one. Nothing is claimed when the
computed word is infinite or a NaN.
Statements
Any tree (MojoProof/Float/Tree.lean)
graft t f replaces each leaf j of a FloatLib ReductionTree by the tree f j: the tree of a
reduction whose inputs are themselves reductions (a block reduction over the warps' butterflies).
FloatLib has no such operation.
roundsTree r ps c and rounds combine r ps v c are rounds of a per-cell step over cells
numbered by Nat: in round p, cell c's new value is the tree r p c of cell numbers
evaluated at the values before the round. A block's shared-memory halving round is such a
step. roundsTree r ps c is defined by recursion on the rounds: the leaf c with no rounds, and
after p :: ps the tree after ps with each cell c' replaced by the first round's tree
r p c'.
eval_graft,leaves_graft,depth_graft: for every carrier, combining operation and pairt,f, evaluatinggraft t fis evaluatingtat the values of thef j; its leaves are those of thef j,jalongt's leaves; if everyf jat a leaf ofthas depthd, its depth ist.depth + d.eval_roundsTree: cellc's value after the rounds is the evaluation ofroundsTree r ps c.leaves_graft_range: ift's leaves are a permutation of0, …, W - 1and the leaves of eachf w,w < W, are a permutation ofb·w, …, b·w + b - 1, the leaves ofgraft t fare a permutation of0, …, W·b - 1.finiteEval_of_isFinite,isFinite_of_mem_leaves: in every IEEE format, a tree ofModel.addwhose root is finite is FloatLib'sModel.ReductionTree.FiniteEval(every node's sum finite), and every leaf of such a tree is finite.eval_error: for every carrier, combining operation, values, mapinterpretto the reals,u ≥ 0, treetover any index type and listSsuch thatt's leaves are a permutation ofS: if every combination at a node oftis withinu · (|x| + |y|)of its operands' exact sum, the result is within((1 + u) ^ t.depth - 1) · Σ_{j∈S} |v j|ofΣ_{j∈S} v j. It is FloatLib'sReductionTree.abs_eval_sub_exact_le_depthwith the sums taken overS.sum_error: in every IEEE format, for every treetwhose leaves are a permutation ofSand valuesv: ift.eval Model.add vis finite, everyv j,j ∈ S, is finite and the result is within((1 + u) ^ t.depth - 1) · Σ_{j∈S} |v j|ofΣ_{j∈S} v j. It rests on FloatLib'sModel.ReductionTree.abs_toReal_eval_sub_sum_le_depthand statement 3.sum_mixedError: the same tree with inputs that approximate exact realsw jwith mixed errors(r j, a j)when finite: the result has the absolute error((1 + u) ^ t.depth - 1) · Σ_{j∈S} |w j| + (1 + u) ^ t.depth · Σ_{j∈S} (r j · |w j| + a j)againstΣ_{j∈S} w j. This is the tree form of FloatLib's left-to-rightModel.mixedError_toReal_foldl_add_absolute, with the depth in place of the number of additions.
Butterflies of any width and order (MojoProof/Sem/Bfly.lean)
leaves_bfly: for everyk, every list of offsetsmsthat is a permutation of1, 2, 4, …, 2 ^ (k - 1)(any order of the rounds) and every lanel < 2 ^ k, the leaves ofbflyTree ms lare a permutation of0, …, 2 ^ k - 1.leaves_warpis its casek = 5atwarpOffsets.bfly_warp_errorandbfly_add_errorkeep their statements (bfly.md, statements 5 and 6) and are statement 4 and statement 5 att = bflyTree ms l,S = 0, …, w - 1. With statement 7, their width premise holds at every width2 ^ kand every order of the offsets.
Block reductions (MojoProof/Float/Halve.lean)
halveStep s c is the tree of cell c's value after the shared-memory halving round with stride
s: a cell c < s combines its value with cell c + s's, its own first; the other cells keep
theirs. The strides 2 ^ (k - 1), …, 2, 1 are the butterfly's offsets bflyOffsets k
(MojoProof/Sem/Bfly.lean), so the halving loop over 2 ^ k cells is
rounds combine halveStep (bflyOffsets k) and cell 0's tree is
roundsTree halveStep (bflyOffsets k) 0.
leaves_halve,depth_halve: for everyk, cell 0's leaves after the halving rounds over2 ^ kcells are a permutation of0, …, 2 ^ k - 1and its depth isk.halve_error: in every IEEE format, for everykand values: if cell 0's value after the halving rounds ofModel.addis finite, every input below2 ^ kis finite and the value is within((1 + u) ^ k - 1) · Σ_{j<2^k} |v j|ofΣ_{j<2^k} v j(statement 5).block_error: in every IEEE format, for every treeTwhose leaves are a permutation of theWwarps, offsetsmsthat are a permutation of1, …, 2 ^ (j - 1)and values of the threads (thread2 ^ j · w + lis lanelof warpw): if the sum alongTof each warp's lane 0 after its butterfly rounds is finite, every value belowW · 2 ^ jis finite and the sum is within((1 + u) ^ (T.depth + j) - 1) · Σ |v|ofΣ v. The two stages are one tree,graft T (fun w => (bflyTree ms 0).map (2 ^ j · w + ·)), whose depth is the sum of the two stages' depths. WithTcell 0's halving tree over2 ^ kwarps (statement 9) the depth isk + j.
Mean and variance, two passes (MojoProof/Float/Stats.lean)
mean t x N is the first pass: the n words x summed by Model.add along a tree t, divided
by a word N that denotes n. variance t₁ t₂ x N is the second: each difference of an input
with the mean word mean t₁ x N by Model.sub, squared by Model.mul, summed along a tree t₂
and divided by N. Each tree's leaves are a permutation of the n indices (List.finRange n);
the two trees are independent and of any shape. meanErr, devErr and varErr are the closed
forms of the absolute errors of the mean, of each difference and of the variance.
mean_error: in every IEEE format, for everyn, treet, inputsx : Fin n → Model fmtand finite wordNwhose real value isn: if the mean word is finite, every input is finite and the mean is withinMixedError … u (meanErr u η t.depth x)of the exact mean𝔼 j, x j(Mathlib'sFinset.expect), where `meanErr u η d x = (1 + u) · ((1 + u) ^ d - 1) · 𝔼 j, |x j|- η`.
var_error: under the same premises onN, for every two treest₁,t₂: if the variance word is finite, it is withinMixedError … u (varErr u η t₁.depth t₂.depth x)of TorchLean's population varianceTorchLean.varof the inputs' real values.𝔼andTorchLean.varare the two statistics of TorchLean's real layer normTorchLean.TransformerBlock.layerNorm.
The same module has RMS norm's mean of squares msq t x N and its bound msq_error
(docs/proofs/float-norm.md, statement 1).
Max-subtracted exponential sums and softmax (MojoProof/Float/ExpSum.lean)
The maximum is a tree of Model.maximumNumber (LLVM's maxnum) over the inputs. expTerm b x m j
is FloatLib's correctly rounded Model.Transcendentals.CorrectlyRounded.exp, with the search
budget b, of the rounded difference Model.sub (x j) m; the terms are summed along any tree
whose leaves are a permutation of the n indices; a softmax entry is Model.div of term j by
the sum. expSumErr u η d y is the closed form of the sum's absolute error,
`((1 + u) ^ d - 1) · Σ_j exp (y j) + (1 + u) ^ d · Σ_j (((1 + u) · exp (u · |y j|) - 1) · exp (y j)
- η)
, at the exact differencesy j = x j - m`.
max_exact: in every format, for every tree over any index type and inputs finite at its leaves, the tree's maximum is finite, its real value is one input's and it is at least every input's: the maximum is exact.expTerm_error: in every IEEE format, if the differenceModel.sub (x j) mand the term are finite, the term is withinMixedError … ((1 + u) · exp (u · |x j - m|) - 1) ηofexp (x j - m).expSum_error: in every IEEE format, for everyn, treet, inputs and wordm: if every differenceModel.sub (x j) mis finite and the sum of the terms alongtis finite, the sum is withinMixedError … 0 (expSumErr u η t.depth (x - m))ofΣ_j exp (x j - m).softmax_error: in every IEEE format, for everyn, treet, inputs, wordmwhose real value is some input's (the maximum of statement 14, or any input) and indexj, withAthe absolute error of statement 16: if every difference is finite,A < 1, the sum is finite and the entry is finite, the entry is withinMixedError … ((1 + u) · ((r + A) / (1 - A)) + u) ((1 + u) · η / (1 - A) + η)of TorchLean's real softmaxTorchLean.TransformerBlock.softmax Finset.univ x j, withr = (1 + u) · exp (u · |x j - m|) - 1. The exponential of-∞is+0, a finite word, so the differences' finiteness is a premise and not a consequence of the entry's.
The compiled exponential (MojoProof/Float/Ex2.lean)
Mojo's exp on float32 is not a correctly rounded exponential. Its NVPTX lowering of
exp (x - m) is fsub contract, fmul contract by the word 0x3FB8AA3B of log₂ e (log2e)
and the instruction ex2.approx.ftz.f32 as inline assembly (the standard library's math.exp). A
subtraction followed by a multiplication cannot contract, so the instruction's operand is
Model.mul (Model.sub x m) log2e. PTX ISA 9.5 §9.7.3.21 states its accuracy: at most 2 ulp from
the correctly rounded result across the full range of inputs, with subnormal inputs and results
flushed to zero of their sign. Its consequence at a finite operand a < 128 is the contract
Ex2Close a w: the word w is finite and within ex2Err · 2 ^ a + ex2Tiny of 2 ^ a, with
ex2Err = 3 · 2 ^ -23 (two ulp of a normal value c are at most 2 ^ -22 · c, and the correctly
rounded c is within 2 ^ -24 · 2 ^ a of 2 ^ a) and ex2Tiny = 2 ^ -126 (a flushed result, a
result near the subnormal range or the 1 of a flushed subnormal operand). The contract is an
assumption on the hardware, as rsqrt.approx's is; the execution model stops at inline assembly.
ex2Rel u η ρ y = (1 + ex2Err) · exp (((1 + u) · (u + ρ + u ρ) + u) · |y| + η · log 2) - 1 is one
term's relative error.
log2e_close: the wordlog2e(12102203 / 2 ^ 23) is withinMixedError … 2 ^ -26 0of1 / log 2.ex2_error: for every binary32 multiplier wordLwithinMixedError … ρ 0of1 / log 2and wordsx,m,w: if the operandModel.mul (Model.sub x m) Lis finite andwmeets the contract there,wis withinMixedError … (ex2Rel u η ρ (x - m)) ex2Tinyofexp (x - m).ex2Sum_error: for everyn, treetwhose leaves are a permutation of thenindices, suchL, wordsx, wordmand term wordse: if every operand is finite, everye jmeets the contract at its operand and the sum of thee jalongtis finite, the sum is withinMixedError … 0 (((1 + u) ^ d - 1) · Σ_j exp (y j) + (1 + u) ^ d · Σ_j (ex2Rel u η ρ (y j) · exp (y j) + ex2Tiny))ofΣ_j exp (x j - m), withy j = x j - mandd = t.depth: statement 16's form with the compiled term's error.
Log-sum-exp and log-softmax (MojoProof/Float/ExpSum.lean)
lse t b c x m is Model.add m (log s) and logSoftmax t b c x m j is
Model.sub (Model.sub (x j) m) (log s), with s the sum of statement 16 and log FloatLib's
correctly rounded Model.Transcendentals.CorrectlyRounded.log with the search budget c. The
entry is in the order of Mojo's three-pass CPU log-softmax (max/kernels/src/nn/softmax.mojo,
_softmax_3_pass_base with identity, exp, log and sub): it stores x j - m, sums the
exponentials and subtracts the logarithm of the sum. With S = Σ_j exp (x j - m) and A the
absolute error of statement 16:
lse_error: in every IEEE format, for everyn, treet, budgets, inputs and wordmwhose real value is some input's: if every difference is finite,A < 1, the sum is finite andlseis finite, it is within `MixedError … u ((1 + u) · (u · log S + (1 + u) · -log (1 - A)- η))
oflog Σ_j exp (x j)`.
- η))
logSoftmax_error: under the same premises with the entryjfinite in place oflse, the entry is withinMixedError … u ((1 + u) · (u · |x j - m| + (u · log S + (1 + u) · -log (1 - A) + η)))ofx j - log Σ_i exp (x i). TorchLean has no log-softmax over the reals as a function ofFin n → ℝin the modules built here; itsTorchLean.Roundoff.CrossEntropy.log_probs_reference(TorchLean/Verify/RuntimeApprox/Roundoff/CrossEntropy.lean, not built here) states its reference in this real form, which is written out here rather than defined a second time.
The relative part u is of the result itself; the absolute part grows with log S ≤ log n and,
through -log (1 - A), with the sum's error.
Masked inputs (MojoProof/Float/ExpSum.lean)
A masked input is -∞: less a finite m, its difference is -∞, whose correctly rounded
exponential is +0, an exact zero of the sum. maskErr U u η d y is expSumErr's form with both
sums over the kept indices U, and expSumErr is maskErr with every index kept.
expTerm_negInf: in every format, if the differenceModel.sub (x j) mis-∞(infinite with its sign bit set), the termexpTerm b x m jis the word+0.maskSum_error: in every IEEE format, for everyn, treet, inputs, wordmand setUof kept indices: if the difference is finite at everyj ∈ Uand-∞at every other index and the sum of the terms alongtis finite, the sum is withinMixedError … 0 (maskErr U u η t.depth (x - m))ofΣ_{j ∈ U} exp (x j - m).maskSoftmax_error: in every IEEE format, for everyn, treet, inputs, setU, wordmwhose real value is some kept input's and indexj ∈ U, withA = maskErr U u η t.depth (x - m): if the differences are as in statement 24,A < 1, the sum is finite and the entry is finite, the entry is within statement 17's mixed error with thisAof TorchLean's real softmax over the kept indicesTorchLean.TransformerBlock.softmax U x j.
Statements 16 and 17 are statements 24 and 25 with every index kept, and are proved so.
The entry in the kernel's order (MojoProof/Float/ExpSum.lean)
Mojo's GPU softmax computes an entry as e_j * (1 / s): the reciprocal of the sum rounded, then
the product, where statements 17 and 25 take one Model.div e_j s. With r = termErr u (x j - m)
= (1 + u) · exp (u · |x j - m|) - 1, the term's relative error of statement 15, and
q = recipErr u A = (1 + u) · (A / (1 - A)) + u, the reciprocal's:
softmaxRecip_error: in every IEEE format, for everyn, treet, inputs, setU, wordmwhose real value is some kept input's and indexj ∈ U, under statement 25's premises on the differences,A < 1and the sum: if the entryModel.mul (expTerm b x m j) (Model.div 1 s)is finite, it is withinMixedError … ((1 + u) · (r + q + r · q) + u) ((1 + u) · ((1 + q) · η + (1 + r) · η · exp (x j - m) + η²) + η)of TorchLean's real softmax over the kept indicesTorchLean.TransformerBlock.softmax U x j;U = Finset.univis the unmasked softmax of statement 17.
Instances (MojoProofTest/FloatTree.lean, MojoProofTest/FloatStats.lean, MojoProofTest/FloatEx2.lean)
Each headline statement has one binary32 instance whose premises are discharged by evaluation
(decide +kernel): chain_error, chain_mixed (statements 5 and 6 at a loop), halve_ones
(statement 10 over 8 cells), block_ones and block_ones8 (statement 11 with two warps and
with four groups of 8 lanes), mean_xs and var_xs
(statements 12 and 13 at the inputs 1, 2, 3, 4, the mean along a loop and the squares along a
pairwise tree), max_xs, term_xs, expSum_xs (statements 14 to 16), softmax_ones
(statement 17 at four inputs 1 shifted by their maximum, with A < 1 by norm_num on FloatLib's
binary32 constants in errA_lt), lse_ones and logSoftmax_ones (statements 21 and 22 under
softmax_ones's premises, with the correctly rounded logarithm of the sum 4), and
term_masked, maskSum_masked and maskSoftmax_masked (statements 23 to 25 at the inputs
1, -∞, 1, -∞ less 1, kept at 0 and 2, with A < 1 in errM_lt). Statement 26 has two,
softmaxRecip4 and softmaxRecip8, at four and eight inputs 1 less 1 along halveFin 2 and
halveFin 3, every index kept, each with A < 1 closed by the tactic recip_num. ex2_ones and
ex2Sum_ones are statements 19 and 20 at four inputs 1 less the word 1 with L = log2e: the
operand is +0, at which the word 1 meets the contract (zero_close). Each is one example, not
a claim about a program.
block_halve is statement 11 at the inputs 1 for every k halving rounds after j butterfly
rounds, its premise the finiteness of the sum word; block_ones and block_ones8 are its cases
at (1, 5) and (2, 3), declared by the command theorem name := e, a theorem without a type
(MojoProofTest/FloatTree.lean), which states the type of the term e. The inputs xs are iota 4, the words of 1, …, n at n = 4,
and pairs is halveFin 2, cell 0's halving tree over 2 ^ k cells with its leaves in
Fin (2 ^ k) at k = 2; iota_toReal, iota_bound, var_iota and msq_iota give their real
values, bound, variance (n ^ 2 - 1) / 12 and mean of squares (n + 1) (2 n + 1) / 6 at every
n ≤ 2 ^ 24 (MojoProofTest/FloatStats.lean). four_toReal and eight_toReal are nat32_toReal,
the real value of the word of a natural number m ≤ 2 ^ 24, at 4 and 8.
Proofs
- Induction on
t. The depth uses that everyf jhas the same depth att's leaves.eval_roundsTree: induction on the rounds, witheval_graftat the first one. - Statement 1 rewrites the leaves to a
flatMap; a permutation oft's leaves permutes theflatMap, and theflatMapover0, …, W - 1of the blocksb·w + ·is0, …, W·b - 1(induction onW,List.range_add). - A finite sum has finite operands (FloatLib's
Model.isFinite_of_isFinite_add); induction. - FloatLib's depth bound,
eval_add_eq_sumand the permutation on both sums. - Statement 3 on
t.map v, then FloatLib's IEEE depth bound and the permutation. - Statement 5, then the triangle inequality with each leaf's error, bounding
Σ |v j|byΣ |w j| + Σ (r j · |w j| + a j). - The leaves of
bflyTree ms lareL msXORl, withLthe leaves of lane 0. A round appendsLXORmtoL, two rounds commute up to a permutation, soLdepends only on the multiset of the offsets; at1, 2, …, 2 ^ (k - 1)in orderLis0, …, 2 ^ k - 1(List.range_add), and XOR withl < 2 ^ kpermutes that list (it has no duplicates and stays below2 ^ k). - Statement 4 or 5 rewritten by
eval_bflyTreeanddepth_bflyTree. - Induction on
k: by the definition ofroundsTree, cell 0's tree overbflyOffsets (k + 1)is its tree overbflyOffsets kwith each leafc < 2 ^ kreplaced by the pairc, c + 2 ^ k, so its leaves are those of0, …, 2 ^ k - 1followed by those shifted by2 ^ k(List.flatMap_append_perm,List.range_add), and its depth grows by 1 (statement 1). - Statement 5 at cell 0's tree, with
eval_roundsTreeand statement 9. - Statement 1 (
eval_graft, FloatLib'seval_map,eval_bflyTree) for the value, statement 2 with statement 7 at lane 0 for the leaves,depth_graftfor the depth, then statement 5. - Statement 5 as an absolute
MixedErrorof the sum, then FloatLib's quotient ruleModel.mixedError_toReal_divwith the exact divisorN(relative error 0);(Σ_j x j) / n = 𝔼 j, x j. - FloatLib's
Model.mixedError_toReal_subfor the difference with the mean of statement 12 andModel.mixedError_toReal_mulfor the square give each term's error against(x j - 𝔼 x) · (x j - 𝔼 x); statement 6 sums them alongt₂; the quotient rule divides byN;TorchLean.varis the mean of those squares. - Induction on the tree: at finite operands
maximumNumberismaximum(FloatLib'smaximumNumber_eq_maximum_of_not_isNaN), finite and the realmax(FloatLib'stoReal_maximum_eq_max_of_isFinite);max_choicepicks the side. - FloatLib's
toReal_exp_of_isFinite(a finite correctly rounded exponential of a finite argument is the rounded real exponential),Model.mixedError_toReal_subfor the difference andMixedError.trans_exp. - Statement 24 with every index kept.
- Statement 25 with every index kept.
log2e's value by evaluation, then Mathlib'sReal.log_two_gt_d9andReal.log_two_lt_d9:|log2e · log 2 - 1| ≤ 2 ^ -26.Model.mixedError_toReal_subfor the difference,Model.mixedError_toReal_mulwithL's error and FloatLib'sMixedError.const_mulbylog 2putlog 2 · pwithin((1 + u) · (u + ρ + u ρ) + u, η · log 2)ofx - m; then2 ^ p = exp (log 2 · p)and FloatLib'sMixedError.trans_expwith the contract.- Statement 6 with statement 19 at every leaf.
- Statement 17's relative error
Aof the sum (shared by a private lemma), FloatLib'stoReal_pos_of_isFinite_logandtoReal_log_of_isFinite(a finite correctly rounded logarithm of a finite input is the rounded real logarithm of a positive one), then FloatLib'sMixedError.trans_log, which needsA < 1, forlog S, andModel.mixedError_toReal_addwith the exactm;log S = log Σ_j exp (x j) - m(Real.exp_sub,Real.log_div) andlog S ≥ 0. - As statement 21, with
Model.mixedError_toReal_subfor the differencex j - mand for the entry. - FloatLib's correctly rounded exponential of an infinite word with its sign bit set is
+0by its definition (an infinite word is not a NaN, FloatLib'sModel.isNaN_eq_false_of_isInfinite_eq_true). - Statement 6 with the weights
exp (x j - m)at the kept leaves (statement 15) and0at the masked ones, whose terms are+0(statement 23), so of real value0with error(0, 0); a sum over every index of terms that are0outsideUis the sum overU(Mathlib'sFinset.sum_ite_mem). - The term at the kept
kisexp 0 = 1and every term is positive, so the exact sum overUis at least 1 and FloatLib'sMixedError.relative_of_le_absmakes the sum's absolute errorAa relative one; thenModel.mixedError_toReal_div, TorchLean'ssoftmax_eq_exp_sub_divoverU(the softmax isexp (x j - m) / Σ_{i ∈ U} exp (x i - m)for everym) andη / ((1 - A) · Σ) ≤ η / (1 - A). - Statement 25's relative error
Aof the sum (the same private lemma); FloatLib'sModel.mixedError_toReal_divwith the exact numerator1(Model.toReal_posOne) gives the reciprocal's error(q, η), andModel.mixedError_toReal_mulwith statement 15's term error the entry's (both factors are finite byModel.isFinite_of_isFinite_mul); thensoftmax_eq_exp_sub_div,a / Σ = a · (1 / Σ)and|1 / Σ| ≤ 1, asΣ ≥ 1.
Not proved
- That a grid run of a kernel computes these trees. The corpus's layer norm kernels
(tests/corpus/layernorm/) compute the mean and variance by Welford updates merged across lanes,
not by two passes, so statements 12 and 13 are not their bound (Welford's merge is bounded in
docs/proofs/float-welford.md); the corpus's reduction kernel sums
i32(tests/corpus/reduction/reduction_reduction_sum_kernel_SIMD_DTy6A6AcB6A6AcB_950d42eb4d93545d.nvptx.ll, lines 151-160), so no float bound applies to it. - A softmax entry with the compiled exponential: statement 20 bounds the sum, and statement 17's
form with
ex2Relis not stated. Nor is the-∞operand (its+0is outside the contract) or an operand of128or more. - RMS norm against TorchLean: TorchLean proves no closed form of
TorchLean.Tensor.rmsNorm(TorchLean/Tensor/Layers/Normalization.lean) over the reals, so docs/proofs/float-norm.md states RMS norm against the real value its docstring gives. TorchLean'sTorchLean.Roundoff.rms_norm_forward_error(TorchLean/Verify/RuntimeApprox/Roundoff/Operators.lean) boundsTorchLean.Tensor.rmsNormon its configured tensors with left-fold reductions. - Masked inputs in log-sum-exp and log-softmax (statements 21 and 22 keep every index), the
maximum of a tree with
-∞inputs (statement 14's inputs are finite; statement 25 takes anymwhose real value is a kept input's) and a row whose every input is masked. Nor is the log-softmax entry in the order of Mojo's GPU softmax kernel,log (e_j · (1 / s)), stated, nor with Mojo's ownlog, which is not FloatLib's correctly rounded one. - Any bound when a result is infinite or a NaN.
Related results elsewhere
These are about other carriers or orders and are not reproved here:
- TorchLean's
TorchLean.Roundoff.softmax_error(TorchLean/Verify/RuntimeApprox/Roundoff/Softmax.lean) bounds the stable softmax of its configured tensors, whose reductions are left folds; statements 14 to 17 are about FloatLib'sModelwords and any trees. - TorchLean's
TorchLean.TransformerBlock.Arithmetic.sqrt_sum_sq_layerNorm_sub_lebounds the whole layer norm for an abstract rounding of reals whose sums are indexed by their length; statements 12 and 13 are about words and any trees and stop at the two statistics. - TorchLean's ordered sums and maxima (
TorchLean.Roundoff.mixedError_ordered_sum,TorchLean.Roundoff.toReal_ordered_maximum, TorchLean/Verify/RuntimeApprox/Roundoff/Rules/ReduceOrder.lean) are about its configured values in a reduction orderReduceOrderthat covers the indices. - TorchLean's
TorchLean.TransformerBlock.get2_softmax_forwardandTorchLean.TransformerBlock.get2_layerNorm_forward(TorchLean/Verify/RuntimeApprox/TransformerBlock/Ops.lean) equate, at the reals, the row-wise forwards of its op table'sOp.softmaxandOp.layerNormwithTorchLean.TransformerBlock.softmaxandTorchLean.TransformerBlock.layerNormof each row. A kernel theorem about TorchLean's tensor operations can reach the statements here through them.