[论文解读] LLM in a flash: Efficient Large Language Model Inference with Limited Memory
本文将 LLM 的权重存储在闪存中,并使用硬件感知的技术(窗口化和行列打包)按需加载,使推理可用于大于 DRAM 的模型,相较于朴素加载实现了显著加速。
Large language models (LLMs) are central to modern natural language processing, delivering exceptional performance in various tasks. However, their substantial computational and memory requirements present challenges, especially for devices with limited DRAM capacity. This paper tackles the challenge of efficiently running LLMs that exceed the available DRAM capacity by storing the model parameters in flash memory, but bringing them on demand to DRAM. Our method involves constructing an inference cost model that takes into account the characteristics of flash memory, guiding us to optimize in two critical areas: reducing the volume of data transferred from flash and reading data in larger, more contiguous chunks. Within this hardware-informed framework, we introduce two principal techniques. First, "windowing" strategically reduces data transfer by reusing previously activated neurons, and second, "row-column bundling", tailored to the sequential data access strengths of flash memory, increases the size of data chunks read from flash memory. These methods collectively enable running models up to twice the size of the available DRAM, with a 4-5x and 20-25x increase in inference speed compared to naive loading approaches in CPU and GPU, respectively. Our integration of sparsity awareness, context-adaptive loading, and a hardware-oriented design paves the way for effective inference of LLMs on devices with limited memory.
研究动机与目标
- 通过将参数存储在闪存中并在推理过程中按需加载,激励运行超出可用 DRAM 的 LLM。
- 开发一个受硬件影响的成本模型,考虑闪存和 DRAM 的特性以指导数据传输。
- 提出降低数据传输、提升闪存吞吐量的技术,以实现设备端更大规模推理。
- 证明稀疏性和内存管理策略能显著减少 DRAM 占用并加速推理。
提出的方法
- 构建一个将闪存、DRAM 和计算硬件特性纳入的推理成本模型。
- 引入窗口化以复用过去 token 的权重并减少 I/O 请求。
- 引入行列打包,通过成对相关的行/列从闪存中读取更大的一致块。
- 利用前馈网络的稀疏性和一个低秩预测器,仅加载非零或可能活跃的权重。
- 实现静态 DRAM 预分配和滑动窗口神经元数据管理方案以最小化内存重新分配。
- 在 CPU(DRAM+闪存)和 GPU 设置上使用 OPT 6.7B 和经过稀疏化的 Falcon 7B 进行评估,并与完整加载基线进行比较。

实验结果
研究问题
- RQ1闪存按需加载是否能支持大于可用 DRAM 的模型的 LLM 推理?
- RQ2硬件感知的数据传输策略(窗口化和打包)如何影响闪存驻留权重的延迟和吞吐量?
- RQ3稀疏性预测在不损害零-shot 任务准确性的前提下,在多大程度上能减少数据传输?
- RQ4在具有限制 DRAM 的边缘式硬件上运行 7B–6.7B 规模模型时,实际的延迟和内存占用权衡是什么?
- RQ5在类似内存约束下,这些方法与现有基线/灵活卸载策略(例如 FlexGen)相比如何?
主要发现
- 模型大小可达可用 DRAM 的两倍时,可以通过从闪存按需加载权重来运行。
- 在 CPU 设置中,相较于朴素加载,提速 4–5 倍;在 GPU 设置中,提速 20–25 倍。
- 窗口化将新数据加载量降低到大约 FFN 神经元的 2.4%(窗口为 5-token),从而节省 DRAM 带宽。
- 行列打包使读取块大小翻倍并通过读取更大连续块来提升闪存吞吐量。
- 低秩预测器和稀疏感知加载在保持零-shot 任务准确性的同时显著减少数据传输。
- 与完全重新加载基线相比,所提出的方法显著降低 I/O 延迟(例如,在某些配置下从约 2330 ms 降至每个 token ~87 ms)。

阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。