Learned step-size quantization, LSQ and SEQ
A uniform quantizer has one knob, the step size. LSQ's contribution was to learn it by gradient descent on the task loss, with a step-size gradient that is sensitive to how close each value sits to a rounding boundary, plus a scale factor that keeps its updates balanced against the weights'. SEQ is ParetoQ's low-bit descendant: the same learned step size, a better-shaped grid. I read the LSQ paper and its LaTeX, audited the quantizer code that four other notes here depend on, and verified the gradient and both grids.
- Note
Core insights. A uniform quantizer is completely described by one number per layer: the step size , the width of a quantization bin. Everything else (which integer each weight maps to, the dequantized value) follows. Before LSQ, that step size was set from statistics of the weights or by minimizing quantization error. LSQ’s idea is to treat as an ordinary learnable parameter and descend the task loss on it, alongside the weights. Two things made that work: a step-size gradient, derived through the straight-through estimator, that grows as a value nears a rounding boundary (because that value is about to jump bins); and a scale factor on that gradient, so a step size shared by weights gets updates proportioned like the weights’ own. SEQ, from ParetoQ, is the same learned step size with a differently-shaped grid for the extreme low-bit regime. The learned step size is the quiet substrate under most of this site’s QAT notes, and this is where it comes from.
The step size is the parameter
Take a uniform symmetric quantizer. Given a weight and a step size , LSQ (the paper says, Eq. 1–2) computes an integer code and a dequantized value:
is round-to-nearest; for -bit signed weights and (so 2-bit weights land on , 4-bit on ; I verified both). At inference the integer codes feed low-precision matrix multiplies and the output is rescaled by , so is genuinely the only continuous knob.
The question LSQ answers is how to set . Earlier methods fit it to the data (match the range, or minimize ). LSQ’s argument is that minimizing quantization error is the wrong target: a grid that reproduces the weights most faithfully need not be the grid that preserves the task. So it learns by gradient descent on the training loss, like any other parameter. The obstacle is the same one every QAT method hits, the round in has zero gradient almost everywhere, and the interesting part is how LSQ gets a useful gradient to out of it.
The gradient, and why its shape matters
Differentiate with respect to , using the straight-through estimator for the round (treat while leaving the round in the forward value). In the interior the product rule gives ; in the clipped regions is a constant so . That is LSQ’s Eq. 3:
The interior term is the negative rounding residual, and its magnitude is the distance from to the nearest bin centre: near zero at a centre, near at a transition. That is the property the paper cares about and the earlier methods lacked. A value sitting close to a bin boundary is the one most likely to flip codes when moves a little, so it should pull hardest on , and LSQ’s gradient does exactly that while QIL’s is insensitive to boundary distance and PACT’s is zero below the clip point. I verified the three-region formula matches the reference code line for line, and that the interior magnitude stays in , peaking at the transitions.
Balancing the step-size update
There is a second, less glamorous contribution that the paper is right to insist on. A single step size is shared by all weights in a layer, and its gradient sums a residual-sized term over all of them, so its raw magnitude grows like (the sum of roughly independent, zero-mean terms). Meanwhile each weight’s gradient is a single term. Left alone, the step size takes updates two to three orders of magnitude larger than the weights relative to its own size, which the paper measured and which wrecks convergence. LSQ multiplies the step-size gradient by
so that the ratio of update magnitude to parameter magnitude is about the same for as for the weights. The cancels the summing-over- growth; the offsets the fact that a finer grid (larger ) uses a smaller step, so its gradient would otherwise scale differently with precision. I verified the part directly: the summed step-size gradient’s magnitude tracks across four orders of magnitude, so dividing by flattens it. This gradient-scaling trick is not incidental; it reappears verbatim as the factor in ParetoQ’s and StableQAT’s code.
The remaining details: is initialised to from the initial weights, the first and last layers are left at 8 bits, and training fine-tunes from a full-precision model. On ImageNet this was the state of the art of its day (paper says): ResNet-18 at 2/3/4 bits scored 67.6 / 70.2 / 71.1 against a 70.5 full-precision baseline, so 4-bit exceeds full precision and 3-bit lands within a few tenths, with the paper reporting 3-bit matching full precision once knowledge distillation is added.
SEQ: the same knob, a better low-bit grid
LSQ’s grid is the plain integer set, and it carries two features that are invisible at 4 bits and expensive at 2. It contains zero, which costs a level, and it is asymmetric, one more negative level than positive. At sixteen levels nobody notices; at four levels, spends its budget on a single positive value and a zero. ParetoQ introduced Stretched Elastic Quant (SEQ) to fix exactly this, and it is not a separate paper or a new training method, it is LSQ’s learned step size with the grid reshaped. SEQ keeps the learnable (its name for ) and the three-region gradient, but replaces the integer round with
whose half-integer shift lands the levels on symmetric, zero-free bin centres. I verified the grids from the code: 2-bit SEQ gives , four balanced values with no zero, and ternary SEQ gives , keeping zero only where an odd level count makes it free. ParetoQ’s ablations pick SEQ for ternary and 2-bit and plain LSQ for 3 and 4, which is the crossover made concrete: the zero-free symmetric grid wins exactly when levels are scarce.
Where this shows up
LSQ is a 2020 CNN paper, but its learned step size is the substrate under most of the low-bit LLM work on this site. ParetoQ is LSQ for 3–4 bit and SEQ for 1–2 bit, trained end to end. StableQAT keeps LSQ’s forward and its step-size gradient unchanged, and swaps only the straight-through estimator on the weight gradient (the round’s ) for a Fourier surrogate. EfficientQAT learns an affine version (a step size and a zero point) block by block. Even GPTQ, which learns nothing, fits a per-row step size before quantizing. Once you have read the LSQ gradient and its scale, that recurring grad_scale = 1/sqrt(numel * Qp) line in every one of these repos stops looking like a magic constant and starts looking like a citation.
What I verified
The checks are one seeded NumPy script, verification/learned-step-size/checks.py, all PASS: the LSQ integer grids (signed 2- and 4-bit, unsigned 2-bit); that the paper’s Eq. 3 step-size gradient equals the reference code’s formula exactly, with the interior magnitude bounded by and peaking at the transitions; that the unscaled step-size gradient grows as , which is what the in the gradient scale cancels; and the SEQ 2-bit and ternary grids, with the structural contrast that LSQ’s 2-bit grid has a zero and is asymmetric while SEQ’s is zero-free and symmetric. The LSQ math is from the paper and its LaTeX; the code references are the LsqBinaryTernaryExtension and StretchedElasticQuant implementations in the ParetoQ (7b36b8d) and StableQAT (4760535) repos, which cite LSQ directly. LSQ has no official code release, so the “code does” side is those faithful reimplementations, not the authors’ own. I did not retrain any model; the ImageNet accuracies are the paper’s as reported.