Efficiency

Pruning: Removing Unnecessary Weights

Reduce parameter count by zeroing or removing weights. Unstructured sparsity needs sparse kernels for speed; structured pruning removes whole channels/heads to shrink dense tensor shapes.

status: publishedimportance: importantdifficulty 3/5math: undergraduateread: 16mlive demo
Editorial efficiency illustration of a dense weight grid being pruned into a smaller sparse structure.

Concept Structure

Pruning: Removing Unnecessary Weights

01Intuition

Start with the picture, metaphor, or geometric mechanism.

02Math

Make the objects explicit and connect them with notation.

03Code

Mirror the equations with runnable implementation details.

04Interactive Demo

Manipulate the mechanism and watch the idea respond.

2prerequisites
1next concepts
1related links

Learning map

Pruning: Removing Unnecessary Weights
BeforeEfficiency: Quantization, Distillation, LoRA & Sparse MoENow4/4 sections readyTryManipulate one control and predict the visible change.NextQuantization: Compressing Models to Integers

Object flow

4/4 sections readyAsk about thisResearch room
ConceptPruning: Removing Unnecessary WeightsEfficiency
2 sources attachedLocal snapshot ready
concept:efficiency/pruning

Conceptual Bridge

What should feel connected as you move through this page.

Carry inEfficiency: Quantization, Distillation, LoRA & Sparse MoE

Bring the mental model from Efficiency: Quantization, Distillation, LoRA & Sparse MoE; this page will reuse it instead of restarting from zero.

Work herePruning: Removing Unnecessary Weights

Reduce parameter count by zeroing or removing weights. Unstructured sparsity needs sparse kernels for speed; structured pruning removes whole channels/heads to shrink dense tensor shapes.

Carry outQuantization: Compressing Models to Integers

The next edge should feel earned: use the demo prediction here before following Quantization: Compressing Models to Integers.

Test the linkManipulate one control and predict the visible change.Then continue to Quantization: Compressing Models to Integers
01

01

Intuition

Build the mental picture first so the rest of the page has something to attach to.

Section prompt

Deep nets are often heavily overparameterized. Pruning asks: can we remove weights (or whole structures like neurons/heads) while keeping most of the performance?

Two big distinctions matter:

  • Unstructured pruning: set individual weights to zero. This can give huge sparsity numbers, but you only get speedups if your hardware/software stack has sparse kernels.
  • Structured pruning: remove whole channels/heads/blocks. This often gives smaller compression, but because it changes dense tensor shapes, it is more likely to translate into wall-clock speedups on standard kernels.

The surprising part is that naive rules (like "prune small weights") often work decently, even though they are not theoretically optimal.

02

02

Math

Translate the story into symbols, assumptions, and a derivation you can inspect.

Section prompt

Magnitude pruning (a common baseline)

Let WW be a weight matrix and let θ\theta be a threshold. Define a mask:

Mij=1[Wij>θ],Wpruned=WM.M_{ij}=\mathbf 1[|W_{ij}|>\theta],\qquad W_{\text{pruned}}=W\odot M.

Structured pruning (remove units)

If SS is the set of columns/heads you keep, structured pruning changes the layer shape:

Wpruned=W[:,S].W_{\text{pruned}} = W[:,\,S].

This changes the model shape, which is why it can translate into ordinary dense-kernel speedups more directly.

03

03

Code

Keep the implementation aligned with the notation so the algorithm is legible.

Section prompt
import numpy as np

rng = np.random.default_rng(0)
W = rng.normal(size=(256, 256)).astype(np.float32)

sparsity = 0.7  # prune 70% of weights by magnitude
th = np.quantile(np.abs(W), sparsity)
M = (np.abs(W) > th).astype(np.float32)
W_pruned = W * M

print("target sparsity:", sparsity)
print("actual sparsity:", round(float((M == 0).mean()), 3))
print("L2 norm ratio ||W_pruned||/||W||:", round(float(np.linalg.norm(W_pruned) / np.linalg.norm(W)), 3))
04

04

Interactive Demo

Use direct manipulation to connect the explanation to a moving system.

Section prompt

The demo below asks you to predict which pruning pattern actually turns into a speedup before revealing the mask and deployment metrics. The key invariant is that unstructured zeros reduce storage and sometimes sparse-kernel work, but structured pruning changes the dense matrix shape and therefore can map to ordinary GPU speedups more directly.

Live Concept Demo

Explore Pruning: Removing Unnecessary Weights

The stage is code-native and interactive. Use it to test the explanation against the mechanism.

difficulty 3/5undergraduatecode-aligned
Demo Prediction Checkpoint

Manipulate one control and predict the visible change.

Commit to what Pruning: Removing Unnecessary Weights should make visible before reading the result.

After The First Pass

Turn the concept into an inspected object.

Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.

Mechanism Storyboard

See the idea move before the page explains it

Reduce parameter count by zeroing or removing weights. Unstructured sparsity needs sparse kernels for speed; structured pruning removes whole channels/heads to shrink dense tensor shapes.

Prediction open01 / Intuition
Editorial efficiency illustration of a dense weight grid being pruned into a smaller sparse structure.
Prediction lens

Start with the picture, metaphor, or geometric mechanism.

