betaFeedback

WorksComputer Science

Following the Error Through a Compressed Network:An Angular Measure for FFN Weight Compression in ViT-L/16

Abstract

We study the compression of the 48 feed-forward network (FFN) matrices of the Vision Transformer ViT-L/16 to 2–8 bits with four schemes: a per-token grid, a fixed Gaussian Lloyd–Max table, a table fitted to the matrix, and a random-sign Hadamard rotation followed by the fixed table. We evaluate on 50,000 images. At 4 bits the top-1 accuracy of the four schemes lies within 0.8 points of the float32 model, while the agreement with its predictions ranges from 98.4% to 94.4%. We use the angular error between the compressed and the float32 residual stream, followed through the blocks, as a portable measure that ranks the schemes as the final classification does and shows where the ranking is built: with rotation the angle grows close to the square root of the number of blocks, the signature of independently accumulating errors, while the other schemes are amplified in the later blocks. The same measure shows that a scheme that is better on one block in isolation can be worse in the whole network. To address this inconsistency we introduce an angular measure of the spectrum of the output of a block, which in isolation orders the schemes as the whole network does where they diverge most. We support these observations with real samples and with statistically generated ones. The scope is one model, the FFN weights only, and float evaluation of compressed weights; no speed-up is claimed. The error measures and the sample generation, however, can be applied to other models and precisions.

Introduction

The feed-forward network (FFN) matrices hold most of the parameters of a Vision Transformer (ViT). In ViT-L/16 the 48 matrices (fc1: 1024→40961024 \to4096 and fc2: 4096→10244096 \to1024 in each of 24 blocks) hold 201 of its 304 million parameters. Compressing them to a few bits per weight reduces storage and traffic, and the question this paper asks is how to compare compression schemes, not which one to build.

Three habits are common, and each can mislead. The first compares the error made on the weights, how far each compressed weight vector is from the original. On this model a table fitted to the matrix is closer to the weights than a plain per-token grid, yet the compressed network is closer to the original with the grid. The second compares top-1 accuracy on a sample. At 4 bits, on 50,000 validation images, four schemes differ from the float32 model by 0.15 to 0.78 points of top-1, but behind this small gap in the total hides a large movement of labels: 802 to 2,792 images change their predicted class, some are negative flips (right before, wrong now, which we call broken) and some positive flips (wrong before, right now, fixed), and the two nearly cancel in the accuracy. On a sample of 5,000 images the order of their top-1 is the reverse of the order of the damage. The third compresses one block at a time and keeps the scheme that is best there. In our data the preference measured on one block does not survive when all blocks are compressed.

We use instead measures that each answer one intuitive question. The angle between the compressed and the float32 residual stream after each block, per token, says how far compression has turned the token, that is, the embedding, away from where it should point; since a transformer reads direction much more than length, a turn is the damage that matters, and turns of independent errors add up in a way we can predict. The agreement with the float32 prediction says how often the compressed network still says the same thing as the original, right or wrong. The Kullback–Leibler (KL) divergence of the output distribution says how much the network’s confidence has moved, even when its answer has not. The swing says who pays for a small change in accuracy: the images whose class changes, negative flips (broken: right before, wrong now) and positive flips (fixed: wrong before, right now), which can cancel in the accuracy and not in the damage. Inside one matrix, the span of the output (the leading eigenvectors of its second-moment matrix, where the output keeps its energy) says whether compression has kept the eigenvectors that carry the signal, or has bent or shrunk them; losing a direction is the damage that no later block can repair. The same angular idea measures the weights (Section 3), so one kind of quantity connects the weight, the stream and the output.

Contributions. (i) A measure and a protocol: the stream angle followed through the blocks, evaluated on named samples of 100 to 50,000 images with paired intervals, and the swing of the classification, its negative and positive flips. (ii) The error flow: with rotation the stream angle grows as the square root of the number of blocks at every width from 8 to 2 bits (exponents 0.43 to 0.53), the signature of independent errors, and the crop schemes rise above this line in the later blocks. (iii) Isolation and context: the error that arrives at a block is four to five times what the block adds, the order of two schemes measured on single blocks reverses in the whole network, and the gap between them arises in fc2. (iv) The span: a spectrum angle and other measures of the output of a matrix show where a scheme loses energy, and order the schemes in isolation as the whole network does where they diverge most. (v) Generated inputs: from 500 images a bulk and one hot eigenvector reproduce the span measures of the real inputs on held-out images. (vi) A sweep of four schemes at 8, 6, 5, 4, 3 and 2 bits, and a confirmation on 50,000 images at 4 bits.

Scope. One model (ViT-L/16, the augreg_in21k_ft_in1k checkpoint), the FFN weights only, one random sign seed for the rotation, and float32 evaluation: the compressed weights are decoded to float before the multiply, so we measure the effect of the representation, not of a kernel. We report no run time. The rotation costs a Hadamard transform of the activations at each FFN matrix, which we do not measure here.

Section 2 places the work, Section 3 defines the objects and measures, Section 4 the schemes, Section 5 the span, as an error measure in context and as a generator of tokens, Section 6 states the observations as testable statements, and Section 7 gives the results. Section 8 lists the limits.

Related work

