Calibration-Aware Activation Sparsity for Instruction-Tuned LLMs

The language models in this post are stacks of transformer blocks, and most of the parameters in each block sit in its MLP. An MLP is three big weight matrices with a nonlinearity in between, where a nonlinearity is any fixed curve applied to each number on its own. A token is a word or a piece of a word, and when a phone generates text it decodes one token at a time. The cost of the MLP at that point is reading its weights, because every token drags all three matrices out of the phone's main memory, DRAM.

The weights are stored quantized. A weight comes out of training as a 16-bit float, a number with about four significant digits. Quantizing it to 4 bits rounds it to one of 16 allowed levels, so it takes a quarter of the bytes to store and a quarter of the time to read. The bytes of those three matrices are the bill.

The activations, the numbers the MLP computes for one token, are skewed. Each hidden unit of the MLP, which I call a neuron, produces one number per token. For any one token a few neurons fire hard and the rest barely move. The down projection is the third matrix, the one that maps the hidden numbers back to the model width, and most of it is being read in order to multiply numbers near zero.

That is the opening for activation sparsity. Keep the top KK neurons for each token, skip the rows of the down projection that belong to the others, and read fewer bytes. The fraction of neurons kept is the density.

Two things have to be right for this to pay. The router, which is the rule that picks which neurons to keep for each token, has to pick the ones that matter. And the mask, the pattern of kept and dropped weights, has to be something a quantized kernel can actually skip, where a kernel is the low-level routine that does the matrix multiply. This post compares three existing routers and measures accuracy on five benchmarks, so here they are first.

namewhat it is
CATSa router that keeps the neurons whose gate value is largest for the current token, with no training
GRIFFINa router that scores neurons on the prompt once and reuses that choice for the whole generation
LaRoSAa router that rotates the MLP input into a new basis learned from data and keeps the largest coordinates there
MMLUmultiple choice questions across 57 school and professional subjects
ARC-C and ARC-Egrade school science questions, a challenge set and an easy set
BoolQyes or no questions about a short passage
HellaSwagpick the most plausible ending to a short everyday scene

CATS gets the mask right. It routes on the size of the gate value alone, which costs nothing and leaves a mask that drops whole rows, and it gives up accuracy.

LaRoSA gets the routing right. A basis is the set of axes a vector's coordinates are written in, and rotating it rewrites the same vector in new coordinates. LaRoSA rotates the input basis using calibration data, which is a few hundred typical sequences run through the model in advance, and routes on magnitude in the rotated basis. That routes well, but its mask drops columns instead of rows, and that fights the memory layouts phones use.

CLAWS keeps the CATS mask and multiplies the gate score by one calibrated constant per neuron. On Gemma-4-E2B-IT, a 4.65 billion parameter instruction-tuned model from Google, at half density it recovers dense accuracy on the five-task average. It beats CATS with the same LoRA recipe by 6.8 MMLU points, where LoRA is a cheap way of doing further training on an already trained model, and I describe it below. A kernel written for ARM phone chips turns the mask into a 1.24 times faster MLP block on Apple silicon.

The gated MLP

This is where the maths comes in, so bear with me.

The MLP in these models is a gated one. For input x∈RDmodelx \in \mathbb{R}^{D_{\text{model}}}, gate and up projections Wg,Wu∈RDFFN×DmodelW_g, W_u \in \mathbb{R}^{D_{\text{FFN}} \times D_{\text{model}}} and down projection Wd∈RDmodel×DFFNW_d \in \mathbb{R}^{D_{\text{model}} \times D_{\text{FFN}}}, the block computes

h=ϕ(Wgx)⊙Wux,y=Wdh, h = \phi(W_g x) \odot W_u x, \qquad y = W_d h,

with ϕ\phi the gate nonlinearity, GELU in Gemma and SiLU in Llama. Both are smooth curves that pass small negative inputs through as nearly zero and large positive inputs through nearly unchanged. The gate and up projections each turn the input into a longer vector of hidden values, the two are multiplied entry by entry, and the down projection maps the result back to the model width.

Write the second product column by column and the geometry appears,

