liveBook · Manning

Clipping

As explained in Quantization and Fast Inference

Clipping limits a numerical value to a specified minimum and maximum so it remains within a representable range.

Clipping (also called clamping) constrains a rounded quantized value to the integer type’s limits: q = clip(round(rS + Z), qmin, qmax). It prevents overflow, but values beyond the representable range saturate at a boundary. section 2.2

Clipping has two practical consequences:

  • It limits integer outputs to qmin and qmax; signed int8, for example, uses −128 and 127. section 2.2
  • It introduces overload error when values fall outside the quantization grid. Widening the grid reduces clipping but increases rounding error; tightening it reverses that tradeoff. section 2.6

Saturation at an integer boundary

With signed int8 limits, a rounded quantized value above 127 is clipped to 127 rather than stored beyond the type’s range. section 2.2

Figure 2.4 The ruler problem. Fixed-point quantization (left) forces a single rigid ruler on all measurements: a rice grain vanishes between coarse tick marks, while a watermelon extends beyond the ruler's edge and gets clipped. Affine quantization (right) manufactures a custom ruler for each object, with tick spacing (scale) and starting position (zero-point) tailored to the data's actual range.

The ruler illustration contrasts values that fit the quantization range with an oversized value that extends past its edge and gets clipped. section 2.2

How Quantization and Fast Inference covers it

How deep it goes
Defines clipping in the affine quantization equation and explains overload error and its tradeoff with rounding, but not clipping algorithms.
Examples
Uses signed int8 bounds of −128 and 127 and illustrates clipping with an oversized value extending past a ruler’s edge.
What it assumes
Defines clipping alongside scale, zero-point, rounding, and integer bounds in an affine quantization mapping.
What you can do after
Apply it via affine quantization to constrain rounded values to qmin and qmax.
How it connects
Connects clipping to affine quantization, scale, zero-point, rounding, calibration, and overload error.

Also explained in

Compare how 5 books explain clipping →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quantization and Fast Inference. The section links point to the parts of the book it draws on.