advanced28 min studyLesson 491 in Engineering

Unit roundoff is half the spacing convention, not the whole error story

Separate significand precision, local spacing, exponent range, and rounding mode before interpreting numerical tolerances in learning kernels.

On this page

What you’ll understand

  • Distinguish unit roundoff from the spacing above one under an explicit convention.
  • Apply the relative-error model only within its normal-range assumptions.
  • Explain why subnormals, overflow, and fused operations require additional analysis.

A dtype name describes a representation, not one universal accuracy guarantee for an entire training step. Precision controls the number of significant bits, exponent range controls which magnitudes fit, and rounding mode chooses a nearby representable result. The local grid changes with magnitude. We begin with explicit conventions so a tolerance, an ulp comparison, or a claim about a tiny gradient refers to the actual arithmetic rather than an ambiguous phrase such as machine epsilon.

Define spacing and the round-to-nearest convention

For a normalized binary format with p significand bits including the implicit leading bit, spacing in the interval from one through just below two is two to the power one minus p. Here epsilon means that gap above one. Under round-to-nearest, unit roundoff u is half that spacing, two to the power minus p. Some literature uses machine epsilon for a different convention, so always state the definition. PyTorch finfo eps reports the gap above one, while tiny describes the smallest positive normal value rather than every nonzero value.

Round-to-nearest with ties to even resolves a halfway case using the destination significand's least significant bit. Directed modes instead choose toward zero or an infinity, changing error direction and the usual bound. An ulp describes a local representational step, whose scale changes at powers of two and can differ immediately above and below a boundary. Comparing an optimizer update with the spacing near its parameter is therefore more informative than comparing every update with epsilon at one. A format with wide exponent range can still have coarse spacing at ordinary parameter magnitudes.

ϵ=21−p,u=ϵ2=2−p,ulp⁡(x)=2e−p+1(2e≤x<2e+1)\epsilon=2^{1-p},\qquad u=\frac{\epsilon}{2}=2^{-p},\qquad \operatorname{ulp}(x)=2^{e-p+1}\quad(2^e\le x<2^{e+1})
These formulas use normalized positive binary values and p total significand bits. Epsilon is specifically the gap above one, u the round-to-nearest unit roundoff, and ulp the upward grid spacing inside this binade. Boundary directions, subnormals, and other rounding modes need their own treatment.↔ Scroll wide equations horizontally.

Relative error has a domain of validity

For a basic correctly rounded operation whose exact result remains in the normal finite range, the standard model writes the rounded result as the exact result times one plus a small relative error bounded by u. This is a local operation model, not a bound on the final network output after many operations. Near cancellation, a small absolute perturbation in inputs can dominate a tiny result. An exact zero also makes a relative error quotient undefined, even when the operation itself is perfectly meaningful and exact.

Gradual underflow extends the representation with subnormals, whose absolute spacing stays fixed near zero; their relative spacing grows as magnitude shrinks. A pure relative bound by u does not describe every subnormal result. Flush-to-zero settings can remove those values entirely. Overflow can produce infinity or another specified result depending on mode, and NaNs need deliberate handling. Fused multiply-add rounds a product-plus-sum once rather than rounding the product separately first. The actual instruction, accumulation type, compiler settings, and intermediate values therefore belong in a numerical experiment's configuration.

fl⁡(z)=z(1+δ),∣δ∣≤u;∣fl⁡(z)−z∣≤Δ2 on a uniform nearest-rounded grid\operatorname{fl}(z)=z(1+\delta),\quad |\delta|\le u;\qquad |\operatorname{fl}(z)-z|\le\frac{\Delta}{2}\ \text{on a uniform nearest-rounded grid}
The first model assumes a correctly nearest-rounded normal finite result without exceptional behavior. The second is an absolute-error bound for an interior uniform grid of spacing Delta, including a gradual-underflow region when its assumptions hold. Neither covers overflow or arbitrary flush-to-zero behavior.↔ Scroll wide equations horizontally.

Inspect the operation, not only the tensor's storage type

A half-precision input tensor can feed products or accumulations performed at a different precision, followed by an output cast. Conversely, an apparently wider computation may use a reduced-precision input path or intermediate buffer. Check documented backend behavior and use controlled probes around representable neighbors, underflow thresholds, and large intermediate values. Record exact input bit patterns where practical. A final scalar that fits the output dtype does not prove every intermediate fit, and widening only the final cast cannot undo earlier discarded information.

