FastQuery: Communication-efficient Embedding Table Query for Private LLM Inference

Chenqi Lin, Tianshi Xu, Zebin Yang, Runsheng Wang, Ru Huang, Meng Li

Abstract

With the fast evolution of large language models (LLMs), privacy concerns with user queries arise as they may contain sensitive information. Private inference based on homomorphic encryption (HE) has been proposed to protect user query privacy. However, a private embedding table query has to be formulated as a HE-based matrix-vector multiplication problem and suffers from enormous computation and communication overhead. We observe the overhead mainly comes from the neglect of 1) the one-hot nature of user queries and 2) the robustness of the embedding table to low bit-width quantization noise. Hence, in this paper, we propose a private embedding table query optimization framework, dubbed FastQuery. FastQuery features a communication-aware embedding table quantization algorithm and a one-hot-aware dense packing algorithm to simultaneously reduce both the computation and communication costs. Compared to prior-art HE-based frameworks, e.g., Cheetah, Iron, and Bumblebee, FastQuery achieves more than $4.3\times$, $2.7\times$, $1.3\times$ latency reduction, respectively and more than $75.7\times$, $60.2\times$, $20.2\times$ communication reduction, respectively, on both LLAMA-7B and LLAMA-30B.

Introduction

When users interact with cloud-based Large Language Models (LLMs), their prompts often contain sensitive personal data. To mitigate privacy risks, researchers employ Homomorphic Encryption (HE) and Secure Two-Party Computation (2PC), which allow models to process encrypted data without revealing the raw input to the service provider.

However, a significant bottleneck remains in the embedding table query. In a standard setting, this is a simple lookup; in a private setting, the server must perform a massive matrix-vector multiplication across the entire vocabulary (often 32,000+ tokens) to hide which specific token the user is querying. FastQuery addresses this by leveraging the unique "one-hot" nature of these queries and the inherent robustness of embedding tables to low-precision quantization.

Methodology

FastQuery introduces a co-optimization strategy that bridges cryptographic protocol design with model quantization techniques.

1. One-Hot Aware Protocol

Traditional HE-based matrix multiplication assumes dense input vectors. FastQuery recognizes that a query is a "one-hot" vector, meaning only one token is active at a time. By moving the embedding query to the online phase, the system can drastically reduce the "accumulation bit-width"—the number of bits required to store multiplication results—since it effectively performs a row selection rather than a full summation of products.

2. Low Bit-Width Element Packing

HE ciphertexts typically require a minimum plaintext bit-width (around 13 bits) to ensure successful decryption. However, individual embedding values do not require such high precision. FastQuery exploits this "extra" space by packing multiple low-bit channels (e.g., one 4-bit and two 3-bit values) into a single 13-bit coefficient. This allows the system to process three times as much data per communication round, effectively tripling the throughput of the encrypted channel.

Figure 3: FastQuery's packing mechanism, which compresses multiple low-bit weights into a single 13-bit coefficient to maximize HE ciphertext efficiency.

3. Channel-Wise Mixed-Precision Quantization

Not all embedding channels contribute equally to model performance. FastQuery identifies "salient" channels—those with higher importance based on mean absolute values—and assigns them 4-bit precision, while less critical channels use 3-bit precision. This mixed-precision approach, combined with data-free fine-tuning, allows the model to maintain accuracy despite heavy quantization.

Experimental Results

The framework was evaluated using the LLaMA model family (7B, 13B, and 30B) on the WikiText-103 and C4 benchmarks.

Latency and Communication Gains

FastQuery demonstrates substantial improvements over existing state-of-the-art frameworks. On LLaMA-7B, it achieved a 75.7x reduction in communication compared to Cheetah and a 20.2x reduction compared to Bumblebee. Latency was similarly improved, with speedups ranging from 1.3x to 4.5x across different baselines.

Figure 1: Latency comparison showing that FastQuery significantly reduces the time required for private embedding queries compared to previous 2PC frameworks like Iron.

Accuracy Preservation

Despite the aggressive quantization, FastQuery maintains near-original model performance. For instance, LLaMA-13B on WikiText-103 achieved a perplexity of 7.317, which is remarkably close to the full-precision (FP16) baseline of 7.313. Furthermore, the reduced communication footprint makes FastQuery highly resilient to low-bandwidth network conditions where traditional methods fail.

Conclusion

FastQuery provides a path toward practical private LLM inference by specifically targeting the embedding layer bottleneck. By co-optimizing quantization and cryptographic packing, it achieves order-of-magnitude improvements in communication efficiency. Future research may extend these techniques to other sparse operations, such as Mixture of Experts (MoE) layers, to further enhance the scalability of private AI.

Summary updated

BibTeX
@inproceedings{lin2024fastquery,
  author = {Chenqi Lin and Tianshi Xu and Zebin Yang and Runsheng Wang and Ru Huang and Meng Li},
  title = {{FastQuery: Communication-efficient Embedding Table Query for Private LLM Inference}},
  booktitle = {DAC},
  year = {2024},
  url = {https://openreview.net/forum?id=dvZ51FFj4Z},
}
Figure