[论文解读] PUMA: Secure Inference of LLaMA-7B in Five Minutes
Puma 通过引入高效的 GeLU/softmax 近似以及端到端的安全嵌入和 LayerNorm,实现在不重新训练的情况下,对 LLaMA-7B 的安全 MPC 推理,约每个标记 5 分钟,并达到与明文相同的准确度。
With ChatGPT as a representative, tons of companies have began to provide services based on large Transformers models. However, using such a service inevitably leak users' prompts to the model provider. Previous studies have studied secure inference for Transformer models using secure multiparty computation (MPC), where model parameters and clients' prompts are kept secret. Despite this, these frameworks are still limited in terms of model performance, efficiency, and deployment. To address these limitations, we propose framework PUMA to enable fast and secure Transformer model inference. Our framework designs high quality approximations for expensive functions such as GeLU and softmax, and significantly reduce the cost of secure inference while preserving the model performance. Additionally, we design secure Embedding and LayerNorm procedures that faithfully implement the desired functionality without undermining the Transformer architecture. PUMA is about $2 imes$ faster than the state-of-the-art framework MPCFORMER(ICLR 2023) and has similar accuracy as plaintext models without fine-tuning (which the previous works failed to achieve). PUMA can even evaluate LLaMA-7B in around 5 minutes to generate 1 token. To our best knowledge, this is the first time that a model with such a parameter size is able to be evaluated under MPC. PUMA has been open-sourced in the Github repository of SecretFlow-SPU.
研究动机与目标
- 在不重新训练的情况下,推动对大型 Transformer 模型的隐私保护推理。
- 为 Transformer 中的非线性层开发快速、准确的基于 MPC 的协议。
- 提供与明文 Transformer 工作流对齐的端到端安全嵌入和 LayerNorm。
- 展示对大型模型(LLaMA-7B)的可扩展性,以及与常见来源的预训练模型的兼容性。
提出的方法
- 设计针对 MPC 效率量身定做的 GeLU 和 softmax 的新多项式近似。
- 实现与明文 Transformer 架构兼容的端到端安全嵌入和 LayerNorm。
- 使用 2-out-of-3 复制的秘密分享和成熟的 MPC 基元来实现线性和非线性运算。
- 通过负指数泰勒展开式以及减少除法来优化 softmax,以降低通信和计算开销。
- 在不重新训练的前提下,安全加载并执行预训练 Transformer 权重。
- 提供序列化调整的基础设施,以处理大模型的大规模秘密共享结构。
实验结果
研究问题
- RQ1在不重新训练的情况下,安全的基于 MPC 的推理是否能在大型 Transformer 模型上达到与明文相同的精度?
- RQ2哪些近似和协议设计能为 Transformer 的非线性组件(GeLU、softmax、LayerNorm、Embedding)带来实际可行的安全推理加速?
- RQ3在不改变明文模型工作流的前提下,端到端安全的 Embedding 和 LayerNorm 是否可行?
- RQ4在 MPC 下,Puma 相较于先前工作(MPCFormer)在非常大模型(如 LLaMA-7B)上的扩展能力如何?
主要发现
- Puma 在准确度方面达到与明文模型相近的水平,差异在小幅范围内(在 GLUE 任务上不超过 0.011,在 GPT-2 变体上的困惑度不超过 0.02)。
- Puma 的速度大约是 MPCFormer 的两倍,同时在评估的模型和任务中提供相似或更高的准确性。
- 在 MPC 下,安全的 LLaMA-7B 推理在每个标记五分钟内完成,并对输入/输出的成本进行了测量。
- 端到端安全嵌入和 LayerNorm 使得在不重新训练的情况下加载预训练 Transformer 权重成为可能,保持与明文模型的兼容性。
- Puma 在更大模型上的可扩展性更有利,在报告的实验中对 GPT-2 系列模型获得了更大的相对加速。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。