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 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.
| name | what it is |
|---|---|
| CATS | a router that keeps the neurons whose gate value is largest for the current token, with no training |
| GRIFFIN | a router that scores neurons on the prompt once and reuses that choice for the whole generation |
| LaRoSA | a router that rotates the MLP input into a new basis learned from data and keeps the largest coordinates there |
| MMLU | multiple choice questions across 57 school and professional subjects |
| ARC-C and ARC-E | grade school science questions, a challenge set and an easy set |
| BoolQ | yes or no questions about a short passage |
| HellaSwag | pick 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 , gate and up projections and down projection , the block computes
with 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,
Each neuron owns one fixed direction in output space, the column , and contributes that direction scaled by a scalar that depends on the token. The MLP output is the point you reach by laying arrows head to tail.
A routing score ranks the neurons and a top- mask keeps of the arrows, so the output becomes at density . The error is the sum of the arrows you dropped. So the arrows to drop are the short ones, where length means times , 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 , 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 but computes its mask once on the prompt and reuses it for every generated token, so its routing is not per token.
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 moves the hidden vector by along the -th axis. If the loss is smooth in , 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,
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 . 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 . Then divide out the part the runtime score already measures,
The denominator is the point. The runtime score already carries the gate magnitude for this token, so dividing by its average leaves 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
Setting every 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 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 work per token per layer, meaning the cost grows in step with the number of neurons and no faster.
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 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. was computed from the distribution of and , 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 the only thing that adapts, which is also the only matrix the mask touches.
The hard top- 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 , a raw score derived from where sits in the ranking, and the mask is . 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 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 falls the ramp steepens into a step at the top- line.
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 , 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 , on the same distribution as calibration so that stays valid as the adapters update.
At inference the soft mask collapses to hard top- and 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, , 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.
| method | PPL | MMLU | Avg5 |
|---|---|---|---|
| dense | 1.27 | 46.2 | 51.44 |
| CATS, no training | 3.56 | 29.2 | 43.04 |
| GRIFFIN-prefill, no training | 3.94 | 25.4 | 46.16 |
| LaRoSA, no training | 2.65 | 34.0 | 48.60 |
| CLAWS signal only | 2.17 | 35.4 | 45.72 |
| dense + LoRA | 1.25 | 44.4 | 50.72 |
| CATS + LoRA | 1.89 | 42.8 | 52.60 |
| LaRoSA + LoRA | 1.54 | 46.6 | 50.00 |
| CLAWS | 1.70 | 49.6 | 53.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 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 , and is folded into the weights as and , so the function is unchanged, .
Routing is then a magnitude top- over the coordinates of . Zeroing coordinate of the input zeros column of the rotated and , 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 and several versions of the constant. We used the average absolute gradient with respect to , 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 and swap order under only when is larger than . 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- 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 the base score and the modifier, define the leverage
When is small the score varies more than its modifier and rankings stay driven by magnitude. When is near one the two are matched and the modifier can move things across the boundary.
The numbers are these. The rotated input magnitude has against 2.96 for its modifier, so . The raw native gate is just as spread, 5.08, so a constant would have had no leverage there either.
But CATS routes on , 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 comes out at 2.83. The CLAWS modifier has spread 2.95, so . 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 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.
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 . 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 drops column of and , 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, and , 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.
What it does not say
- There are two model families, Gemma-4-E2B-IT and Llama-3-8B-base, so nothing is known about scaling further.
- The ARM number is the MLP block in isolation, not end-to-end decode with attention, and the 1.1 times full-model figure is an estimate from the MLP's share.
- bundles four factors, gate, up, column norm and gradient, and we have not ablated them one at a time.
- On the base model LoRA moved MMLU down one point and Avg5 up two, so the recovery step is a win on the instruction-tuned model and a wash on the base one.
- Longer-form generation quality is only partly reported.
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
- Lee et al., CATS: contextually-aware thresholding for sparsity in large language models, COLM, 2024.
- Liu et al., LaRoSA: enhancing LLM efficiency via layerwise rotated sparse activation, ICML, 2025.
- Dong, Chen and Chi, Prompt-prompted adaptive structured pruning for efficient LLM generation, COLM, 2024.
- Liu et al., Deja Vu: contextual sparsity for efficient LLMs at inference time, ICML, 2023.
- Song et al., PowerInfer: fast large language model serving with a consumer-grade GPU, SOSP, 2024.
- Liu et al., Training-free activation sparsity in large language models, ICLR, 2025.
- Hu et al., LoRA: low-rank adaptation of large language models, ICLR, 2022.
- Shazeer, GLU variants improve transformer, 2020.
- Maddison, Mnih and Teh, The concrete distribution: a continuous relaxation of discrete random variables, ICLR, 2017.
- Hinton, Vinyals and Dean, Distilling the knowledge in a neural network, 2015.