TorchLean API

NN.Proofs.RuntimeApprox.NF.Ops.Sum

NF Sum Reduction Bounds #

Forward-error bounds for rounded sum reductions. The accumulator carries both the runtime value and a proof budget, so every addition contributes the incoming element error plus one rounding term. These bounds follow sumSpec's left-to-right tensor traversal, starting at rounded zero. They do not cover a different reduction tree or establish a native kernel's accumulation order.

One fold step for sumSpec that tracks an explicit forward error budget.

State is (accR, epsAcc) where accR is the runtime accumulator and epsAcc bounds the absolute error |toSpec accR - accS| for the corresponding spec accumulator accS. Each step adds:

  • the incoming per-element budget epsElem;
  • one rounding-ULP term for the addition.
Instances For

    Fold sumStep over a tensor via foldlSpec.

    This is the shared helper behind sumBound and approxTensor_sum_spec: it simultaneously computes the runtime sum (in .1) and the accumulated error bound (in .2).

    Instances For

      Forward absolute-error bound for sumSpec.

      Assumes each element is approximated within epsElem. The budget starts with a conservative half ULP at zero and adds one rounding term per sequential addition; it is not a tight bound for an empty tensor, whose sum is exactly zero.

      Instances For

        Forward approximation bound for sumSpec over an arbitrary tensor shape.

        If xR approximates xS elementwise within eps, then the scalar sums sumSpec xR and sumSpec xS differ by at most sumBound eps xR.