SIGMA: Secure GPT Inference with Function Secret Sharing

Kanav Gupta, Neha Jawalkar, Ananta Mukherjee, Nishanth Chandran, Divya Gupta, Ashish Panwar, Rahul Sharma

Introduction

As "Prediction-as-a-Service" (PaaS) becomes a standard for deploying large language models, the tension between utility and privacy grows. Clients often need to process sensitive data, such as medical records or financial statements, while AI providers must protect their proprietary model weights and system prompts. Secure 2-Party Computation (2PC) provides a cryptographic framework for this, but standard protocols have historically struggled with the immense scale and complexity of modern Transformers.

SIGMA introduces a breakthrough in this field, representing the first end-to-end system for secure transformer inference based on Function Secret Sharing (FSS). It achieves a 12–19× speedup over previous state-of-the-art GPU-accelerated systems, enabling the secure inference of billion-parameter models like Llama2-13B in under 40 seconds.

The Challenge of Secure Transformer Inference

Existing 2PC systems face three primary bottlenecks when handling large-scale models:

  1. Communication Overhead: Standard secret-sharing protocols require frequent interactions between parties, which becomes a major bottleneck for models with billions of parameters.
  2. Non-linear Operations: Transformers rely heavily on functions like Softmax, GeLU, and LayerNorm. These are computationally expensive to evaluate securely compared to linear operations.
  3. Security-Efficiency Trade-offs: Many "fast" systems compromise security by using insecure shortcuts, such as local truncation, which can leak information.
Overview of Transformer architecture highlighting linear and non-linear operations targeted by SIGMA.

Methodology: Leveraging Function Secret Sharing

SIGMA addresses these challenges by shifting the heaviest cryptographic workloads to an offline "preprocessing" phase using FSS. In the online phase, parties evaluate local functions on masked values, significantly reducing real-time communication.

Key Innovations

  • Custom FSS Protocols: The researchers designed highly efficient protocols specifically for GeLU, SiLU, Softmax, and LayerNorm.
  • Faithful Truncation: A new protocol for "faithful truncation" was developed, offering up to a 30× efficiency gain over prior work while maintaining standard 2PC security guarantees.
  • GPU Optimization: SIGMA optimizes FSS kernels for GPUs, specifically managing the transfer of large cryptographic keys from CPU to GPU memory to avoid hardware bottlenecks.
  • SyTorch Frontend: A C++ frontend allows users to define models using PyTorch-like syntax, which is then compiled into optimized secure protocols.

Key Insights: Domain-Specific Approximations

A core insight of SIGMA is the use of domain-specific approximations for non-linearities. For instance, the GeLU activation function is nearly identical to the simpler ReLU function except in a small interval around zero.

The difference between GeLU and ReLU is concentrated in a small interval around zero, allowing for efficient approximation using small Look-Up Tables.

By recognizing this, the authors could use small Look-Up Tables (LUTs) of size $2^8$ instead of the massive $2^{50}$ tables suggested by prior general-purpose libraries. This drastically reduces the memory and communication requirements for evaluating these activations.

Performance and Results

SIGMA was evaluated on standard NLP tasks using models ranging from BERT-Tiny to Llama2-13B.

  • Speed and Scale: SIGMA is 12.2× to 19× faster than CrypTen. It successfully ran secure inference for Llama2-13B in 38 seconds and GPT2 in 1.5 seconds, avoiding the memory overflows that plague previous systems.
  • Efficiency: For smaller models, SIGMA reduces communication by 8.4× to 11.6× compared to CrypTen.
  • Accuracy: The system maintains the accuracy of standard 32-bit floating-point PyTorch models despite its optimizations.

Conclusion and Future Work

SIGMA demonstrates that secure, large-scale Transformer inference is feasible with the right combination of cryptographic protocols and hardware optimization. While currently focused on semi-honest adversaries, future work includes extending these protocols to malicious security and further reducing the data transfer costs associated with the offline preprocessing phase.

Summary updated

BibTeX
@article{gupta2024sigma,
  author = {Kanav Gupta and Neha Jawalkar and Ananta Mukherjee and Nishanth Chandran and Divya Gupta and Ashish Panwar and Rahul Sharma},
  title = {{SIGMA: Secure GPT Inference with Function Secret Sharing}},
  journal = {Proc. Priv. Enhancing Technol.},
  year = {2024},
  doi = {10.56553/popets-2024-0107},
}
Figure