Rotation before rounding. Multiplying the weights and the activations by an orthogonal matrix before quantization spreads outliers over the coordinates; it is used with randomized Hadamard transforms or learned rotations in recent work on language models [2, 1, 9]. We use a fixed random-sign Hadamard rotation and do not propose a new one; we ask what the rotation does to the error through the blocks of the network. Data-aware weight quantization. GPTQ and AWQ use calibration data to choose the rounding or the scales [7, 8]. Our schemes use no data (information levels 0 to 2, § 4); data would be a further level. Non-uniform formats. Lloyd–Max quantizers [10, 11] minimize the mean squared error for a density; fixed non-uniform tables are used in 4-bit formats for language-model weights [5]. We use the same construction for a Gaussian table solved once and for a table fitted to a matrix. Models. The network is a vision transformer [6] in the augmented-regularized training recipe [13].

The contribution here is not a quantizer. It is the measure (the angle followed through the network), the protocol (paired intervals on named samples, the swing), and what they show about isolation, accumulation and localization. The angular error and the statistical treatment of the compression error, with ablation and validation on samples, were developed for the compression of the key–value cache [4, 3]; here we apply the same machinery to the weights of a public model, and extend it from one layer to the error that flows through the whole network.

Notation and definitions

We fix the vocabulary used in the rest of the paper: the block and its parts, what we call an outlier, the two kinds of angle, the classification measures, and the samples on which they are computed.

A block b∈{0,…,23}b \in\{0,\ldots,23\} of ViT-L/16 maps the residual stream xbx_b to xb+1x_{b+1}:

xb′=xb+Attn⁡(LN⁡(xb;γ1,β1)),(1)x_b' = x_b + \operatorname{Attn}(\operatorname{LN}(x_b;\gamma_1,\beta_1)), \tag*{(1)}
xb+1=xb′+W2GELU⁡(W1LN⁡(xb′;γ2,β2)+b1)+b2,(2)x_{b+1} = x_b' + W_2\operatorname{GELU}(W_1\operatorname{LN}(x_b';\gamma_2,\beta_2)+b_1)+b_2, \tag*{(2)}

where LN⁡(x;γ,β)=γ⊙(x−μ)/σ+β\operatorname{LN}(x;\gamma,\beta)=\gamma\odot(x-\mu)/\sigma+\beta is layer normalization, with μ\mu and σ\sigma the mean and the standard deviation of the 1024 entries of the token xx and with a learned scale γ\gamma and shift β\beta; the two layer normalizations of a block are the same operation with their own parameters (γ1,β1)(\gamma_1,\beta_1) and (γ2,β2)(\gamma_2,\beta_2), and every block has its own. GELU is the Gaussian error linear unit, a smooth activation that suppresses most negative values, and with W1∈R4096×1024W_1 \in\mathbb{R}^{4096 \times1024} (fc1) and W2∈R1024×4096W_2 \in\mathbb{R}^{1024 \times4096} (fc2), stored as [out, in]. Only W1W_1 and W2W_2 are compressed; attention, embeddings, norms and the head stay in float32.

Two kinds of token appear. The network cuts an image into 14×14=19614 \times14 = 196 patches of 16×1616 \times16 pixels and adds one class token; each of these 197 positions is a vector of 1,024 numbers that the blocks update, and we call it an activation token. A weight token is one row wj∈Rnw_j \in\mathbb{R}^n of a weight matrix, that is, the weight vector of one output channel (n=1024n=1024 for fc1, 4096 for fc2). We place a weight token on the sphere, z^j=n wj/∥wj∥\hat{z}_j=\sqrt{n}\,w_j/\lVert w_j\rVert, so that its root mean square is 1; we call σj=∥wj∥/n\sigma_j=\lVert w_j\rVert/\sqrt{n} the sigma of the token (a root mean square, with no mean subtracted), measure coordinates in sigma units, ∣wji∣/σj|w_{ji}|/\sigma_j, and store the norm separately.

An outlier is a coordinate of a weight token whose magnitude (its absolute value) in sigma units is far larger than that of the other coordinates of the token. Counting the coordinates beyond a threshold is one measure (§ 7); the largest coordinates of the 48 matrices reach 10 to 37 sigma, where the largest coordinate of a Gaussian matrix of the same shape would reach about 5.5. By extension we also call a weight token that contains outlier coordinates an outlier token (in the results, a heavy row), and the positions of those coordinates its outlier columns. We use a second, functional definition: an outlier is a coordinate that spends bits on range rather than on precision. A rotation does not remove it; it spreads its energy over all coordinates, so that fewer bits cover the range and more coordinates carry the same information.

The angle between two vectors uu and vv is θ(u,v)=arccos⁡(⟨u,v⟩∥u∥∥v∥)\theta(u,v)=\arccos\left(\frac{\langle u,v\rangle}{\lVert u\rVert\lVert v\rVert}\right). For a weight token ww and its compressed copy w~\widetilde{w} the weight angle is θ(w,w~)\theta(w,\widetilde{w}). The weight angle measures how far compression has turned the token. Any orthogonal transformation, such as a rotation, preserves angles.

Take the first block and a token tt of its input x0x_0. The block turns tt into the token rr of x1x_1; the compressed block turns the same tt into r′r'. The stream angle is φ0(t)=θ(r,r′)\varphi_0(t)=\theta(r,r'): how far compression has turned the output token. Each token is first centred, that is, the mean of its 1,024 numbers is subtracted. We do this because layer normalization is invariant to a constant added to all the numbers of a token: it subtracts the mean itself, so the next layer cannot see such a shift. For a later block bb the compressed network has also compressed the blocks before it, so rr and r′r' are the tokens of xb+1x_{b+1} in the float32 and in the compressed network, and φb(t)\varphi_b(t) contains the error accumulated so far. We report the median (and the 99th percentile) over tokens.

