Install any skill in seconds. Free to start, no credit card required.
Get Started Free →mkurman/model-pruning
Structured and unstructured model pruning: weight pruning, attention head pruning, layer removal, and neural architecture search for efficient LLMs.
Passed 17 of 22 test cases with the skill, and 14 of 22 without it.
and 1 more in the full report
4 fixed13 passed either way4 still failing1 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 4 test cases the skill fixed. Same model, same prompt, with and without the skill.
What compression factor range can be achieved through structured layer pruning in Transformer models?
| Checked | Without skill | With skill |
|---|---|---|
| The response specifies a layer pruning compression range of 1.5-5x. | Missed | Passed |
The instructions your model reads when the skill loads.
Pruning removes redundant parameters from neural networks. Structured pruning removes entire heads/layers (hardware-friendly), while unstructured pruning sets individual weights to zero (higher compression, needs sparse hardware support).
| Type | What's removed | Hardware Support | Compression |
|---|---|---|---|
| Unstructured (N:M sparsity) | Individual weights | NVIDIA 2:4 sparse cores | 2x (2:4) |
| Structured — Head pruning | Attention heads | Any GPU | 1.5-3x |
| Structured — Layer pruning | Transformer layers | Any GPU | 1.5-5x |
| Structured — Neuron pruning | FFN neurons | Any GPU | 1.5-2x |
from transformers import AutoModelForCausalLM
import torch
model = AutoModelForCausalLM.from_pretrained("Qwen/Qwen2.5-1.5B-Instruct")
# Apply SparseGPT (one-shot, no training needed)
from sparsegpt import SparseGPT
sparsifier = SparseGPT(model)
sparsifier.compress(sparsity=0.5) # 50% weight sparsity
# Or use NVIDIA 2:4 sparsity
for name, param in model.named_parameters():
if param.dim() >= 2:
param.data = torch.nn.utils.parametrizations.prune_2in4(param.data)
# Layer removal example
def prune_layers(model, layers_to_keep):
model.model.layers = model.model.layers[:layers_to_keep]
model.config.num_hidden_layers = layers_to_keep
return model
test cases passed, vs 14 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.