LLM Compression Without Quantization: Pruning Cuts MLP Width from 8192 to 2048 Channels
You can cut LLM inference costs without quantization by physically removing part of the model. A Machine Learning Mastery walkthrough shows, in a teaching example, how the intermediate width of an MLP block, where the vector expands and then compresses back, is trimmed from 8192 to 2048 channels, a 4x reduction. But real gains only materialize if the runtime can execute the resulting structure efficiently. So check support in your own stack first, and only then prune the model.
AI-processed from Machine Learning Mastery; edited by Hamidun News
When the GPU bill climbs, the first thing people reach for is quantization: storing weights in 8 or 4 bits instead of 16. But that is only one lever. The second is making the model itself smaller, either by removing some weights or whole blocks, or by training a compact model to mimic a large one. Adrian Tam covers this topic in a Machine Learning Mastery article: pruning, structured pruning, and knowledge distillation.
The numbers in the headline come from the author's teaching example, not from a measurement on a real model. In a transformer, each layer has an MLP block: it first expands the vector to a large "intermediate" width, then compresses it back. Suppose that intermediate part has 8192 channels. If you keep 2048, the block becomes 4 times narrower. How much this translates into speed and quality depends on the model and the hardware, and that is what the article is about.
Why shrink a model at all
A smaller model reads fewer weights from memory. It can take up less space for the KV cache, which depends on the number of layers, KV heads, and head size. It also lets you run larger batches or use cheaper hardware. The difficulty lies elsewhere: you have to preserve the behavior the application depends on, and verify that the runtime executes the resulting structure efficiently.
Pruning: zero out the small stuff
The simplest variant is magnitude pruning. The assumption is that weights with small absolute values influence the output less. In the author's example, for a 1024×1024 matrix, a quantile threshold is chosen and half the weights are zeroed. The matrix is then converted to the CSR sparse format, which stores only the nonzero values along with row and column indices.
Here is the trap. After zeroing, the tensor still sits in memory as a dense array, so the zeros save nothing. The sparse format saves memory only if the index overhead weighs less than the removed values. It speeds things up only if an efficient sparse kernel exists for your matrix shape, sparsity level, data type, and GPU. Otherwise, the model looks slimmer in a report but doesn't get faster in production. To check results, the author compares sparse and dense multiplication with a tolerance for numerical error, since the summation order differs between them.
Structured pruning: cut out whole blocks
The alternative is to remove not individual weights but whole units: attention heads, MLP channels, or layers. The result can be assembled into a smaller dense model, and such models are easier to accelerate on any hardware.
In an MLP, each intermediate channel is created by one row of the first matrix and consumed by one column of the second. So if you remove a row, you must also remove its paired column. The author's code ranks rows by norm and keeps the largest ones. With keep_channels=2048, the width of 8192 shrinks to 2048.
There is an important caveat. This code preserves shape compatibility but does not prove that the removed channels were redundant. Real methods evaluate layer outputs and their interactions, and fine-tune the model after cutting. Attention heads are trickier: with GQA, several query heads share one KV head, and arbitrary removal breaks that grouping. Removing layers changes the depth of the residual stream and may require retraining the connections between the remaining layers.
Another nuance: awkward hidden sizes sometimes run slower than slightly larger sizes that suit the hardware better. It's worth aligning channel counts with the tile-size requirements of matrix-multiplication kernels.
Distillation: teach a small model from a large one
The third path is to take a large teacher model and train a smaller student model. The student can learn from the teacher's probability distribution (it sees not only the best token but also which other options the teacher considered plausible), from intermediate representations, or from generated data.
The example uses the classic distillation loss: the Kullback–Leibler divergence between the teacher's and student's distributions, softened by a temperature T and multiplied by T². It equals zero when the distributions match and grows as they diverge. The author also names the constraints: the teacher and student must share a vocabulary and the same token positions. Obtaining teacher outputs also takes time, even though no gradients are computed for the teacher. The example uses two randomly initialized GPT-2-style models and shows only a single training step, which produces no useful model. A real experiment requires a pretrained teacher and representative text.
- Dec 2, 2026Qwen3.8-27B at 4-Bit Quantization Weighs 16.6 GB Instead of 55 GB: How to Read the Filename
- Dec 2, 2026Ollama client mistakes a truncated response for a finished one: five integration bugs and how to catch them
- Dec 2, 2026T-Decision-1 with 9B Parameters Beats Copernicus-57B on Russian: 71.6 vs. 71.2 Points
- Dec 2, 2026Canonical Releases Ubuntu 26.04 for RTX Spark Laptops with 128 GB of Shared Memory
Key Questions Answered
Why shrink a model at all?
A smaller model reads fewer weights from memory. It can take up less space for the KV cache, which depends on the number of layers, KV heads, and head size. It also lets you run larger batches or use cheaper hardware. The difficulty lies elsewhere: you have to preserve the behavior the application depends on, and verify that the runtime executes the resulting structure efficiently.
What are the key details on Pruning: zero out the small stuff?
The simplest variant is magnitude pruning. The assumption is that weights with small absolute values influence the output less. In the author's example, for a 1024×1024 matrix, a quantile threshold is chosen and half the weights are zeroed. The matrix is then converted to the CSR sparse format, which stores only the nonzero values along with row and column indices. Here is the trap. After zeroing, the tensor still sits in memory as a dense array, so the zeros save nothing.
What are the key details on Structured pruning: cut out whole blocks?
The alternative is to remove not individual weights but whole units: attention heads, MLP channels, or layers. The result can be assembled into a smaller dense model, and such models are easier to accelerate on any hardware. In an MLP, each intermediate channel is created by one row of the first matrix and consumed by one column of the second. So if you remove a row, you must also remove its paired column. The author's code ranks rows by norm and keeps the largest ones.
Test Frontier LLMs & Autonomous Agents in One Workspace
Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.
Daily 60-sec AI Voice Brief + Weekly Production AI Agent Playbook
Listen to a 60-second AI news brief every morning and get a weekly hands-on playbook for shipping AI agents to production — tools, MCP servers and patterns that work. Curated by Jemal Hamidun, Head of AI at Alpina Digital.
