arXiv:2410.10553cs.LGcs.AI2024-10

解决大模型推理中层归一化溢出问题,静态缩放提升稳定性

SLaNC: Static LayerNorm Calibration

  • 基于前级线性层权重预计算缩放因子,避免运行时开销
  • 确保层归一化计算不发生溢出或下溢,支持多硬件部署
  • 适合追求高效低精度推理的模型部署开发者

随着大语言模型参数量突破千亿级别,对专用硬件加速器的压力持续增大,推动了加速器创新设计的快速发展。为在计算与存储受限条件下高效处理大模型,量化技术成为主流方案,但低精度量化带来的数值范围受限问题仍带来挑战。尤其在硬件上运行流行的Transformer模型时,层归一化(LayerNorm)的方差累积需要远超硬件支持的动态范围,易引发溢出或下溢。本文提出一种名为SLaNC的静态层归一化校准方法,通过分析前级线性层的静态权重,预先计算输入缩放因子,在推理阶段无需额外计算即可保证数值稳定性。该方法无运行时延迟,理论和数值实验均验证其在多种硬件架构上实现平滑、准确且资源高效的推理。

原文摘要 · Abstract (English)

The ever increasing sizes of Large Language Models (LLMs) beyond hundreds of billions of parameters have generated enormous pressure on the manufacturers of dedicated hardware accelerators and made the innovative design of the latter one of the most rapidly expanding fields of the AI industry. Various approaches have been explored to enable efficient and accurate processing of LLMs on the available accelerators given their computational and storage limitations. Among these, various quantization techniques have become the main focus of the community as a means of reducing the compute, communication and storage requirements. Quantization to lower precision formats naturally poses a number of challenges caused by the limited range of the available value representations. When it comes to processing the popular Transformer models on hardware, one of the main issues becomes calculation of the LayerNorm simply because accumulation of the variance requires a much wider dynamic range than the hardware enables. In this article, we address this matter and propose a computationally-efficient scaling technique that can be easily applied to Transformer models during inference. Our method suggests a straightforward way of scaling the LayerNorm inputs based on the static weights of the immediately preceding linear layers. The scaling factors are computed offline, based solely on the linear layer weights, hence no latency or computational overhead is added during inference. Most importantly, our technique ensures that no numerical issues such as overflow or underflow could happen during the compute. This approach offers smooth, accurate and resource-effective inference across a wide range of hardware architectures. The article provides theoretical justification as well as supporting numerical simulations.

层归一化量化推理硬件优化

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