Commit first

Before reading further, choose the kind of change Pruning: Removing Unnecessary Weights should make visible.

Visual Inquiry

Make the image answer a mathematical question

Reduce parameter count by zeroing or removing weights. Unstructured sparsity needs sparse kernels for speed; structured pruning removes whole channels/heads to shrink dense tensor shapes.

4/4 stages readyLive demo connected
Prediction

Which visible object should carry the first intuition?

Commit first

Pick the cue that should make Pruning: Removing Unnecessary Weights easier to reason about before the page gives the answer.

Source Grounding

Canonical references for the mechanism on this page.

paper · 2015Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman CodingHan, Mao, and Dally

Grounds magnitude-threshold connection pruning, retraining, sparse storage, and sparse-kernel batch-1 speed/energy benchmarks in the Deep Compression pipeline.

Open source
paper · 2016Pruning Filters for Efficient ConvNetsHao Li, Asim Kadav, Igor Durdanovic, Hanan Samet, and Hans Peter Graf

Grounds structured/filter pruning as removing whole filters and feature maps, avoiding irregular sparse connectivity, and mapping to standard dense BLAS operations.

Open source

Claim Review

Reduce parameter count by zeroing or removing weights. Unstructured sparsity needs sparse kernels for speed; structured pruning removes whole channels/heads to shrink dense tensor shapes.

Status1 substantive review recorded

Claims without a substantive review badge still need exact source-support review.

Sources2 references

han-2015-deep-compression, li-2016-pruning-filters

Witnesses4 local objects

Use equation, code, and demo objects to check whether the source support is operational.

Substantively reviewedPruning can be taught as applying a sparsity mask, often with a magnitude threshold: unstructured zeros can compress storage but do not automatically speed dense kernels, while structured filter/channel removal changes tensor shape and can map to dense-kernel acceleration.Claim metadata: source checked

Han et al. prune small-weight connections below a threshold, retrain remaining sparse connections, store them as CSR/CSC, and benchmark sparse matrix-vector kernels. Li et al. show filter pruning removes whole filters/feature maps, avoids sparse connectivity, and works with dense BLAS. The page math/code/demo instantiate this contrast.

Sources: Deep Compression: Compressing Deep Neural Networks with Pruning, Trained Quantization and Huffman Coding, Pruning Filters for Efficient ConvNetsThis checks the pruning-mask and deployment-distinction lesson, not exact compression ratios, full retraining schedules, measured speedups, modern pruning methods, sparse-kernel performance on current hardware, or accuracy preservation guarantees.A bounded review summary is present; still check caveats and exact source scope.

Oracle PASS: Han supports thresholded unstructured connection pruning, masks, CSR/CSC sparse storage, and sparse-kernel benchmarking; Li supports filter/feature-map removal that avoids irregular sparsity and maps to smaller dense BLAS operations. Scope excludes exact ratios, schedules, modern hardware, universal speedups, and accuracy guarantees.

Reviewer: codex+oracle; reviewed 2026-05-07

Practice Loop

Try the idea before it explains itself

Reduce parameter count by zeroing or removing weights. Unstructured sparsity needs sparse kernels for speed; structured pruning removes whole channels/heads to shrink dense tensor shapes.

Readiness0/3 checks ready
Predict

Before touching the demo, predict one visible change that should happen in Pruning: Removing Unnecessary Weights.

Hint 1

Reveal when your model needs a nudge.

Hint 2

Reveal when your model needs a nudge.

Hint 3

Reveal when your model needs a nudge.

Object research drawerClose
ConceptPruning: Removing Unnecessary WeightsEfficiency

Research Room

Attach the question to an exact object

Pick the concept, equation, source, code witness, claim, misconception, or demo state before asking for help. The handoff stays grounded to that object.
Next local actionNo local draft saved yet

Open the draft below to save one note and next action in this browser.

conceptEfficiency

Pruning: Removing Unnecessary Weights

Anchored question

What is the smallest example that makes Pruning: Removing Unnecessary Weights click without losing the math?

Local action draftNo local draft saved yetExpand only when ready to capture one local next action
Local action draft

This draft stays locally in this browser for concept:efficiency/pruning.

No local draft saved.
Evidence to inspect
  • Source ids to inspect: han-2015-deep-compression, li-2016-pruning-filters
  • Definition, prerequisite, and contrast concept links
  • The equation or code witness that makes the concept operational
  • One demo state that shows the invariant instead of a slogan
What would resolve this
  • The learner can state the mechanism in their own words
  • The learner can name the prerequisite that would repair confusion
  • The learner can predict how the mechanism changes under one perturbation
Grounded AI handoff

I am working in Continuous Function's research reading room. Object: concept - Pruning: Removing Unnecessary Weights Object key: concept:efficiency/pruning Context: Efficiency Anchor id: concept/concept-notebook/efficiency/pruning Open question: What is the smallest example that makes Pruning: Removing Unnecessary Weights click without losing the math? Evidence to inspect: - Source ids to inspect: han-2015-deep-compression, li-2016-pruning-filters - Definition, prerequisite, and contrast concept links - The equation or code witness that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.

Open source object
concept/concept-notebook/efficiency/pruning concept:efficiency/pruning