y=∑j=1DFFNhj(x) Wd[:,j],hj(x)=ϕ((Wgx)j) (Wux)j. y = \sum_{j=1}^{D_{\text{FFN}}} h_j(x)\, W_d[:, j], \qquad h_j(x) = \phi((W_g x)_j)\,(W_u x)_j.

Each neuron jj owns one fixed direction in output space, the column Wd[:,j]W_d[:, j], and contributes that direction scaled by a scalar hj(x)h_j(x) that depends on the token. The MLP output is the point you reach by laying DFFND_{\text{FFN}} arrows head to tail.

A routing score rj(x)r_j(x) ranks the neurons and a top-KK mask m(x)m(x) keeps KK of the arrows, so the output becomes y=Wd(m(x)⊙h)y = W_d(m(x) \odot h) at density d=K/DFFNd = K / D_{\text{FFN}}. The error is the sum of the arrows you dropped. So the arrows to drop are the short ones, where length means ∣hj(x)∣|h_j(x)| times ∥Wd[:,j]∥2\|W_d[:, j]\|_2, the size of the scalar times the length of the column, with a further weight for how much the loss cares about being displaced in that direction. The loss is the number training pushes down, the model's average error on the next token, and it is the judge of what matters throughout.

CATS scores with rjCATS(x)=∣ϕ((Wgx)j)∣r_j^{\text{CATS}}(x) = |\phi((W_g x)_j)|, which is one factor of the scalar. It is free, and it ignores the up activation, the length of the column and how sensitive the loss is to any of it. GRIFFIN scores with the fuller ∣hj∣|h_j| but computes its mask once on the prompt and reuses it for every generated token, so its routing is not per token.

the MLP output is a sum of one arrow per neuronarrow j is h_j(x) · W_d[:, j], a fixed direction times a scalar that depends on the token · schematicy, denseŷ, four keptydense, all eight arrowshalf density, the four longest keptdashed arrows are dropped · the gap between ŷ and y is their sum, so short arrows cost littlesaliency also weights each arrow by how much the loss cares about its direction, |g_j|
Each neuron of the MLP contributes one arrow to the output. The arrow always points along that neuron's column of the down projection, and its length changes from token to token. On the left all eight arrows are laid head to tail and reach the dense output. On the right only the four longest are kept, and the gap between where they end and the dense output is the sum of the four that were dropped. The lengths and directions are made up to show the mechanism.

The calibrated constant

The missing factors are all things calibration data can tell you about a neuron in advance. Start with how much the loss cares. Zeroing neuron jj moves the hidden vector hh by −hj(x)-h_j(x) along the jj-th axis. If the loss is smooth in hh, a step that small is well described by a straight-line approximation. The gradient of the loss with respect to a number is the slope, how fast the loss changes when that number is nudged. So the loss moves by its gradient along that axis times the length of the step,

∣ΔLj(x)∣≈∣hj(x) gj(x)∣=∣ϕ((Wgx)j) (Wux)j∣⋅∣gj(x)∣,gj(x)=∂L∂hj(x). |\Delta \mathcal{L}_j(x)| \approx |h_j(x)\, g_j(x)| = \left|\phi((W_g x)_j)\,(W_u x)_j\right| \cdot |g_j(x)|, \qquad g_j(x) = \frac{\partial \mathcal{L}}{\partial h_j(x)}.

This estimate of how much each unit matters is called saliency, and it is the Taylor saliency that SNIP and the rest of the pruning literature use, where pruning means deleting the units of a network that matter least. The estimate is exact as long as the straight-line approximation holds. It costs one backward pass, which is the half of training's computation that runs the network in reverse to get the gradient for every number.

Now make it static. Take the average over a calibration set Dcalib\mathcal{D}_{\text{calib}}. Weight it by the length of the down column, so it measures how far the neuron actually moves the output rather than the size of the scalar hjh_j. Then divide out the part the runtime score already measures,

cj=EDcalib ⁣[ ∣hj(x)∣⋅∥Wd[:,j]∥2⋅∣gj(x)∣ ]EDcalib ⁣[ ∣ϕ((Wgx)j)∣ ]. c_j = \frac{\mathbb{E}_{\mathcal{D}_{\text{calib}}}\!\left[\,|h_j(x)| \cdot \|W_d[:, j]\|_2 \cdot |g_j(x)|\,\right]}{\mathbb{E}_{\mathcal{D}_{\text{calib}}}\!\left[\,|\phi((W_g x)_j)|\,\right]}.