If every block adds an independent error of similar size, the errors add like random steps, in quadrature, so after n=b+1n=b+1 compressed blocks the median angle grows as n1/2n^{1/2} for small angles. We fit φn∝np\varphi_n\propto n^p and call pp the growth exponent: pp near 1/21/2 means independent accumulation, and a larger pp means that later blocks amplify the error.

For an image, the logit angle is θ(l,l′)\theta(l,l'), where ll and l′l' are the 1,000 logits of the float32 and of the compressed network, each centred by removing a constant, its mean; the softmax cannot see such a constant. We could compare the probabilities directly, with a cross entropy (we also report the Kullback–Leibler divergence of the output), but the angle is a measure common to the weights, the stream and the logits.

Agreement is the share of images with the same predicted class as the float32 network. Top-1 and top-5 are the usual accuracies. KL is the divergence of the compressed softmax from the float32 one. The swing counts the images whose class changed, among them those the float32 network classified correctly and the compressed one does not (a negative flip, which we also call broken), and the reverse (a positive flip, fixed) [14]; the two counts are the discordant pairs of McNemar’s test [12]. The top-1 change is fixed minus broken, over the sample; it can be near zero while many images change.

The validation images are taken in file order. A sample is named by its number of images and the number of classes it covers (Table 1).

sampleselectionimagesclasses coveredused for
100-93every 500th image10093checking the scaffolding
500-401every 100th image500401per-token flow runs, swap tests, local analysis
5000-995every 10th image5,000995exploration
50000-1000all images50,0001,000confirmation

Table 1. The samples. Only the full validation set is balanced across classes.

The float32 network has top-1 85.84% and top-5 97.82% on 50000-1000 (85.86% top-1 on 5000-995). All evaluation uses batch size 10; the noise floor of the logits between runs is about 3×10−63 \times10^{-6}. Intervals are 95% bootstrap intervals over images (2,000 resamples). The same resamples are used for every arm, so a difference between two schemes is a paired difference.

Compression schemes and their assumptions

We study the effect of four compressions of a weight token to bb bits per coordinate: a uniform grid, as in an integer representation; Lloyd–Max tables, which minimize the mean squared error (one fixed table for Gaussian coordinates and one fitted to the matrix); and a Hadamard rotation, which spreads the outliers over all coordinates, combined with the fixed table. In each, a coordinate is replaced by the index of one of 2b2^b levels and the token keeps one scale chosen by least squares. We rank them by what the encoder must know about the weights, the information level: level 0 nothing, level 1 the token itself, level 2 the distribution of the whole matrix, and level 3 data, such as calibration inputs of the layer, whose covariance an encoder could use. We stay at levels 0 to 2.

Crop with a grid (Grid-crop). A weight token is clipped to an interval [−cσ,cσ][-c\sigma,c\sigma], with σ\sigma its sigma (the root mean square), that is, to [−c,c][-c,c] on the sphere of radius n\sqrt{n} where the token has sigma 1; the grid is the 2b2^b equally spaced levels of an integer representation, one of which is zero, with the largest level at cc; each coordinate takes the nearest level. The interval is chosen per token, from candidates of 1 sigma upward, as the one with the smallest weight angle, and the token keeps the least-squares scale. It assumes nothing about the distribution of the coordinates and needs the token itself (information level 1).

Lloyd–Max tables. A Lloyd–Max quantizer chooses levels and thresholds that minimize the mean squared error under a density; the levels are the conditional means of the cells [10, 11]. StaticLM-crop uses the table of the standard normal, solved once for each width, on the normalized token: it assumes Gaussian coordinates and needs nothing about the weights (level 0). FitLM-crop fits the table to the pooled coordinates of the matrix itself (level 2): it replaces the Gaussian assumption by the empirical density, at the price of using the weights to build the table. The fit iterates until the relative decrease of the distortion is below 10−910^{-9}, with a cap of 10,000 iterations.

Rotation. Let HH be the n×nn \times n Walsh–Hadamard matrix scaled by 1/n1/\sqrt{n} and dd a vector of random signs; the transform Tx=H(d∘x)Tx = H(d \circ x), where ∘\circ is the element-wise product, is orthogonal. Since y=Wx=(WT−1)(Tx)y = Wx = (WT^{-1})(Tx), we compress the rows of WT−1WT^{-1} and apply TT to the activation xx at run time. We expect a random rotation to send a token to a point close to uniform on the sphere; its coordinates then follow a beta distribution (scaled) and, as nn grows, a Gaussian. The random-sign Hadamard transform is a cheap approximation of such a rotation, and we test the Gaussian expectation (§ 7). The cost is a transform of length nn per activation token (nlog⁡2nn\log_2 n additions for n=1024n = 1024 or 4096), and the sign vector.

Rotation with the fixed table (StaticLM-rot). We rotate the weight token with T−1T^{-1} and quantize it with the StaticLM-crop table.

schemequantizerinformation about the weights
Grid-cropuniform grid, per-token clipthe token (level 1)
StaticLM-cropN(0,1)N(0,1) Lloyd–Maxnone (level 0)
FitLM-cropfitted Lloyd–Maxthe matrix (level 2)
StaticLM-rotN(0,1)N(0,1) Lloyd–Max after rotationnone (level 0)

Table 2. The four schemes. Information levels: 0 nothing about the weights, 1 the token, 2 the distribution of the matrix, 3 data.

The bit width counts the indices only; the per-token scale (and, for the grid, the clip) is side information of the order of 1/64 bit per weight if stored in 16 bits per token of 1,024 weights.

The span: an error measure in context and a generator of tokens

To see how the coordinates of a set of tokens relate to each other we look at their empirical covariance, a matrix; if the coordinates were independent Gaussians it would be diagonal. We keep the mean in it, which makes it a second moment: the energy of the tokens. An eigenvalue and eigenvector analysis of this matrix shows the eigenvectors that carry the energy and, by their eigenvalues, how much each carries; the span is the subspace of the leading eigenvectors, and its dimension is the number of directions that matter. We use it in two ways. First, as an error measure that depends on the context: the output of a matrix lives in a span, and compression can shrink it, tilt it or lose part of it; it measures the error where the inputs put the energy (§ 5.1, Table 3). Second, to generate tokens: the covariance describes how the tokens of a small sample are related to each other, and a description of a few numbers lets us generate new tokens that keep what matters, so that a small sample generalizes (§ 5.2).

measureneedssees
weight anglethe matrix and its copythe weight in the isotropic metric
branch angle (median over tokens)the matrix, its copy, an input samplethe typical token
span measuresthe matrix, its copy, the second moment of the inputsthe leading eigenvectors and the whole spectrum
stream anglethe network, compressed and float32what arrives from the other blocks
agreement, KL, swingthe whole network and a samplethe end result

Table 3. The measures compared. The span measures sit between the weight and the stream.

The span as an error measure

Take fc2 of one block, W∈R1024×4096W \in\mathbb{R}^{1024 \times4096}, and its compressed copy W~\widetilde{W}. Let A∈RN×4096A \in\mathbb{R}^{N \times4096} be a sample of its inputs (the GELU outputs of NN activation tokens), Y=AWTY = AW^{\mathsf{T}} the output signal, Y~=AW~T\widetilde{Y} = A\widetilde{W}^{\mathsf{T}} the compressed output and E=Y~−YE = \widetilde{Y} - Y the error. The second-moment matrices are C=YTY/N=WΣWTC = Y^{\mathsf{T}}Y/N = W\Sigma W^{\mathsf{T}} and C~=Y~TY~/N=W~ΣW~T\widetilde{C} = \widetilde{Y}^{\mathsf{T}}\widetilde{Y}/N = \widetilde{W}\Sigma\widetilde{W}^{\mathsf{T}} with Σ=ATA/N\Sigma= A^{\mathsf{T}}A/N, so every measure below depends on the sample only through Σ\Sigma. Write C=∑iλiviviTC = \sum_i \lambda_i v_i v_i^{\mathsf{T}} with λ1≥λ2≥…\lambda_1 \ge\lambda_2 \ge\ldots; the span of the output is the subspace of the eigenvectors viv_i with the largest eigenvalues λi\lambda_i: where the output has its energy. Four measures describe it. The spectrum angle is the angle between the two spectra taken as vectors, θ(s~1:k,λ1:k)\theta(\widetilde{s}_{1:k}, \lambda_{1:k}), with s~1≥s~2≥…\widetilde{s}_1 \ge\widetilde{s}_2 \ge\ldots the eigenvalues of C~\widetilde{C} and k=32k = 32: the eigenvalues are ordered, so no eigenvectors have to be matched and the number does not depend on which channels hold the energy. It is zero when the compressed output keeps the shape of the spectrum, and it turns when energy is lost where the signal has most of it. The spectrum distance d=∥s~1:k−λ1:k∥/∥λ1:k∥d = \lVert\widetilde{s}_{1:k} - \lambda_{1:k} \rVert/\lVert\lambda_{1:k} \rVert is a second form of the same comparison, which also counts a uniform change of scale. The dominant gain μ1=v1TC~v1/λ1\mu_1 = v_1^{\mathsf{T}}\widetilde{C}v_1/\lambda_1 is the variance kept along the dominant eigenvector; if Y~=αY+ν\widetilde{Y} = \alpha Y + \nu along v1v_1, with the part not proportional to the signal, then μ1=α2+ν\mu_1 = \alpha^2 + \nu and the error energy along it is (1−α)2+ν(1-\alpha)^2+\nu, so a small μ1\mu_1 with a large error is a contraction. The in-span share ∑i≤kviTC~vi/∑i≤ks~i\sum_{i \le k} v_i^{\mathsf{T}}\widetilde{C}v_i/\sum_{i \le k}\widetilde{s}_i is the part of the compressed output that still lives where the signal lived (by Ky Fan’s maximum principle the denominator is the most any kk-dimensional subspace can hold). The error in the span is the share of ∥E∥2\lVert E\rVert^2 that falls along the top 8 eigenvectors of YY, together with the error relative to the signal along each eigenvector, ei=viT(ETE/N)vi/λie_i = v_i^{\mathsf{T}}(E^{\mathsf{T}}E/N)v_i/\lambda_i. All four are eigenvalues or traces of 1024×10241024 \times1024 matrices; none needs a network run or a label. They avoid subspace angles on purpose: eigenvectors are poorly estimated from a small sample, and we saw the same difficulty (the principal angle between the two top-8 subspaces is 17° for the rotation, whose error is 10−410^{-4} of the signal, because the cut splits near-degenerate eigenvectors).

The span for the generalization of token samples

The span carries what matters of a set of tokens, so from a small sample we can extrapolate it and rebuild a clone of the inputs of a block: tokens that satisfy the same basic requirements as the real ones. From a small sample of real tokens zz at the input of the feed-forward part of a block2 we estimate by a fixed rule the span of the standardized tokens and how the tokens load on it. Most tokens form a bulk, Gaussian with the mean and the covariance of the typical tokens (the covariance turns out to be optional, the mean is not). A few tokens are hot: they load on one hot eigenvector u1u_1, the first eigenvector of the second moment of the standardized tokens with the largest energy (the top 1%), with its sign fixed positive. The hot share pp is the fraction of tokens whose projection on u1u_1 exceeds three standard deviations of the others’ projections, and the amplitude of the load is a log-normal fitted to the projections of the hot tokens. A hot token is z=cn u1+1−c2 bz = c\sqrt{n}\,u_1 + \sqrt{1-c^2}\,b with bb a bulk token orthogonalized to u1u_1 and scaled to norm n\sqrt{n} and cc the amplitude over n\sqrt{n}, then standardized. The description is u1u_1 (about six channels), pp, two amplitude numbers and the mean: about ten numbers.

Observations and findings

observationmeasurementstatus
O1a (WT−1)ji∼N(0,σj2)(WT^{-1})_{ji} \sim N(0,\sigma_j^2)Kolmogorov–Smirnovfc2 0/24 rejected, fc1 20/24 rejected
O1b b=4b = 4: θ(WT−1,Q(WT−1))=5.59∘\theta(WT^{-1}, Q(WT^{-1})) = 5.59^\circweight anglefc2: true (median 5.57°, no token above 6.3°); fc1: only the median (5.52°, tokens up to 7.7°)
O2 The unrotated weight tokens have heavy tails, and the Lloyd–Max schemes (StaticLM-crop and FitLM-crop) lose to Grid-crop in the tail.99th percentile of the weight angle, 8 bitsFitLM-crop 48/48, StaticLM-crop 45/48

Table 4. Observations, the test that could refute each, and the status.

observationmeasurementstatus
O3Spearman correlation of the stream angle after the last block, the logit angle and the KL divergencerank correlation over the schemes and the widthsstream–logit 0.988, stream–KL 0.997, logit–KL 0.990; within one width 1.00 at 8, 6 and 4 bits, 0.80 at 2 bits
O4top-1 and the share of changed images, at 4 bits95% intervals, per scheme and per sampletop-1: intervals overlap in 6/6 pairs of schemes on 5000-995 and on 50000-1000; changed share: disjoint in 5/6 and 6/6 pairs, the same on both samples for every scheme
O5rotation: independent errors, φn∝n1/2\varphi_n \propto n^{1/2}exponent pp of φn∝np\varphi_n \propto n^protation p=0.43p = 0.43 to 0.530.53 at 8, 6, 4 and 2 bits; the crop schemes rise above it at 6 and 4 bits, Grid-crop not at 8 and 2 bits
O6φ(xb′)≫φFFN\varphi(x_b') \gg\varphi_{\mathrm{FFN}}, and φFFN\varphi_{\mathrm{FFN}} does not depend on the inputmedian angle at the end of block 20: arriving, and added by the block with the clean and with the in-context inputarriving 12.1∘12.1^\circ, added 2.12.1 to 2.9∘2.9^\circ; the added error changes by at most 3% with the input
O7FitLM-crop << Grid-crop alone, >> in all 48 matriceslogit angle, 4 bits<< in 4 of 4 blocks; 16.45∘>9.41∘16.45^\circ> 9.41^\circ
O8the gap in φ23\varphi_{23} between all FitLM-crop and all Grid-crop (6.9∘6.9^\circ) arises in fc2FitLM-crop swapped into fc1 or fc2 of blocks 8–15 of the Grid-crop networkfc2 +4.2∘+4.2^\circ, fc1 +0.2∘+0.2^\circ
O9the sensitivity of a block in isolation at low bits locates the blocks that matter in contextoverlap of the top 5 blocks, isolation and contextStaticLM-rot 2 bits 4/5, Grid-crop 3 bits 5/5, FitLM-crop 8 bits 4/5; FitLM-crop and StaticLM-crop 4 bits 1/5
O10from 500 images and their eigen factors we reproduce the span measures of the real inputsSpearman correlation of the span measures, real against generated, over scheme-by-measure pairsblocks 11–14: 0.98 to 1.00; block 17: 0.98 with the mean, 0.60 without

Table 1 (PDF p. 8).

Results

We follow the error from the weights to the classification and through the blocks of the network (the weights, classification, the error flow), then into single blocks (isolation and context, the span of fc2, its trigger, the input scheme), and end with mixed policies.

The weights

After a random-sign Hadamard rotation the coordinates of the weight tokens are Gaussian in fc2 and closer to Gaussian in fc1 (O1a); the unrotated tokens have heavy tails, the largest coordinate of a matrix being 10 to 37 sigma (O2). For a Gaussian token a table with relative squared error DD (after the best scale of the compressed token) turns it by θ=arcsin⁡D\theta= \arcsin\sqrt{D}, which is 5.59∘5.59^\circ at 4 bits (O1b). Table 5 and Table 6 give the weight angle at 4 and 8 bits.

4 bits, median angle (∘^\circ)StaticLM-rotGrid-cropFitLM-cropStaticLM-crop
fc1 (median over 24 blocks)5.526.335.675.62
fc2 (median over 24 blocks)5.577.016.136.24

Table 5. Weight angle at 4 bits.

8 bits, over the 48 matricesmedian99th pctmaxsmallest norm ratio
Grid-crop0.521.413.120.997
FitLM-crop0.502.5010.960.881
StaticLM-crop0.388.5028.420.680
StaticLM-rot0.360.420.740.999

Table 6. Weight angle (degrees) at 8 bits: median over the matrices of the per-matrix median, 99th percentile and maximum over tokens, and the smallest ratio ∥w~∥/∥w∥\|\widetilde{w}\|/\|w\|.

Classification

Table 7 gives the sweep on 5,000 images and Table 8 the result at 4 bits on 50,000. The rotation is the closest to float32 at every width; the agreement falls gently from 8 to 4 bits and steeply below 3 bits, and the logit angle of the rotation grows by a factor of 1.98 to 1.99 per bit from 8 to 3 bits, as a weight distortion that falls by four per bit would give (O3). At 4 bits FitLM-crop is below Grid-crop by −1.23 [−1.40, −1.07] points of agreement and −0.30 [−0.44, −0.15] of top-1 (paired, 50,000 images). The intervals of top-1 overlap for every pair of schemes on both samples, while the share of images that change class is 1.6, 3.1, 4.4 and 5.2 to 5.6% and is the same on both (O4).

865432 bits
agreement (%)StaticLM-rot99.9299.5698.9298.4496.7092.22
Grid-crop99.7899.2898.2496.9094.1882.34
FitLM-crop99.4098.9097.8295.6493.3485.68
StaticLM-crop96.7895.8295.6294.7692.5683.52
logit angle (∘^\circ)StaticLM-rot0.230.901.793.547.0215.37
Grid-crop0.452.094.609.4115.1228.46
FitLM-crop1.892.785.8716.4521.7530.79
StaticLM-crop11.4814.5016.7419.2423.2932.04
mean KLStaticLM-rot0.00000.00030.00110.00440.01820.1087
Grid-crop0.00010.00110.00740.02670.06980.4574
FitLM-crop0.00070.00150.00760.05590.11270.4581
StaticLM-crop0.03260.04480.05730.07720.13770.5404

Table 7. Sweep on 5,000 images, all 48 FFN matrices compressed.

agreement (%)top-1top-5changed / broken / fixedlogit angleKL
float32–85.8497.82–––
StaticLM-rot98.40 [98.29, 98.51]85.6997.83802 / 320 / 2443.540.0041
Grid-crop96.84 [96.69, 96.99]85.5997.731580 / 623 / 5019.350.0264
FitLM-crop95.61 [95.44, 95.80]85.2997.642193 / 923 / 65016.490.0556
StaticLM-crop94.42 [94.22, 94.62]85.0697.562792 / 1200 / 81219.270.0775

Table 8. 4 bits, 50,000 validation images, all 48 matrices.

The error flow

Figure 1 shows the median stream angle after each block at 4 bits and Figure 2 the spectrum angle of the stream; the other widths are in Appendix A. Table 9 gives the growth exponents. The rotation follows n1/2n^{1/2} at every width (O5) and the crop schemes rise above it in the later blocks. The spectrum angle is not cumulative: it rises where a scheme loses energy (after the 12th to the 14th block, that is blocks 11 to 13, for the Lloyd–Max schemes at 4 bits) and falls back in the later blocks, while the stream angle keeps growing.

Median angle of the residual stream against the number of blocks

Figure 1. Median angle of the residual stream against the number of blocks, 4 bits, 5,000 images. Left: log–log with the n\sqrt{n} line. Right: the angle divided by φ1n\varphi_1\sqrt{n}.

Spectrum angle flow, 4 bits, 98,500 tokens (first 32 eigenvalues of the stream)

Figure 2. Spectrum angle of the residual stream against the number of blocks, 4 bits, 500-401 (98,500 tokens): the angle between the first 32 eigenvalues of the second moment of the stream, compressed against float32. Left: log scale. Right: linear.

8642 bits
exponent pp (all / late)StaticLM-rot0.53 / 0.540.53 / 0.530.51 / 0.490.43 / 0.29
Grid-crop0.48 / 0.430.51 / 0.730.42 / 0.670.37 / 0.13
FitLM-crop0.75 / 1.640.61 / 1.140.62 / 1.140.46 / 0.49
StaticLM-crop0.63 / 1.340.61 / 1.110.53 / 0.770.42 / 0.45
angle after block 24 (∘^\circ)StaticLM-rot0.522.027.8532.27
Grid-crop0.944.6317.8852.50
FitLM-crop3.995.3024.6251.34
StaticLM-crop19.1022.1328.5053.04

Table 9. Growth exponents (over all 24 blocks, and over blocks 13–24) and the final stream angle, 5,000 images.

Isolation and context

Compressed alone, the fitted table is as good as or better than the grid in blocks 0, 1, 20 and 21; in all 48 matrices it is worse (O7). The error that arrives at block 20 is four to five times the error the block adds, and the error the block adds hardly depends on its input (Table 10, O6). Swapping the fitted table into the grid network puts the gap in fc2 (Table 11, O8). The sensitivity of a block in isolation locates the blocks that matter in context for a mild error, and not for the table schemes at 4 bits (O9): isolation points to blocks 23, 22, 11, 21 and 0, context to blocks 11, 12, 13, 17 and 14.

median angle at the end of block 20 (∘^\circ)StaticLM-rotGrid-cropFitLM-crop
local error, clean input2.192.882.45
local error, in-context input2.112.902.49
total error (arriving + local)12.3312.6312.57

Table 10. Block 20 at 4 bits, 500 images. The error that arrives from the blocks before is 12.14∘12.14^\circ.

network (4 bits, 500 images)angle after block 23 (°)
all GRID-CROP17.87
all FITLM-CROP24.75
GRID-CROP with FITLM-CROP in blocks 0–7 / 8–15 / 16–2117.88 / 22.21 / 18.41
GRID-CROP with FITLM-CROP in blocks 22–2318.83
GRID-CROP with FITLM-CROP in fc1 / fc2 of blocks 8–1518.05 / 22.06
FITLM-CROP with GRID-CROP in blocks 0–7 / 8–15 / 16–2124.73 / 19.57 / 22.86
FITLM-CROP with GRID-CROP in blocks 22–2323.77
FITLM-CROP with GRID-CROP in fc1 / fc2 of blocks 8–1524.66 / 19.67

Table 11. Swap tests: median stream angle after the last block.

The error of fc2 in the span of its output

Table 12 gives the span measures of § 5.1 for fc2 of blocks 11 and 17, compressed alone, at 4 bits. At block 11 the fitted table loses the dominant eigenvector of the output (μ1=0.09\mu_1 = 0.09), made of the stream channels 681 and 724, rows of W2W_2 with coordinates of 22 to 27 sigma: the weight angle of these rows is 1.5 times the grid’s and the output error 400 times. The spectrum angle orders the schemes as the end of the flow does, the median branch angle does not. At block 17 both crop schemes lose the dominant eigenvector (spectrum angle 25.6 and 29.8°) and the rotation does not (0.11°).

block 11block 17
FITLM-CROPGRID-CROPSTATICLM-ROTFITLM-CROPGRID-CROPSTATICLM-ROT
spectrum angle (°)19.774.460.0225.6029.840.11
spectrum distance0.8030.2960.0160.8270.8180.011
dominant gain μ1\mu_10.0900.6470.9830.0470.0870.986
in-span share (32)0.9190.9510.9990.9570.9610.997
error in the top-8 eigenvectors (%)93.244.83.091.688.61.1
error over signal, top 80.4290.0380.00010.4720.3820.0002
error on the top 1% of tokens (%)68.162.26.352.651.85.7
branch angle, median (°)6.808.295.755.956.745.69
final angle, isolation (°)3.431.620.971.421.471.06

Table 12. fc2 of one block compressed alone at 4 bits, 500 images. The span measures of Section 5.1, the concentration of the error on tokens, the median branch angle (the angle between the output of fc2 and its compressed counterpart, per token) and the final stream angle.

What triggers the error: the input

Gaussian tokens do not trigger the loss: with the real mean and covariance they give a spectrum distance of 0.03 for the fitted table at block 11, against 0.80 for the real input. Independent hidden units with the real energy of each unit reproduce most of it (0.53), and the same energies permuted over the units remove it (0.02): it is the alignment of the input energy with the outlier columns of the heavy rows that triggers the error. At block 11 that energy comes from about 1% of the tokens, which lie along one eigenvector u1u_1 of six channels (724, 681, 319, 612, 427, 131).

The input scheme across blocks

Table 13 applies the description of § 5.2, estimated on 500 images of each block, to seven blocks and judges it on all 5,000 images, 4,500 of which were not used for the estimation. At blocks 11 to 14 it reproduces the span measures and the order of the schemes (Spearman 0.98 to 1.00); block 17 needs the mean of the tokens (0.60 without, 0.98 with); the quiet blocks 5 and 8 have no hot population, and the description reproduces their lack of failure (spectrum distance of the fitted table 0.023 and 0.097 against the real 0.026 and 0.031). Where the local measures cannot tell the two crop schemes apart (blocks 14 and 17), the description gives the same answer.

blockpp (%)ch. 60% of u1u_1spectrum dist. real / schemeSpearman 15 pairstable − grid real / scheme
518.7*630.026 / 0.0230.957−0.009 / −0.006
897.6*370.031 / 0.0970.814−0.002 / +0.017
115.140.804 / 0.7501.0000.509 / 0.465
125.130.877 / 0.7601.0000.547 / 0.443
134.630.843 / 0.6620.9750.347 / 0.189
144.330.811 / 0.6000.9930.050 / 0.012
174.630.834 / 0.9290.9790.009 / 0.044

Table 13. The input scheme (with the mean) estimated on 500 images and compared with the real 5,000 images, fc2fc2 at 4 bits: the hot share pp and the channels carrying 60% of u1u_1; the spectrum distance of the fitted table, real and generated; the Spearman correlation over the scheme-by-measure pairs; and the spectrum distance of the fitted table minus that of the grid, real and generated. 1

Mixed policies

Rotating a few matrices does not recover the gap. With the fitted table elsewhere, rotating block 0 and fc1fc1 of block 1 (3 matrices), 4 matrices, or the 12 most sensitive matrices gives 95.94, 95.82 and 95.76% agreement (5,000 images), against 95.64% for none and 98.44% for all. On a grid base, rotating blocks 0–1 gains 0.11 [0.01, 0.20] points of agreement on 50,000 images, and the fitted table in blocks 20–21 changes the agreement by −0.04 [−0.14, +0.06] while the mean KL rises by 0.0048.

Conclusion

The angle between the compressed and the float32 residual stream, followed through the blocks, ranks the schemes as the classifier does and separates what top-1 and top-5 do not. The spectrum of the output of a matrix gives a measure that depends on the context, and a description of a few numbers estimated on 500 images generates inputs on which it can be studied. Together they show the two regimes of the error (independent accumulation with the rotation, amplification with the crop schemes) and where a scheme loses: in fc2fc2 of a few blocks, through the dominant eigenvector of its output.

Scope. One model, the FFN weights, one random sign seed, and float32 evaluation of the compressed weights, so that we measure the representation and not a kernel and report no run time, including the cost of the rotation. The span analysis is at 4 bits and the flow curves are medians over tokens.

The error flow at 8, 6 and 2 bits

Figure 1 for the other widths: the median angle of the residual stream against the number of blocks, 5,000 images. Left: log–log with the n\sqrt{n} line. Right: the angle divided by φ1n\varphi_1\sqrt{n}.

Error flow, 8 bits

Figure 3. Error flow, 8 bits.

Error flow, 6 bits

Figure 4. Error flow, 6 bits.

Error flow, 2 bits

Figure 5. Error flow, 2 bits.

The spectrum angle flow at 8, 6 and 2 bits

Spectrum angle flow, 8 bits

Figure 6. Spectrum angle flow, 8 bits (as Figure 2).

Spectrum angle flow, 6 bits

Figure 7. Spectrum angle flow, 6 bits.

Spectrum angle flow, 2 bits

Figure 8. Spectrum angle flow, 2 bits.

References

  1. [1]Saleh Ashkboos, Amirkeivan Mohtashami, Maximilian L. Croci, Bo Li, Pashmina Cameron, Martin Jaggi, Dan Alistarh, Torsten Hoefler, and James Hensman. QuaRot: Outlier-free 4-bit inference in rotated LLMs. In Advances in Neural Information Processing Systems, volume 37, 2024.arxiv.org/abs/2404.00456
  2. [2]Jerry Chee, Yaohui Cai, Volodymyr Kuleshov, and Christopher De Sa. QuIP: 2-bit quantization of large language models with guarantees. In Advances in Neural Information Processing Systems, volume 36, pages 4396–4429, 2023.arxiv.org/abs/2307.13304
  3. [3]Paolo D’Alberto. Statistical inference and quality measures of KV cache quantisations inspired by TurboQuant, 2026.
  4. [4]Paolo D’Alberto, Ashish Siarasao, Elliott Delaye, and Rajeev Patwari. Ablation, statistical inference, and validation for KV-cache compression, 2026.
  5. [5]Tim Dettmers, Artidoro Pagnoni, Ari Holtzman, and Luke Zettlemoyer. QLoRA: Efficient finetuning of quantized LLMs. In Advances in Neural Information Processing Systems, volume 36, pages 10088–10115, 2023.arxiv.org/abs/2305.14314
  6. [6]Alexey Dosovitskiy, Lucas Beyer, Alexander Kolesnikov, Dirk Weissenborn, Xiaohua Zhai, Thomas Unterthiner, Mostafa Dehghani, Matthias Minderer, Georg Heigold, Sylvain Gelly, Jakob Uszkoreit, and Neil Houlsby. An image is worth 16x16 words: Transformers for image recognition at scale. In International Conference on Learning Representations, 2021.
  7. [7]Elias Frantar, Saleh Ashkboos, Torsten Hoefler, and Dan Alistarh. GPTQ: Accurate post-training quantization for generative pre-trained transformers. In International Conference on Learning Representations, 2023.arxiv.org/abs/2210.17323
  8. [8]Ji Lin, Jiaming Tang, Haotian Tang, Shang Yang, Wei-Ming Chen, Wei-Chen Wang, Guangxuan Rein Xiao, Xingyu Dang, Chuang Gan, and Song Han. AWQ: Activation-aware weight quantization for on-device LLM compression and acceleration. In Proceedings of Machine Learning and Systems, volume 6, pages 87–100, 2024.DOI
  9. [9]Zechun Liu, Changsheng Zhao, Igor Fedorov, Bilge Soran, Dhruv Choudhary, Raghuraman Krishnamoorthi, Vikas Chandra, Yuandong Tian, and Tijmen Blankevoort. SpinQuant: LLM quantization with learned rotations. In International Conference on Learning Representations, 2025.arxiv.org/abs/2405.16406
  10. [10]Stuart P. Lloyd. Least squares quantization in PCM. IEEE Transactions on Information Theory, 28(2):129–137, 1982.DOI
  11. [11]Joel Max. Quantizing for minimum distortion. IRE Transactions on Information Theory, 6(1):7–12, 1960.DOI
  12. [12]Quinn McNemar. Note on the sampling error of the difference between correlated proportions or percentages. Psychometrika, 12(2):153–157, 1947.pubmed.ncbi.nlm.nih.gov/20254758
  13. [13]Andreas Steiner, Alexander Kolesnikov, Xiaohua Zhai, Ross Wightman, Jakob Uszkoreit, and Lucas Beyer. How to train your ViT? data, augmentation, and regularization in vision transformers. Transactions on Machine Learning Research, 2022, 2022.
  14. [14]Sijie Yan, Yuan Yuan, Jiaming Ning, Yanhao Zhang, Zhongmin Wang, Chengjie Wang, and Hao Sheng. Positive-congruent training: Towards regression-free model updates. In Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition, pages 14299–14308, 2021.arxiv.org/abs/2011.09161

Paper details

vlnc:W_2bjhbgm6
Version
v1 · latest
Published
Fresh — added to the Hub within the last 30 days
Added
License
CC BY 4.0
Usage

views · 0

downloads · 0

A view counts once per browser per day, a download each time the PDF is requested.

  • Computer Science

Not recorded for this paper

View statement
Looking for related papers…
Contents