QUANTIZATION · CHANNELWISE SMOOTHING
SmoothQuant: channel scales and output error
Preserve the float product, then measure what rounding and calibration change.
Configure matrices
Channel calibration
| Channel | Activation max | Weight max | Diagonal scale |
|---|
Compare quantized products
Measured matrix errors for these inputs. Scroll tables horizontally on narrow screens.
| Path | Activation range | Weight range | Clipped activations | Output MSE | Maximum error |
|---|
| Row | Output | Reference | Transformed float | Unsmoothed quantized | Smoothed quantized |
|---|
Complete state evidence
Follow a channel through a matrix product
Calibration and evaluation matrices contain token rows and input-channel columns. The weight matrix contains input-channel rows and output-channel columns: the reference output is evaluation times weights. Calibration is a separate collection used only to choose scales and activation ranges. The initial two-channel fixture contains an activation outlier of sixteen in the second channel. These are deliberately small numerical examples, not collected language-model activations. Every edit recomputes the displayed products. Invalid matrices clear old results so stale evidence cannot be mistaken for the new experiment.
Use every input deliberately
Example selects an outlier, shifted evaluation, or zero-channel fixture. Load example copies its three matrices while preserving alpha and bit width; selecting a name alone does not change the calculation. Each JSON matrix accepts one through eight rows and columns, rectangular rows, finite numeric entries, and absolute values up to one thousand. Calibration and evaluation must have the same number of columns as weights have rows. Their row counts may differ. Alpha accepts values from zero through one. Bit width selects two, three, four or eight bits for both activations and weights. Reset defaults restores the outlier example, alpha one half and four bits. Complete state evidence expands all transformed matrices, integer codes, scales and reconstructed values.
Separate exact rescaling from quantization
For channel j, a is the largest absolute calibration activation across token rows, and w is the largest absolute weight across output columns. The scale is a raised to alpha divided by w raised to one minus alpha. For zero channels this implementation floors both maxima and the final scale at 0.00001. Evaluation and calibration columns are divided by their scale; weight rows are multiplied by that same scale. These inverse operations preserve the matrix product before rounding, up to floating-point error. Alpha zero is not an off switch: ignoring the floor, its scale is one divided by w. The separate Unsmoothed row is the actual baseline without any diagonal transformation.
Inspect the quantizer assumptions
Both paths use static symmetric per-tensor fake quantization. The activation clip magnitude is the maximum absolute entry of the corresponding calibration matrix, after transformation for the smoothed path. The weight clip magnitude is the maximum absolute entry of its corresponding weight matrix. Evaluation never fits these ranges. With b bits, Q equals two to the power b minus one, minus one; signed codes run from minus Q to Q. Values clip to the fitted interval and round to nearest with even-integer ties, using scale clip divided by Q. A zero range produces all-zero codes with a sentinel scale of one. The unused most-negative signed code, floating-point division and rounding rules are explicit teaching choices.
Reproduce an exact outlier experiment
Reset defaults. The channel maxima are one and sixteen, and both weight maxima are one. At alpha one half, the channel scales are one and four. The first reference output row is seventeen and minus fifteen; the transformed float product must match it. At four bits, the baseline activation one rounds to zero because the activation scale is sixteen sevenths, producing sixteen and minus sixteen. Its output MSE is one. The smoothed path has activation and weight ranges of four, and produces approximately 17.306122 and -14.693878. Its MSE is approximately 0.093711. These errors are measured from these matrices, not a promised model-quality improvement. Set alpha to zero and compare: for this particular unit-weight fixture the diagonal scales are one, so the two paths agree. Other weights make alpha zero different from the baseline.
Expose calibration mismatch and boundaries
Load Shifted evaluation while keeping the default settings. The calibration matrix stays fixed, but evaluation outliers become thirty-two. Two evaluation entries now exceed their fitted range in both paths. Observe the clipped counts and larger output errors; changing bit width cannot recover values removed by clipping. Load Zero channels to see a calibration channel that has no observed activation and a held-out nonzero value. Floors keep the diagonal transformation finite, while a zero calibrated tensor range reconstructs only zeros. Edit weights to make one channel entirely zero and verify its contribution remains zero before rounding. No division by an unobserved channel maximum is silently accepted.
Interpret measurements within their scope
MSE is the mean squared difference across every evaluation-output entry; maximum error is the largest absolute difference. Before-rounding product difference is a separate numerical invariance check. Tables scroll horizontally and receive keyboard focus on narrow screens. This is a direct matrix calculation with no artificial playback clock. It does not implement model loading, LayerNorm folding, shared projection groups, bias terms, GPU integer kernels, per-token or per-output-channel quantizers, perplexity, throughput or memory benchmarks. An alpha that helps one fixture can hurt another. Choosing alpha after repeated evaluation edits turns that data into a tuning set; keep separate untouched data for a real assessment.
Primary sources: SmoothQuant paper and authors' channel scaling implementation. This bounded experiment isolates diagonal scaling and specifies its own quantizer.