通过模块重要性采样,显著降低大模型训练内存占用。
MISA: Memory-Efficient LLMs Optimization with Module-wise Importance Sampling
- 将每层拆分为模块,按重要性加权采样激活
- 理论证明梯度方差更低,收敛速度达O(1/√K)
- 适合资源受限下高效训练大模型的研究者
大语言模型预训练和微调的高昂内存需求亟需高效优化算法。现有分层优化方法将每个Transformer块视为单一层,逐层优化并冻结其余层以节省优化器状态与激活值,但忽略层内模块的重要性差异,导致性能不佳。同时,分层采样内存节省有限,因至少需保持一整层活跃。为此,本文提出模块重要性采样(MISA),将每层细分为更小模块,并为各模块赋予权重得分。MISA采用加权随机采样机制激活模块,在理论上可降低梯度方差,优于分层采样。我们进一步在非凸与随机条件下建立了\\(\mathcal{O}(1/\sqrt{K})\\)的收敛率,其中$K$为块更新总数,并进行详细内存分析,证明其优于现有基线方法。在多种学习任务上的实验验证了MISA的有效性。源代码已开源于https://github.com/pkumelon/MISA。
原文摘要 · Abstract (English)
The substantial memory demands of pre-training and fine-tuning large language models (LLMs) require memory-efficient optimization algorithms. One promising approach is layer-wise optimization, which treats each transformer block as a single layer and optimizes it sequentially, while freezing the other layers to save optimizer states and activations. Although effective, these methods ignore the varying importance of the modules within each layer, leading to suboptimal performance. Moreover, layer-wise sampling provides only limited memory savings, as at least one full layer must remain active during optimization. To overcome these limitations, we propose Module-wise Importance SAmpling (MISA), a novel method that divides each layer into smaller modules and assigns importance scores to each module. MISA uses a weighted random sampling mechanism to activate modules, provably reducing gradient variance compared to layer-wise sampling. Additionally, we establish an \(\mathcal{O}(1/\sqrt{K})\) convergence rate under non-convex and stochastic conditions, where $K$ is the total number of block updates, and provide a detailed memory analysis showcasing MISA's superiority over existing baseline methods. Experiments on diverse learning tasks validate the effectiveness of MISA. Source code is available at https://github.com/pkumelon/MISA.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。