vector_addition
vector_addition, the elementwise sum of two float32 vectors (TorchLean.Tensor.add)
- Area
- Kernels
- Kind
- kernel
- Level
- L4, the top level.
- Evidence present above the level
- None above the level.
- Evidence
- L1:
tests/gpu/vadd/record.txt - L2:
MojoProof.Kernels.vadd.correct - L3:
MojoProofTest.Kernel.vadd_real - L4:
MojoProofTest.Kernel.vadd_real
- L1:
- Scope of the cited theorems
- L2: valid one-dimensional launches (block and grid of side 1 in y and z)
- L3: valid one-dimensional launches (block and grid of side 1 in y and z), where the output is finite and is the exact real result rounded to the format
- L4: valid one-dimensional launches (block and grid of side 1 in y and z), where the output is finite and is the exact real result rounded to the format
- Reference
modular/modular@bbc13a71:max/examples/gpu-functions/vector_addition.mojo:76- Quote
out_tensor[global_tid] = lhs_tensor[global_tid] + rhs_tensor[global_tid]
- Lean declarations
TorchLean.Tensor.addMojoProof.Kernels.vadd.bytesMojoProof.Kernels.vadd.correct
- Corpus files
1 kernel file (
.ll) in the corpus.- Tests
MojoProofTest.Kernel.vadd_realMojoProofTest.Kernel.vadd_finEqMojoProofTest.Kernel.vadd_stable
- Upstream issue
- None filed.
- Depends on
- gpu-model/launch, floats/binary-op-rounding, floats/deliver
The rule. Thread k of the launch, for k below the length n, writes
lhs[k] + rhs[k] (binary32 addition) to out[k], and nothing else.
What is proved, for one kernel. The corpus file is one specialization (float32, one
dimension). MojoProof.Kernels.vadd.correct is the kernel theorem (Kernel.Sound) for every
valid one-dimensional launch and every caller's memory of Map2.Pre: the run is memory safe and
race free, and output cell k holds MojoProof.Kernels.vadd.bytes, the bytes of the delivered
Model.add of the inputs' cells. MojoProofTest.Kernel.vadd_real adds that a finite output is
TorchLean's x + y at k and that its real value is the real sum rounded to binary32
(Model.roundAt). This is the L3 evidence (TorchLean) and the L4 evidence (the IEEE rounding,
exact for finite outputs).
Out of scope. Other element types and widths, other launch shapes than one dimension, and
the bits of a NaN output (they are the delivered NaN, whose payload deliver leaves open).
The GPU run (L1). tests/gpu/vadd/record.txt: on one A100 GPU, six launches of the corpus file on recorded finite inputs; every word of the output buffer is the same on the GPU and in the evaluator. This is a conformance test, not a proof: it covers those launches and inputs.
Open. No level is missing. The cases under "Out of scope" are not covered.