Abstract
The method converts pre-trained transformers into elastic models that adapt continuously to varying computational budgets by jointly ranking and softly pruning individual neurons and attention heads across multiple sparsity targets without retraining.
Scaling up transformers has produced models with broad capabilities, deployed across heterogeneous hardware and fluctuating workloads. Yet, model families offer only a few fixed sizes (e.g., S, B, L), forcing users to commit to a model based on hardware and latency constraints. This rigidity is often suboptimal under varying query loads. We introduce a retraining-free method that elastifies pre-trained transformers into a single model that adapts on-the-fly across a continuum of computational budgets. Our key contribution is a differentiable relaxation of the functional unit-ranking problem: unlike prior work, which optimizes a single importance weight per MLP block or attention head, we rank every individual MLP neuron and attention head jointly, on a common scale, by minimizing the model's loss under soft pruning across many sparsity targets, all at once. Across 27 vision and text transformer encoders ranging from 22M to 8B parameters, our method yields smooth degradation up to 60% sparsity and outperforms one-shot baselines under deep pruning. For example, pruning DINOv3 ViT-H+/16 to 50% sparsity removes 427M parameters while reducing ImageNet-1k linear-probing accuracy by only 0.8%, without the need for weight correction or retraining. At 60% sparsity, a pruned AugReg ViT-B/16 model achieves up to 1.80times higher throughput and 1.26times lower single-query latency on an A100 GPU. Elastic models are produced in minutes, with construction time scaling sub-linearly with parameter count.
Community
Author here ๐ We learn one importance ranking over every MLP neuron and attention head of a pre-trained transformer, with frozen weights. Cut it anywhere and you get a smaller model, so one checkpoint serves any compute budget, with no retraining.
Across 27 vision and text encoders (22M to 8B parameters), it degrades smoothly up to 60% sparsity and reaches up to 1.80ร throughput on an A100.
๐ Interactive results: https://secretly-elastic.ashita.nl
๐ป Code: https://github.com/WalterSimoncini/secretly-elastic
Happy to answer questions!
Get this paper in your agent:
hf papers read 2610.20588 Don't have the latest CLI?
curl -LsSf https://hf.co/cli/install.sh | bash Models citing this paper 0
No model linking this paper
Datasets citing this paper 0
No dataset linking this paper
Spaces citing this paper 0
No Space linking this paper
Collections including this paper 0
No Collection including this paper