The denominator is the point. The runtime score ∣ϕ((Wgx)j)∣|\phi((W_g x)_j)| already carries the gate magnitude for this token, so dividing by its average leaves cjc_j as the remainder that does not depend on the token. Roughly, that is the typical up magnitude, the column length and the loss sensitivity. The routing score is then

rjCLAWS(x)=∣ϕ((Wgx)j)∣⋅cj. r_j^{\text{CLAWS}}(x) = \left|\phi((W_g x)_j)\right| \cdot c_j.

Setting every cj=1c_j = 1 gives CATS back, so the two routers differ only by how far the multiplier moves the gate-magnitude ranking.

The constants are computed once per layer from gate and up activations and from calibration gradients, with the model in eval mode so nothing random is happening inside it. The calibration set is 500 instruction-formatted sequences drawn equally from the MMLU auxiliary dev set and a chat corpus and rendered with the Gemma-4-IT chat template. The gradients come from the same distillation loss used later for recovery, and ϕ\phi in the formula is whichever nonlinearity the model actually uses.

At inference the extra cost is one multiply of the gate values by a stored vector, before the same partial sort that CATS already does to find the top neurons. That is O(DFFN)O(D_{\text{FFN}}) work per token per layer, meaning the cost grows in step with the number of neurons and no faster.

one static multiplier per neuron reorders the top-K24 neurons drawn, K = 12 · CATS ranks by |φ(W_g x)_j|, CLAWS by |φ(W_g x)_j| · c_jCATS ranking01234567891011121314151617181920212223filled bars are selected · nothing has moved yetCLAWS ranking, the same token01234567891011121314151617181920212223filled bars are selected · 3 neurons swapped in or out, outlinedc_j = E|h_j| ‖W_d[:,j]‖ |g_j| / E|φ(W_g x)_j| · computed once on 500 calibration sequences
The same token is routed twice. In the first frame the 24 neurons are ranked by gate magnitude alone, which is what CATS does, and the top twelve are filled in. In the second frame each neuron's score is multiplied by its fixed constant from calibration and the ranking is redone. A few neurons cross the line in each direction, and these are outlined. On the real model about ten percent of the selected set changes per token at half density. The bar heights are made up.

Recovery training

Routing better closes part of the gap to the dense model. The rest is recovered by training the down projection to live with the mask. The training uses LoRA, which stands for low-rank adaptation. It freezes a weight matrix and learns a small correction to it written as the product of a tall thin matrix and a short wide one, so only a small number of parameters move. Here the adapters have rank 128, meaning the thin matrix has 128 columns, and go on WdW_d only, with the scaling factor alpha set to 128.

The gate, the up projection, the normalisation layers and the embeddings stay frozen, and the reason is the calibration. cjc_j was computed from the distribution of WgxW_g x and WuxW_u x, and if those projections moved during training the constants would describe a model that no longer exists. Freezing them keeps the routing signal calibrated and makes WdW_d the only thing that adapts, which is also the only matrix the mask touches.

The hard top-KK mask is a step function of the scores and has no gradient, so training replaces it with a soft one. Each neuron gets a logit ℓj\ell_j, a raw score derived from where rjCLAWSr_j^{\text{CLAWS}} sits in the ranking, and the mask is m~j=σ(ℓj/τ)\tilde m_j = \sigma(\ell_j / \tau). The function here is the sigmoid, the S-shaped curve that squashes any number into the range zero to one, and the divisor is a temperature. At τ=1\tau = 1 the sigmoid is a gentle ramp across the ranking and every neuron is partly on, so gradient reaches the adapters through all of them. As τ\tau falls the ramp steepens into a step at the top-KK line.

τ\tau falls in a straight line from 1 to 0.01 over the first 60% of the 2,500 training steps and is held at 0.01 for the rest, so by the end the model has been training against something indistinguishable from the hard mask it will be served with. This is the idea behind the Concrete distribution and the Gumbel-softmax, a discrete choice made soft with a temperature so it can be trained.

