arXiv:2505.13430cs.LGcs.CL2025-05中稿 · ICLR被引 4

用零阶优化+量化实现4比特大模型单卡微调

Fine-tuning Quantized Neural Networks with Zeroth-order Optimization

  • 通过扰动量化尺度估算梯度,避免显存存储梯度和优化器状态
  • 相比16位全参数微调,内存减少超18倍,支持单24GB显卡跑Llama-2-13B
  • 适用于资源受限场景下的大模型高效微调,尤其适合部署端

随着大语言模型规模指数增长,GPU显存已成为下游任务微调的瓶颈。本文旨在通过统一框架最小化模型权重、梯度和优化器状态的显存占用。核心思想是采用零阶优化,通过前向传播时扰动权重来近似梯度方向,从而消除梯度与优化器状态的存储需求。为降低权重显存,采用量化(如bfloat16转int4)。但直接对量化权重使用零阶优化因离散权重与连续梯度间存在精度鸿沟而不可行。为此提出量化零阶优化(QZO):扰动连续量化尺度进行梯度估计,并引入方向导数裁剪稳定训练。QZO与标量及码本式后训练量化方法正交。相较于16位全参数微调,QZO使4比特大模型总显存降低超18倍,可在单张24GB GPU上完成Llama-2-13B的微调。

原文摘要 · Abstract (English)

As the size of large language models grows exponentially, GPU memory has become a bottleneck for adapting these models to downstream tasks. In this paper, we aim to push the limits of memory-efficient training by minimizing memory usage on model weights, gradients, and optimizer states, within a unified framework. Our idea is to eliminate both gradients and optimizer states using zeroth-order optimization, which approximates gradients by perturbing weights during forward passes to identify gradient directions. To minimize memory usage on weights, we employ model quantization, e.g., converting from bfloat16 to int4. However, directly applying zeroth-order optimization to quantized weights is infeasible due to the precision gap between discrete weights and continuous gradients, which would otherwise require de-quantization and re-quantization. To overcome this challenge, we propose Quantized Zeroth-order Optimization (QZO), a simple yet effective approach that perturbs the continuous quantization scale for gradient estimation and uses a directional derivative clipping method to stabilize training. QZO is orthogonal to both scalar-based and codebook-based post-training quantization methods. Compared to full-parameter fine-tuning in 16 bits, QZO can reduce the total memory cost by more than 18$\times$ for 4-bit LLMs, and enables fine-tuning Llama-2-13B within a single 24GB GPU.

模型量化零阶优化大模型微调显存优化

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