We present LayerSkip, an end-to-end solution to speed-up inference of large language models (LLMs). First, during training we apply layer dropout, with low dropout rates for earlier layers and higher dropout rates for later layers, and an early exit loss where all transformer layers share the same exit. Second, during inference, we show that this training recipe increases the accuracy of early exit at earlier layers, without adding any auxiliary layers or modules to the model. Third, we present a novel self-speculative decoding solution where we exit at early layers and verify and correct with remaining layers of the model. Our proposed self-speculative decoding approach has less memory footprint than other speculative decoding approaches and benefits from shared compute and activations of the draft and verification stages. We run experiments on different Llama model sizes on different types of training: pretraining from scratch, continual pretraining, finetuning on specific data domain, and finetuning on specific task. We implement our inference solution and show speedups of up to 2.16x on summarization for CNN/DM documents, 1.82x on coding, and 2.0x on TOPv2 semantic parsing task.
翻译:我们提出LayerSkip,一种加速大型语言模型(LLMs)推理的端到端解决方案。首先,在训练阶段,我们对早期层应用低丢弃率、对后期层应用高丢弃率的层丢弃方法,并采用所有Transformer层共享同一退出点的早期退出损失函数。其次,在推理阶段,我们发现这种训练策略能提升早期层的退出准确性,且无需向模型添加任何辅助层或模块。第三,我们提出一种新颖的自推测解码方案:在早期层退出,并通过模型剩余层进行验证与修正。与其它推测解码方法相比,本方案具有更小的内存占用,且能共享草稿阶段与验证阶段的计算与激活值。我们基于不同Llama模型规模,在预训练从零开始、持续预训练、特定领域微调及特定任务微调等多种训练场景下进行实验。实验表明,本推理方案可实现:CNN/DM文档摘要任务2.16倍加速、代码生成任务1.82倍加速、TOPv2语义解析任务2.0倍加速。