advanced24 min studyLesson 725 in Engineering

Model weight-only error at the layer output

Use input-sensitive reconstruction rather than treating every weight error as equally harmful.

On this page

What you’ll understand

  • Propagate a weight perturbation through a linear layer.
  • Distinguish parameter error from activation-weighted output error.
  • Separate compressed storage from the arithmetic and traffic costs of execution.

Weight-only quantization reduces the precision of stored weights while leaving activation arithmetic at a declared higher precision. It can reduce parameter traffic without converting every multiply to a native low-bit integer instruction. Its numerical effect depends on both the weight perturbation and the inputs that multiply it. A small average weight error can be serious when it lies on an input direction used heavily by the workload.

Inputs decide how weight error matters

For a column activation x and weights W, define the reconstructed quantized weights as W plus E. Ignoring runtime arithmetic error, the output perturbation is exactly E times x. A norm bound follows from Cauchy–Schwarz, but it is often conservative because it ignores orientation. Two weight perturbations with identical Frobenius norms can behave differently on a given input. Measure representative layer outputs as well as weight reconstruction, while remembering that calibration inputs still cover only part of the deployment distribution.

If input coordinates have different variances or are correlated, their empirical second-moment matrix weights the reconstruction objective. This explains why independently rounding every weight to its nearest value need not minimize layer-output error. Cancellation can make several weight errors harmless on one input and harmful on another. A reconstruction method optimized for a narrow input subspace can also perform poorly outside it. Include held-out inputs with different domains and lengths before accepting the compressed artifact.

Δy=Ex,∥Δy∥2≤∥E∥F∥x∥2\Delta y=Ex,\qquad \|\Delta y\|_2\le\|E\|_F\|x\|_2
W and E are output×input matrices; x is a column vector. The inequality is an exact-real upper bound, with output units equal to weight units times activation units. It excludes activation quantization and arithmetic rounding.↔ Scroll wide equations horizontally.

Algorithms optimize different approximations

GPTQ uses approximate second-order information from calibration inputs and compensates unquantized weights as other weights are quantized. That strategy targets a layer reconstruction problem; it is not equivalent to gradient finetuning of the entire language model. AWQ instead uses activation-informed scaling and clipping choices to improve weight-only quantization, without the same Hessian-based compensation procedure. Both depend on concrete quantizer and grouping decisions. Neither algorithm name implies a universal error bound or a guarantee of identical decoded outputs.

For a calibration matrix X containing input columns, the squared Frobenius norm of EX is a useful explicit objective. Its trace form exposes XX transpose, the input second moment, rather than only E’s elementwise magnitudes. Normalizing by the number of columns changes the scale but not the minimizer when every example is equally weighted. Task-level errors can nevertheless amplify across layers and through nonlinearities, so a local reconstruction score is a diagnostic and selection signal, not a replacement for application evaluation.

∥EX∥F2=tr⁡(EXXTET)\|EX\|_F^2=\operatorname{tr}(EXX^{\mathsf T}E^{\mathsf T})
X is input×m calibration columns and E is output×input. This unnormalized sum has squared output units; dividing by m gives mean summed squared output error. It assumes exact real multiplication of reconstructed weights.↔ Scroll wide equations horizontally.

Compressed weights still need an execution path

A runtime can unpack and dequantize weights into registers, use a fused mixed-precision kernel, or materialize a higher-precision temporary before multiplication. These choices have different memory traffic and launch overhead. Weight-only storage savings are most relevant when parameter movement is a bottleneck, but a large batch can reuse weights enough that compute or activations dominate. Benchmark the actual shapes, packing and kernel implementation. The payload compression factor alone does not predict latency, and a fallback path can erase an expected benefit.

The network lab shows a downstream nonlinear response to a changed scalar weight, not a quantization algorithm. Reset and set both input x=1 and weight w=1; predict sigmoid(0.5), approximately 0.62246. Separately Reset and set both x=1 and w=0.5; predict sigmoid(0)=0.5, because the fixed bias is -0.5. Compare the output change with the weight change. The instrument contains one sigmoid unit and cannot estimate a transformer’s reconstruction error or select compressed weights.

Equal weight error can give unequal output error

Let x=[10,1]ᵀ and W=[[1,2],[3,4]]. Compare perturbations E₁=[[0.1,0],[0,0]] and E₂=[[0,0.1],[0,0]]. Both have Frobenius norm 0.1. Compute the original output and both errors in exact arithmetic.

  1. The reference output is [1 times 10 plus 2 times 1, 3 times 10 plus 4 times 1]ᵀ=[12,34]ᵀ. This fixes the input orientation and output units for the comparison.

  2. For E₁, the output perturbation is [1,0]ᵀ, because the changed weight multiplies the input coordinate 10. The perturbed output is [13,34]ᵀ and its squared output error is 1.

  3. For E₂, the perturbation is [0.1,0]ᵀ, producing [12.1,34]ᵀ and squared error 0.01. The same parameter-error norm therefore produces a hundredfold difference in squared output error on this input.

The result

A weight metric without the multiplying inputs misses directional sensitivity. The norm bound is 0.1√101≈1.005 for either case, valid but far less informative for E₂.

Explore the model

Interactive lab

Interactive lab · network

A scalar perturbation reaches a nonlinear output

Fresh Reset → set x=1 and w=1 → predict σ(0.5)≈0.62246. Separate Reset → set x=1 and w=0.5 → predict σ(0)=0.5; the bias stays -0.5.

A scalar perturbation reaches a nonlinear outputOne inspectable sigmoid unit, σ(wx − 0.5). Playback traces the computation graph. There is no training, attention mechanism or hidden deep network. Current readings: Product · wx: 1.2; Logit · wx − 0.5: 0.7; Sigmoid output: 0.6682. All parameters are adjustable with the labeled controls below.One input. One weight. One sigmoid.x1.20× w1.20+ b0.70σ0.668output0.668w = 1.00b = −0.50σ(z) = 1 / (1 + exp(−z))
Computation graphSignal trace
Product · wx
1.2
Logit · wx − 0.5
0.7
Sigmoid output
0.6682
t = 0 s

One inspectable sigmoid unit, σ(wx − 0.5). Playback traces the computation graph. There is no training, attention mechanism or hidden deep network. 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 forThe lab is one sigmoid unit. These real-valued settings illustrate sensitivity and do not perform weight quantization or reproduce a language model.

Check your understanding

Why can minimizing average squared weight error miss a harmful quantization change?

Try it yourself

With x=[2,3]ᵀ, compare E₁=[[0.2,0],[0,0]] and E₂=[[0,0.2],[0,0]]. Compute their output-error norms and the common Frobenius bound. Which direction is worse on this input?

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

Give me a hint

Each perturbation changes only the first output. Multiply the nonzero entry by its corresponding input coordinate, then use ||x||₂=√13.

Compare with the solution

E₁x=[0.4,0]ᵀ has norm 0.4, while E₂x=[0.6,0]ᵀ has norm 0.6. The common bound is 0.2√13≈0.7211. The second-coordinate perturbation is worse here; the previous worked example’s ordering reverses because the input direction changed.

Take it with you

  • Weight-only output error depends on the input second moment.
  • GPTQ compensation and AWQ scaling are different methods.
  • Storage compression and runtime speed require separate evidence.

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.