The teacher is the dense model before any neurons were dropped, and distillation means training the sparse student to copy the teacher's output distribution. The loss is KL(student ∥ teacher)+0.2⋅CE\mathrm{KL}(\text{student} \,\|\, \text{teacher}) + 0.2 \cdot \mathrm{CE}, where KL measures the gap between the student's and teacher's next-token distributions and CE is the ordinary cross-entropy against the correct next token. Both are computed with teacher forcing, meaning the models are fed the correct text so far at every step.

The optimiser is the rule that turns gradients into weight updates, and AdamW is the standard one for transformers. The learning rate is the size of each step. Here it is 10−510^{-5}, on the same distribution as calibration so that cjc_j stays valid as the adapters update.

At inference the soft mask collapses to hard top-KK and Wd+BAW_d + BA is written back as one matrix, so the deployed model has the dense parameter count. The runtime path is a multiply, a partial sort and a matrix-vector product that skips rows.

Results

The model is Gemma-4-E2B-IT, 4.65B parameters, 35 layers, DFFN=6144D_{\text{FFN}} = 6144, run at density 0.5 with 500 items per task and five worked examples in the prompt for MMLU. Avg5 is the unweighted mean of MMLU, ARC-C, ARC-E, BoolQ and HellaSwag. PPL is perplexity on a held-out instruction-formatted set, which measures how surprised the model is by text it has not seen, so lower is better. The upper block of the table routes with no training. Every method in the lower block got the same rank-128 LoRA recipe on about 80M tokens, so routing is the only thing that differs.

methodPPLMMLUAvg5
dense1.2746.251.44
CATS, no training3.5629.243.04
GRIFFIN-prefill, no training3.9425.446.16
LaRoSA, no training2.6534.048.60
CLAWS signal only2.1735.445.72
dense + LoRA1.2544.450.72
CATS + LoRA1.8942.852.60
LaRoSA + LoRA1.5446.650.00
CLAWS1.7049.653.36

The constants alone take CATS from 29.2 to 35.4 MMLU and from 3.56 to 2.17 perplexity at identical cost. Across the density sweep the CLAWS signal has the lowest perplexity of any untrained method at every density and the best MMLU up to density 0.5. At density 0.3, where CATS perplexity blows up to 397.79, it sits at 4.05. LaRoSA has the best untrained Avg5 from density 0.4 up, so before training neither is strictly stronger.

With LoRA, CLAWS is 6.8 points above CATS, 3.0 above LaRoSA and 5.2 above the LoRA-tuned dense model, so the training recipe is not what is doing the work. LaRoSA with LoRA does keep a lower perplexity, 1.54 against 1.70.

The second model is Llama-3-8B-base, which uses SiLU rather than GELU and has not been instruction tuned. It was calibrated on 500 raw sequences from C4, a large web crawl, since web text is what a base model is deployed on. The signal alone lifts CATS from 57.6 to 59.6 MMLU. LoRA then moves MMLU to 58.6 while Avg5 goes from 68.00 to 70.04, and LoRA with only the KL loss on top of CATS moves it from 57.6 down to 55.8.

That is what we would expect once the calibration set already matches deployment. The constants have already taken what the data had to say, and fine-tuning on the same distribution has little to add.

The rotated router and the leverage ratio

LaRoSA answers a different question. Instead of choosing native neurons it estimates a rotation QQ from the covariance of the layer inputs over calibration data, where the covariance is the matrix of how the input coordinates vary together. The rotation is orthogonal, meaning it turns the input without stretching it, so it can be undone. The input is rotated to z=Q⊤xz = Q^{\top} x, and QQ is folded into the weights as WgQW_g Q and WuQW_u Q, so the function is unchanged, (WgQ)(Q⊤x)=Wgx(W_g Q)(Q^{\top} x) = W_g x.

Routing is then a magnitude top-KK over the coordinates of zz. Zeroing coordinate kk of the input zeros column kk of the rotated WgW_g and WuW_u, which is where the column-sparse pattern comes from. It routes well, so the natural test is whether a saliency constant helps it the way it helps CATS.

We tried, with rkrot(x)=∣zk(x)∣⋅ckrotr_k^{\text{rot}}(x) = |z_k(x)| \cdot c_k^{\text{rot}} and several versions of the constant. We used the average absolute gradient with respect to zkz_k, its root mean square, a continuous-mask variant and a local-reconstruction one. None of them moved the method. The reason is in the shapes of the distributions. I work it out here because it says in advance whether any static multiplier can reorder any router that ranks by magnitude.

