你的Transformer其实是弹性的
研究论文 · 2026/10/15
扩大Transformer规模已产生具备广泛能力的模型,可部署于异构硬件和波动负载。然而,模型家族仅提供少数固定尺寸(如S、B、L),迫使用户根据硬件和延迟约束选择模型。这种刚性在查询负载变化时往往不是最优的。我们提出一种无需重新训练的方法,将预训练Transformer弹性化为单一模型,可在连续的计算预算中即时适应。我们的关键贡献是对功能单元排序问题的可微松弛:与先前工作优化每个MLP块或注意力头的单一重要性权重不同,我们在共同尺度上联合排序每个单独的MLP神经元和注意力头,通过在许多稀疏目标下同时最小化软剪枝下的模型损失。在27个视觉和文本Transformer编码器(22M到8B参数)上,我们的方法在高达60%稀疏度下实现平滑退化,并在深度剪枝下优于一次性基线。例如,将DINOv3 ViT-H+/16剪枝至50%稀疏度可移除427M参数,而ImageNet-1k线性探测准确率仅降低0.8%,无需权重校正或重新训练。在60%稀疏度下,剪枝后的AugReg ViT-B/16模型在A100 GPU上实现高达1.80倍的吞吐量和1.26倍的单查询延迟降低。弹性模型在几分钟内生成,构建时间随参数数量亚线性扩展。
该研究提出了一种无需重新训练即可使预训练Transformer适应多种计算预算的方法,解决了模型固定尺寸在异构硬件和波动负载下的刚性限制。其方法在广泛模型上验证有效,显著降低资源消耗且保持性能,具有很高的实用价值和效率提升潜力。
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.