arXiv:2501.00692cs.LGcs.AI2025-01被引 1

解决大模型长上下文训练内存瓶颈,实现百万级上下文高效训练

Adjoint sharding for very long context training of state space models

  • 用伴随方法分片计算梯度,大幅降低训练内存占用
  • 1.27B模型在100万上下文长度下训练,内存减少3倍,上下文提升至超10万token
  • 适合需要长文本微调的任务,如事实提取与摘要

尽管进展迅速,但在超长上下文下高效训练大语言模型仍具挑战。现有方法多在训练时使用短上下文(训练最大仅数千词元),推理时才处理长上下文(推理可达100万词元)。而直接在长上下文上训练受限于GPU内存和极长训练时间。许多真实应用需在特定任务中进行长上下文的训练/微调,例如结合原始参考信息进行事实提取、摘要或校正。本文提出伴随分片(adjoint sharding)技术,通过分片反向传播中的梯度计算,将内存需求降低数个数量级,使长上下文训练变得可行。该方法基于伴随法,可计算等效梯度。进一步提出截断伴随分片以提速并保持性能。还提供了分布式与并行版本。实验证明,该算法在100万词元上下文长度下,对1.27B参数模型内存减少达3倍;在5个AWS P4实例上,最大训练上下文从3.5万提升至超过10万词元。

原文摘要 · Abstract (English)

Despite very fast progress, efficiently training large language models (LLMs) in very long contexts remains challenging. Existing methods fall back to training LLMs with short contexts (a maximum of a few thousands tokens in training) and use inference time techniques when evaluating on long contexts (above 1M tokens context window at inference). As opposed to long-context-inference, training on very long context input prompts is quickly limited by GPU memory availability and by the prohibitively long training times it requires on state-of-the-art hardware. Meanwhile, many real-life applications require not only inference but also training/fine-tuning with long context on specific tasks. Such applications include, for example, augmenting the context with various sources of raw reference information for fact extraction, fact summarization, or fact reconciliation tasks. We propose adjoint sharding, a novel technique that comprises sharding gradient calculation during training to reduce memory requirements by orders of magnitude, making training on very long context computationally tractable. Adjoint sharding is based on the adjoint method and computes equivalent gradients to backpropagation. We also propose truncated adjoint sharding to speed up the algorithm while maintaining performance. We provide a distributed version, and a paralleled version of adjoint sharding to further speed up training. Empirical results show the proposed adjoint sharding algorithm reduces memory usage by up to 3X with a 1.27B parameter large language model on 1M context length training. This allows to increase the maximum context length during training or fine-tuning of a 1.27B parameter model from 35K tokens to above 100K tokens on a training infrastructure composed of five AWS P4 instances.

长上下文模型训练内存优化状态空间模型

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。