Multiplying scores is adding their logarithms. Two coordinates ii and kk swap order under a⋅ca \cdot c only when log⁡ci−log⁡ck\log c_i - \log c_k is larger than log⁡ak−log⁡ai\log a_k - \log a_i. So the modifier can only reorder the ranking when its spread in log space is comparable to the spread of the score it multiplies.

What matters is the spread near the top-KK line, so measure it as the ratio of the 95th percentile to the median, which I call the top-tail spread. The 95th percentile is the value that 95% of the numbers fall below, and the median is the value half of them fall below. With ai(x)a_i(x) the base score and cic_i the modifier, define the leverage

λ=log⁡10 ⁣(p95(c)/p50(c))log⁡10 ⁣(p95(a)/p50(a)). \lambda = \frac{\log_{10}\!\left(p_{95}(c) / p_{50}(c)\right)}{\log_{10}\!\left(p_{95}(a) / p_{50}(a)\right)}.

When λ\lambda is small the score varies more than its modifier and rankings stay driven by magnitude. When λ\lambda is near one the two are matched and the modifier can move things across the boundary.

The numbers are these. The rotated input magnitude ∣Q⊤x∣|Q^{\top} x| has p95/p50=5.61p_{95}/p_{50} = 5.61 against 2.96 for its modifier, so λ=0.63\lambda = 0.63. The raw native gate ∣Wgx∣|W_g x| is just as spread, 5.08, so a constant would have had no leverage there either.

But CATS routes on ∣ϕ(Wgx)∣|\phi(W_g x)|, after the nonlinearity. GELU is nearly flat and bounded for negative inputs, which is where 72.39% of Gemma's raw gate values fall, so it squashes the distribution and the top-tail spread of ∣ϕ(Wgx)∣|\phi(W_g x)| comes out at 2.83. The CLAWS modifier cjc_j has spread 2.95, so λ=1.04\lambda = 1.04. The two modifiers are spread almost identically, 2.96 and 2.95. The base scores are not, and that is where the difference between the two routers comes from.

The rank movement confirms it. Normalise ranks to [0,1][0, 1] within each layer and token and look at how far they move when the multiplier is applied. In the rotated basis the standard deviation of the rank change, the typical size of the move, is 0.052 and 4.95% of the selected set changes. In the native gate basis it is 0.124, 2.4 times larger, and 10.01% of the selected set changes, about twice as much. Calibration helps the router whose score GELU has squashed, and barely touches the one whose score is already wide.

top-tail spread of the base score against its modifier, p95 / p50a multiplier can only reorder a ranking when its spread is comparable to the score it multiplies|Qᵀx| rotated input5.61c_rot its modifier2.96|W_g x| raw gate, before GELU5.08|φ(W_g x)| native gate2.83c_j CLAWS modifier2.95λ = log(p95/p50 of c) / log(p95/p50 of score) · 0.63 in the rotated basis, 1.04 in the native gate basis
Each bar is how spread out a set of numbers is, measured as the 95th percentile divided by the median. The rotated input and the raw gate are both about twice as spread as the constants that would multiply them, so a constant rarely pushes a neuron across the top-K line in either. GELU squashes the raw gate down to the same spread as its constant, and once the two are matched the constant has enough leverage to reorder the ranking.

Kernel speed on ARM chips

At decode time the MLP is a matrix times a single vector, and it reads every byte of its weight matrix once per token. The speed-up from sparsity is therefore the fraction of bytes you manage not to read, and that depends on where the sparse index sits in the storage layout.

Quantized weights are stored in blocks along the axis that gets summed over, each block a run of 4-bit values with its own scale factor, and a kernel reads blocks whole. In the maths a kept neuron is the column Wd[:,j]W_d[:, j]. In the quantized file it is a row of blocks, and what matters is whether those blocks sit together in memory.

In the layout used by GGML, the library behind llama.cpp, they do not. So a kernel that skips dead neurons, PowerInfer's for instance, still touches the same bytes as the dense kernel. Its cache misses, the reads that the chip's small fast memory cannot serve and that wait on DRAM instead, grow with the number of live neurons.

