Towards Encrypted Large Language Models with FHE
A single attention head of GPT2's first multi-head attention layer can run on encrypted data using TFHE via Zama's Concrete-Python and Concrete-ML, with the rest of the model executing in plaintext on the client. Weights and activations are post-training quantized to integers, nonlinearities become Programmable Bootstrapping table lookups, and the Hugging Face transformers forward pass is overridden with a quantized SingleHeadAttention module. Four-bit quantization keeps about 96% of original top-k accuracy on roughly 80 sentences, and the compiled circuit needs 8-bit width. A 6-token sequence costs 11,622 PBS operations, which takes minutes on CPU; the authors expect future FHE ASICs to bring that under 100 ms.
Related posts
- Running Privacy-Preserving Inferences on Hugging Face Endpoints
Hugging Face mediumAdeptZama's Concrete ML models, compiled for Fully Homomorphic Encryption (FHE), can be deployed as Hugging Face Inference Endpoints using custom inference handlers. Clients quantize and encrypt inputs locally, upload FHE evaluation keys in chunks (about 70 MB), and receive encrypted predictions that only they can decrypt. The handler exposes save_key, append_key and inference methods. Keys live in endpoint RAM, so they are lost on restart and not shared across replicas, and machines top out at 8 vCPUs. Measured latencies range from 0.4 s for logistic regression to 24 s for a CNN on MNIST.
- Sentiment Analysis on Encrypted Data with Homomorphic Encryption
Hugging Face mediumAdeptSentiment classification can run on encrypted text by computing a transformer (RoBERTa) hidden representation on the client, then running a quantized XGBoost classifier under fully homomorphic encryption with Concrete-ML. On the Twitter airline sentiment dataset the transformer-embedding + XGBoost model reaches 85% accuracy (above the transformer alone at 80%), and FHE predictions match clear-text probabilities exactly. Compilation takes about 9 seconds and FHE inference about 4.4 seconds per example on a 16-core CPU. Deployment uses Concrete-ML's FHEModelDev API to export client/server artifacts, demonstrated in a Hugging Face Space with a Gradio client and a FastAPI server.
- Making LLMs lighter with AutoGPTQ and transformers
Hugging Face mediumAdeptAutoGPTQ is now integrated into Hugging Face Transformers (via Optimum), letting users quantize and run LLMs at 8, 4, 3 or 2 bits with the GPTQ post-training method. GPTQ needs a calibration dataset and quantizes only the weights: int4 weights are dequantized on the fly in a fused kernel while compute stays in fp16. That gives nearly 4x memory savings with negligible accuracy loss at 4-bit. On an A100 at batch size 1, Llama-2-7B with the exllama kernel dropped peak memory from about 29 GB to 10.5 GB with slightly better per-token latency than fp16. Text-Generation-Inference can now serve a 70B model on a single 80GB GPU and PEFT adapters can be fine-tuned on top, but the kernels slow down at larger batch sizes and W4A8 or Triton kernels remain open work.
- Intel and Hugging Face Partner to Democratize Machine Learning Hardware Acceleration
Hugging Face mediumAdeptIntel has joined Hugging Face's Hardware Partner Program, and the two are collaborating on Optimum Intel, an open-source library built on Intel Neural Compressor that applies quantization, pruning and distillation to Transformer models on Xeon CPUs. A worked example applies post-training dynamic quantization to a DistilBERT review classifier with a 5% tolerable accuracy loss and up to 10 tuning trials. The run converts all 38 Linear and 2 Embedding operators to INT8, dropping accuracy from 0.574 to 0.546 while making evaluation 1.34x faster.
- Smaller is better: Q8-Chat, an efficient generative AI experience on Xeon
Hugging Face easyNoviceSmoothQuant enables accurate 8-bit (INT8) post-training quantization of LLMs by mathematically shifting activation outliers into the weights, which makes Transformer layers quantization-friendly. Intel applied it to OPT, LLaMA, Alpaca, Vicuna, BloomZ and MPT-7B-chat models, roughly halving model size. On many LM Evaluation Harness tasks the quantized models matched or slightly improved accuracy, and most remaining tasks degraded only marginally. Running on a single 32-core Sapphire Rapids Xeon socket at batch size 1, the quantized models deliver low per-token latency, demonstrated in the Q8-Chat Space, with Optimum Intel integration via Intel Neural Compressor planned.