The bisection lab separates algorithmic refinement from representation questions; it does not emulate a chosen floating-point format. Reset, set both target c=2 and upper bound U=4, predict an initial midpoint-bound of two and a bound of one after one Step, then inspect. Each Step advances one bisection because it adds half a second; refinement is capped at fifty iterations. Playback runs the fixed quadratic root model, whose own guarded arithmetic is specified separately. Do not read its shrinking bracket as a measurement of binary16 unit roundoff or an overflow test.

A binary16 halfway case near a normalized weight

Use binary16 with p=11 significand bits and round-to-nearest, ties to even. Compare one, its next larger neighbor, and the exact midpoint between them. All values remain normal and finite.

  1. The gap above one is epsilon = 2⁻¹⁰ = 0.0009765625, so the next larger value is 1.0009765625.

  2. Unit roundoff is half that gap: u = 2⁻¹¹ = 0.00048828125. The exact midpoint is 1.00048828125.

  3. The midpoint rounds to one under ties to even because one's destination significand has an even least significant bit. The absolute error is 0.00048828125; the relative error divides by the midpoint and is slightly below u.

The result

The spacing convention eps and unit roundoff differ by two here. A halfway rounding example validates a local format rule, not an error bound for an entire learning computation.

Explore the model

Interactive lab

Interactive lab · root-finding

Refinement error and arithmetic precision are different

Reset, set both c=2 and U=4, predict bound two initially and one after one Step, then inspect. Step advances one bisection and playback is capped at fifty iterations. Reset and re-enter both controls before another run. This fixed x²−c bracket model does not emulate binary16 rounding, ulps, subnormal flushing, or overflow.

Refinement error and arithmetic precision are differentBisection of x² − c on [0,U], capped at 50 iterations for floating-point resolution. The error bound is the maximum distance from the displayed midpoint to either bracket endpoint (half the width in exact arithmetic). Compensated square evaluation preserves the bracket when ordinary multiplication rounds a residual to zero. A truly exact endpoint or midpoint collapses the bracket. This is one monotone quadratic, not a general root solver. Current readings: Midpoint after 0 refinements: 1.5; Bracket error bound: 1.5; Computed residual · x² − c: 0.25. All parameters are adjustable with the labeled controls below.Bisection on x squared minus 2: bracket from 0 to 3 after 0 refinements.00.751.52.253−2.360.192.745.297.84x · bracket stays nonnegativef(x) = x² − cn = 0 · [ 0, 3 ]
Quadratic / midpointCurrent bracketPositive root
Midpoint after 0 refinements
1.5
Bracket error bound
1.5
Computed residual · x² − c
0.25
t = 0 s

Bisection of x² − c on [0,U], capped at 50 iterations for floating-point resolution. The error bound is the maximum distance from the displayed midpoint to either bracket endpoint (half the width in exact arithmetic). Compensated square evaluation preserves the bracket when ordinary multiplication rounds a residual to zero. A truly exact endpoint or midpoint collapses the bracket. This is one monotone quadratic, not a general root solver. Parameter changes pause playback and recompute the model at the current elapsed time. Reset restores both parameters and returns time to zero. Playback starts paused. Adjust either parameter, then choose Play or Step.

Look forA smaller algorithmic interval is useful evidence only within its model; it cannot substitute for the actual arithmetic contract.

Check your understanding

Under this lesson's normalized binary round-to-nearest convention, a library reports eps as the gap from one to the next larger value. How does unit roundoff relate to that eps?

Try it yourself

A normalized binary format has p=8 significand bits. Compute the gap above one, nearest-rounding unit roundoff, and upward spacing within the binade [8,16).

Take a moment to make a prediction or work it out on paper. Open a hint when you need one.

Give me a hint

Use epsilon=2^(1−p), halve it for u, and scale local spacing by 2³.

Compare with the solution

The gap above one is 2⁻⁷ = 0.0078125 and u is 2⁻⁸ = 0.00390625. Inside [8,16), upward spacing is 2^(3−8+1) = 2⁻⁴ = 0.0625. These normalized-grid statements do not specify overflow range, subnormal handling, or the accumulated error of a sequence.

Take it with you

  • State whether epsilon means the gap above one or a different convention.
  • Unit roundoff, local ulp spacing, and exponent range describe different limits.
  • Check actual operation and accumulation semantics before applying a normal-range error model.

Read further

Original sources and deeper explanations to follow at your own pace.

Optional progress, saved in this browser when available. Revisit any lesson at any time.

Lesson not marked complete.