The Cactus layout stores the 4-bit weights interleaved so that the groups belonging to one neuron sit together, and a precomputed bitmask of live groups lets the kernel read those runs in bursts and skip the rest, with no decision to make per row. Half the neurons gone means close to half the bytes gone.

Column sparsity is the opposite case. Dropping rotated input coordinate kk drops column kk of WgW_g and WuW_u, which is one position inside every block of every row. The kernel still reads every block, so the bytes moved stay close to dense, and the only way out is to repack the weights into a layout the rest of the toolchain does not use.

We built two LaRoSA-style kernels to separate kernel quality from layout. A naive one that unpacks each live column to 32-bit floats runs at 0.40 times the dense speed. An optimised one that uses the ARM NEON vector instructions, unpacks the 4-bit values directly and does all its multiply and add work in 8-bit and 32-bit integers runs at 0.71 times dense. Kernel engineering closed a 1.8 times gap between the two and could not close the rest, which comes from the layout. LaRoSA also pays the sparse-access cost on two matrices and CLAWS on one.

The measurements are on Apple M-series chips with GGML Q4_0 weights, meaning 4-bit weights in blocks of 32, and Q8_0 activations, meaning 8-bit activations, at Gemma-4-E2B-IT dimensions, DFFN=6144D_{\text{FFN}} = 6144 and Dmodel=1536D_{\text{model}} = 1536, one token at a time. The benchmark cycles through 35 distinct layers so that 177 MB of weights exceed the cache and every layer's weights come from DRAM, as they do in real decode.

Our dense kernel is already 1.69 times faster than GGML's. At half density the row-sparse full MLP block, with the gate dense and real gathering of rows on up and down, runs 1.24 times faster than our dense kernel, 1.14 with the down projection alone, and 2.11 times faster than GGML dense. At 70% sparsity the full stack reaches 1.41. Since the MLP is roughly half of per-token decode, half density implies a full-model decode gain near 1.1 times.

On an H100, a data centre GPU, in 16-bit floats the same sparse gather is 0.62 times dense at half density and only breaks even near density 0.10, because the GPU's dedicated matrix units win at these matrix sizes. ARM is where this density pays.

row-sparse against column-sparse in a row-major quantized layouteach row of cells is one quantization block of W_d or W_g · the kernel reads whole rowsCLAWS, keep 4 of 8 rows of W_drows read 4 of 8bytes moved halvecontiguous bursts, ×1.24 on the full MLP on ARMLaRoSA-style, keep 8 of 16 columns of W_grows read 8 of 8bytes moved stay denseisolated positions inside blocks, ×0.71 even with a NEON int8 kernel
The grid is a weight matrix as it sits in memory, with each row of cells one block of quantized values that the kernel reads whole. In the first frame CLAWS drops a neuron, which removes a whole row of the down projection, so the kernel skips that row and reads half as many bytes. In the second frame the rotated router drops an input coordinate, which removes one column, so every row still has to be read and almost nothing is saved unless the weights are stored differently.

What it does not say

What stands is that one calibrated constant per neuron is enough to make the cheap, kernel-friendly router accurate. A ratio of two spreads says in advance whether that will work on any router that ranks by magnitude.

References

  1. Lee et al., CATS: contextually-aware thresholding for sparsity in large language models, COLM, 2024.
  2. Liu et al., LaRoSA: enhancing LLM efficiency via layerwise rotated sparse activation, ICML, 2025.
  3. Dong, Chen and Chi, Prompt-prompted adaptive structured pruning for efficient LLM generation, COLM, 2024.
  4. Liu et al., Deja Vu: contextual sparsity for efficient LLMs at inference time, ICML, 2023.
  5. Song et al., PowerInfer: fast large language model serving with a consumer-grade GPU, SOSP, 2024.
  6. Liu et al., Training-free activation sparsity in large language models, ICLR, 2025.
  7. Hu et al., LoRA: low-rank adaptation of large language models, ICLR, 2022.
  8. Shazeer, GLU variants improve transformer, 2020.
  9. Maddison, Mnih and Teh, The concrete distribution: a continuous relaxation of discrete random variables, ICLR, 2017.
  10. Hinton, Vinyals and Dean, Distilling the knowledge in a neural network, 2015.