Floats
Scope
The floating-point rules of the semantics: the rounding of the binary operations, the
deliver of a result and the NaNs it may be, the contract flag's fused multiply-add,
llvm.maxnum and llvm.minnum, and rsqrt.approx; and the contract of ex2.approx, Mojo's
float32 exponential, which the semantics does not execute (inline assembly). Each card links the
rule to the semantics' declarations and to FloatLib's, by full name (FloatLib's names are checked
against its sources under .lake/packages). Construct cards climb the construct ladder of
roadmap/README.md.
Reference: LLVM 24.0.0git's LangRef and the PTX ISA version 9.5, the versions docs/TRUST.md records. No copy of them is in the repository, so every quote is empty and each card says "quote to be added".
Cards
- binary-op-rounding:
fadd,fsub,fmul,fdivround to nearest even (FloatLib'sModel.addand the others,Model.roundAt). - deliver: a result's word, with a NaN's bits from the oracle.
- nan-payloads: any NaN, and
NaNEqfor what does not depend on which. - contract:
contractlets anfmuland anfaddfuse (Model.fma). - maxnum-minnum:
maximumNumberandminimumNumber, any NaN for a signaling NaN operand. - rsqrt-approx: every word within PTX's documented relative error.
- ex2-approx: a contract from PTX's 2 ulp, a premise on the term words of the exponential sums.
Open
A rule passes L1 only with a recorded GPU run of a test of it, a conformance test and not a
proof; STATUS.md lists the cards that have one. The rounding, deliver and contract are at
L3: the GPU runs of tests/gpu/ test them on their inputs (binary32 only, no NaN result, and
contract only where it fuses or has nothing to fuse) and the proved kernels use them. The NaN
rule is used by the proved kernels (L3 evidence) but waits for a GPU run that makes a NaN;
maxnum and rsqrt.approx wait for a proved kernel that uses them (softmax, layer norm).
Status of the cards
From roadmap/status.yaml, which the roadmap script writes from the code.
| Card | Kind | Level | Evidence above the level | Next | Corpus kernels |
|---|---|---|---|---|---|
| binary-op-rounding: the rounding of fadd, fsub, fmul and fdiv, to nearest even in the operation's format | construct | L3 | - | top level | 13 |
| contract: contract, the fast-math flag that lets fmul and fadd fuse into one rounding | construct | L3 | - | top level | 14 |
| deliver: deliver, the result of a floating-point operation as a word, NaNs from the oracle | construct | L3 | - | top level | 0 |
| ex2-approx: ex2.approx.ftz.f32, the approximate base-2 exponential of Mojo's float32 exp | construct | L1 | - | L2 needs a recorded GPU run (a conformance test, not a proof) | 0 |
| maxnum-minnum: llvm.maxnum and llvm.minnum, the floating-point maximum and minimum | construct | L1 | - | L2 needs a recorded GPU run (a conformance test, not a proof) | 0 |
| nan-payloads: NaN payloads, which NaN a floating-point operation may return | construct | L1 | L3 | L2 needs a recorded GPU run (a conformance test, not a proof) | 0 |
| rsqrt-approx: rsqrt.approx.ftz.f32, the approximate reciprocal square root | construct | L1 | - | L2 needs a recorded GPU run (a conformance test, not a proof) | 34 |