Roadmap / Kernels

vector_subtraction

vector_subtraction, the tutorial's elementwise difference of two float32 vectors (TorchLean.Tensor.sub)

Area
Kernels
Kind
kernel
Level
L4, the top level.
Evidence present above the level
None above the level.
Evidence
  • L1: tests/gpu/vsub/record.txt
  • L2: MojoProof.Kernels.vsub.correct
  • L3: MojoProofTest.Kernel.vsub_real
  • L4: MojoProofTest.Kernel.vsub_real
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
repo:tests/corpus/vsub/vector_subtraction.mojo:84
Quote
out_tensor[global_tid] = lhs_tensor[global_tid] - rhs_tensor[global_tid]
Lean declarations
  • TorchLean.Tensor.sub
  • MojoProof.Kernels.vsub.bytes
  • MojoProof.Kernels.vsub.correct
Corpus files

1 kernel file (.ll) in the corpus.

Tests
  • MojoProofTest.Kernel.vsub_real
  • MojoProofTest.Kernel.vsub_finEq
  • MojoProofTest.Kernel.vsub_stable
Upstream issue
None filed.
Depends on
kernels/vadd

The rule. Thread k of the launch, for k below the length n, writes lhs[k] - rhs[k] (binary32 subtraction) to out[k], and nothing else.

What is proved, for one kernel. The kernel is the tutorial's (docs/new-kernel.md): vector_addition with - for +, compiled with Mojo 1.3.0.dev2026112105; the corpus file is one specialization (float32, one dimension). MojoProof.Kernels.vsub.correct is the kernel theorem (Kernel.Sound), generated by one mojo_kernel command with a map2 clause and no proof lines, 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.vsub.bytes, the bytes of the delivered Model.sub of the inputs' cells. MojoProofTest.Kernel.vsub_real adds that a finite output is TorchLean's x - y at k and that its real value is the real difference rounded to binary32. This is the L3 and the L4 evidence, as for vadd.

Out of scope. Other element types and widths, other launch shapes than one dimension, and the bits of a NaN output.

The GPU run (L1). tests/gpu/vsub/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.