Glossary#

Terms used across these docs, in plain words.

algorithm#

One concrete way of computing an operation, such as summing a matrix product's terms as a balanced tree in bfloat16, or a fused attention kernel that rounds its weights to bfloat16. A named algorithm has its own bounds, measured from the operation's reference. See Algorithms.

any-order tolerance#

The bound from tolerance(standard="any_order"): how far the output of an implementation can be from the reference when it adds in any order at all without overflowing, as a parallel reduction or atomic adds on a GPU may. It is wider than the default tolerance, which covers normal accumulation.

any_of#

er.any_of(center, *alternatives): one result whose bounds accept an output of any of several expressions an implementation may compute, such as PyTorch's two ways of computing add with alpha. It keeps the first result, the center, and widens its bounds to hold the others', the alternatives. See Chains and any_of.

backward error#

A way to bound an error by the input instead of the output: a result has a small backward error when it is the exact answer for an input close to the real one. The matrix exponential's tolerance says a correct result is exp(A + dA) for a small dA.

Bluestein pass#

A way to compute a Fourier transform whose length has a large prime factor: as a cyclic convolution, padded to a length with only small factors and computed by three ordinary FFTs. pocketfft and DUCC use it, and er.fft.dft.Bluestein describes one in a plan.

boundary#

A step where every correct implementation of an operation turns exact intermediate values into finite-precision numbers, such as the partial sums of a matrix product. ExactRef's tolerances allow for rounding at the boundaries and nowhere else: one rounding of a value, a sum whose partial sums round as normal accumulation does, or a library function such as exp off by a few ulps. r.boundaries lists an operation's boundaries.

chain#

A computation with several steps, checked step by step by passing ExactRef's result for each step into the next operation in place of an array. The next result's bounds cover every value the earlier result allows, since the implementation may have stored any of them: each stored value's uncertainty carries through. See Chains and any_of.

compute format#

The format an implementation rounds to and adds in at each boundary inside the computation. It is float32 by default for inputs narrower than float32 (bfloat16, float16, and the float8 formats) and the input format otherwise. Set it with the compute argument of tolerance() and covers().

correctly rounded#

The exact result rounded once, so that no value of the format is a better answer under the rounding mode. Every floating-point and complex rounded ExactRef returns is correctly rounded.

discrete Fourier transform#

The transform X_k = sum over j of x_j exp(-2 pi i j k / n) of n values into n frequencies. A fast Fourier transform (FFT) computes it in passes. See Fourier transforms.

enclosure#

An interval guaranteed to contain an exact value: a midpoint and a radius, with the exact value no further than the radius from the midpoint. r.exact holds one per element, a pair for a complex element.

finite range#

The lowest and highest finite output a correct implementation can produce, returned by finite_range().

float8#

The 8-bit floating-point formats, such as float8_e4m3fn and float8_e5m2, named after their exponent (e) and stored significand (m) bits. Some have no infinity, and the fnuz ones also have no negative zero.

flush to zero#

A hardware or library mode that replaces subnormal values with zero, as torch.set_flush_denormal(True) does. It acts wherever a value moves into a float format: an input as it is read, a result in the compute format, and the output. Say so with flush_to_zero=True; Flushing subnormals to zero gives the rule for each.

format kind#

The family a format belongs to: floating point (float64 down to the float8 formats), complex, integer (signed and unsigned), or bool. An operation's output format must be of its inputs' kind (integer for a sum of bools); convert across kinds with er.asarray(x, dtype) first.

fused multiply-add#

Computing a * b + c with one rounding instead of two (FMA).

GB10#

The Blackwell GPU in NVIDIA's DGX Spark. ExactRef's tests measured its tensor cores and PyTorch's kernels on it.

half spectrum#

The first n//2 + 1 values of a real input's Fourier transform, which determine the rest: each later value is the complex conjugate of an earlier one. er.fft.rfft returns it, and er.fft.irfft takes it.

named outputs#

