MeBP:内存高效反向传播,精确 BP 压进 1 GB

本页是 GPU 路线的第一个里程碑(见 端侧训练):MeBP [2] (EMNLP 2025 Industry,Apple)证明 精确 backpropagation 不需要 ZO 也能塞进手机——0.5B–4B 的 LLM 在 iPhone 上用不到 1 GB 训练内存完成 LoRA 微调。

1. 问题:LoRA 省参数,不省 activation

LoRA [1] 只训练低秩增量:

W=W+BA,BRd×r, ARr×k, rd W' = W + BA, \qquad B \in \mathbb{R}^{d \times r},\ A \in \mathbb{R}^{r \times k},\ r \ll d

式 1|LoRA:可训练参数只有 B,AB,A,backbone 权重 WW 冻结。

但 backward 时:

  • L/B\partial L/\partial B 需要 LoRA 中间结果 h=xAh = xA
  • 更致命的是,梯度要穿过整个 backbone,每一层的 activation 仍须保存。 朴素 BP 的内存是 O(L×I)O(L \times I)LL 层、每层中间结果总量 II), 远超推理——这就是"训练比推理贵得多"的根源。

另一条路 ZO [3] 内存很低,但收敛要 10–100× 步数,且精度更差。

2. 方法:逐层重算,计算换内存

MeBP 的核心思想:

不保存整个模型的 activation:只存各层输出,backward 时对当前层 重新 forward 一遍,重建层内中间激活再求导。

  • 内存从 O(L×I)O(L \times I) 降到 O(L×O+Ifw)O(L \times O + I_{fw})OO 为各层输出大小,IfwI_{fw} 为框架管理的临时量);
  • 提供内存-计算时间的灵活权衡(多存一些换少算一些,按设备情况调);
  • 梯度是数学上精确的 BP 梯度,没有近似。

实现基于 MLX:非 LoRA 参数用 4-bit 对称 INT4 量化 (QLoRA 风格 [2]),LoRA 参数保持高精度。代码开源: apple/ml-mebp

3. 实测:iPhone 15 Pro Max

  • 0.5B–4B 多个 LLM 的 LoRA 微调,训练内存 低于 1 GB
  • 相比 ZO 基线:收敛快得多(ZO 要 10–100× 步数 [3]),最终效果也更好。
💡 意义

MeBP 把"精确 BP 在手机上不可行"变成了伪命题。剩下的内存余量 由 MeSP 进一步压缩,速度瓶颈则交给 FBLayout

参考文献

[1] HU E J, SHEN Y, WALLIS P, et al. LoRA: low-rank adaptation of large language models[C]//International Conference on Learning Representations (ICLR). 2022. https://arxiv.org/abs/2106.09685

[2] SONG C, TANG X. Memory-efficient backpropagation for fine-tuning LLMs on resource-constrained mobile devices[C]//Proceedings of the 2025 Conference on Empirical Methods in Natural Language Processing: Industry Track (EMNLP). 2025. https://aclanthology.org/2025.emnlp-industry.52/

[3] MALLADI S, LYU K, PANIGRAHI A, et al. Fine-tuning language models with just forward passes[C]//Advances in Neural Information Processing Systems (NeurIPS). 2023. https://arxiv.org/abs/2305.17333


© 2026 Yang Huan · yanghuan9812@qq.com

results matching ""

    No results matching ""