Outputs held by name: attention's output and logsumexp, and every backward's gradients, even a single one, named grad_ plus the input's name, such as grad_A. r[name] is a result for one of them, the form to check with covers() or to pass to a later step.

normal accumulation#

How ordinary kernels add, and what the default tolerance covers. Products are rounded to the compute format and added in it, in index order or in 2 or 4 interleaved SIMD-style lanes. For softmax, log_softmax, and logsumexp it also takes the wider orders of PyTorch's kernels, such as 8 or 16 lanes on x86. Where adding the next value would overflow, a new partial sum starts.

normal answer#

What an ordinary implementation computes, emulated exactly, which normal() returns. For a sum or a product, that is normal accumulation in index order. For an operation of several steps, such as sigmoid, softmax, or layer_norm, it is the steps PyTorch's kernel takes, each rounded in the compute format, with each library function such as exp correctly rounded.

overflow#

A result too large for its format. Depending on the format and the overflow argument, it becomes infinity, the largest finite value, or NaN; an integer wraps around, saturates, or raises.

plan#

How an FFT library computes a transform: for each axis, its passes, each a radix or a Bluestein pass, whose lengths multiply to the axis's length, or to half of it for the packed form of a real transform. An FFT algorithm's bounds come from its plan.

radix#

The size of the small transforms, called butterflies, that one pass of an FFT computes. A plan for 4096 values may be four passes of radix 8.

reference#

The exact answer rounded once to the output format: r.rounded.

rounding mode#

The rule that picks which value of the format an exact result becomes: to nearest with ties to even (the default) or ties away from zero, toward zero, toward +inf, or toward -inf.

saturate#

Overflow handling that gives the largest finite value instead of infinity or NaN: overflow="saturate".

split-K#

A way to compute a matrix product that splits the inner dimension into blocks, sums each block separately, often in parallel, and then adds the block sums. Its order of additions differs from a plain loop's.

subnormal#

A value smaller in magnitude than the format's smallest normal number, held with fewer bits of precision. float32's subnormals reach down to about 1.4e-45.

tensor core#

A GPU unit that multiplies small blocks of matrices, used for float16, bfloat16, TF32, and similar inputs. It adds each block of products in one adder that truncates, which the operations' own tolerances do not cover; the tensor-core algorithms do.

TF32#

NVIDIA's TensorFloat-32 format: float32's 8 exponent bits with 11 bits of precision. GPU tensor cores in TF32 mode round float32 inputs to it before a matrix product. er.round_to_tf32 rounds float32 data to it.

ties to even#

The rule for an exact value exactly halfway between two values of the format: pick the one whose last bit is 0. It is the default rounding.

tolerance#

Per element, how far a correct implementation's finite output can be from the reference, for these inputs: tolerance(). It is computed from the inputs and the operation's boundaries, not fixed per dtype.

twiddle factor#

A root of unity, exp(-2 pi i k / n), or exp(+2 pi i k / n) in an inverse transform, that an FFT multiplies values by between passes. Libraries hold twiddle factors rounded, and the Fourier transforms' tolerance allows each to be off by up to ulps times the compute format's unit roundoff, where ulps is an option of tolerance().

two-pass method#

A way to compute a variance: take the mean first, then add up the squared distances from it. It avoids the cancellation of the textbook formula, the mean of the squares less the square of the mean. er.var's tolerance covers it. See var.

underflow#

A nonzero result too small for its format: it rounds to a subnormal value or to zero.

ulp#

Unit in the last place: the spacing between neighboring values of a format at a given size. For float32 values between 1 and 2 it is 2**-23.

unit roundoff#

Half the distance from 1 to the next larger value of a format: the largest relative error of one rounding to nearest. It is 2**-24 for float32 and 2**-53 for float64.

Welford's method#

A way to compute a mean and a variance in one pass: it updates a running mean and a running sum of squared distances from it with each element, and merges blocks computed apart. PyTorch uses it in most of its variance, std, and normalization kernels. var_welford and std_welford describe it. See var.