Scaling up Privacy-Preserving ML: A CKKS Implementation of Llama-2-7B

Fuente: arXiv
Saved in:
Bibliographic Details
Main Authors: Park, Jaiyoung, Park, Sejin, Park, Jai Hyun, Ahn, Jung Ho, Cheon, Jung Hee, Hanrot, Guillaume, Kim, Jung Woo, Park, Minje, Stehlé, Damien
Format: Preprint
Published: 2026
Subjects:
Online Access:
Tags: Add Tag
No Tags, Be the first to tag this record!
_version_ 1866912849811472384
author Park, Jaiyoung
Park, Sejin
Park, Jai Hyun
Ahn, Jung Ho
Cheon, Jung Hee
Hanrot, Guillaume
Kim, Jung Woo
Park, Minje
Stehlé, Damien
author_facet Park, Jaiyoung
Park, Sejin
Park, Jai Hyun
Ahn, Jung Ho
Cheon, Jung Hee
Hanrot, Guillaume
Kim, Jung Woo
Park, Minje
Stehlé, Damien
contents As large language models (LLMs) become ubiquitous, privacy concerns pertaining to inference inputs keep growing. In this context, fully homomorphic encryption (FHE) has emerged as a primary cryptographic solution to provide non-interactive confidential LLM inference. Existing solutions scale poorly with the input token length, and hence focus either on small models or larger models with a small number of input tokens. They also suffer from the existence of large outlier values. These values have a strong impact on the evaluation of non-linear layers, leading to large-degree polynomial approximation and thus heavy evaluation costs. We propose an FHE-based private LLM inference solution that allows thousands of input tokens with only a part of them being encrypted: this fits with a scenario where the context is benign and only part of the input is sensitive. To do so, we suggest an unbalanced chunked prefill framework that processes the private and public parts of the input tokens differently. Our framework contains plaintext-plaintext, plaintext-ciphertext and ciphertext-ciphertext computational components. We adopt different strategies and ingredients for each component. We also devise new homomorphic algorithms for specific matrix multiplication and polynomial evaluation tasks encountered during LLM inference. Furthermore, without retraining, we tailor the LLM inference algorithm to reduce the ranges of outlier values: we leverage machine learning strategies (token prepending and rotations) to mitigate the impact of the outliers on non-linear layers. Based on these ingredients, we describe a CKKS-based end-to-end implementation of Llama-2-7B private inference for up to 4096 input tokens, of which the last 128 are encrypted. On a cluster of 8~NVIDIA RTX-4090 GPUs, inference takes 85s for summarization and 33s for generation per output token.
format Preprint
id arxiv_https___arxiv_org_abs_2601_18511
institution arXiv
publishDate 2026
record_format arxiv
spellingShingle Scaling up Privacy-Preserving ML: A CKKS Implementation of Llama-2-7B
Park, Jaiyoung
Park, Sejin
Park, Jai Hyun
Ahn, Jung Ho
Cheon, Jung Hee
Hanrot, Guillaume
Kim, Jung Woo
Park, Minje
Stehlé, Damien
Cryptography and Security
As large language models (LLMs) become ubiquitous, privacy concerns pertaining to inference inputs keep growing. In this context, fully homomorphic encryption (FHE) has emerged as a primary cryptographic solution to provide non-interactive confidential LLM inference. Existing solutions scale poorly with the input token length, and hence focus either on small models or larger models with a small number of input tokens. They also suffer from the existence of large outlier values. These values have a strong impact on the evaluation of non-linear layers, leading to large-degree polynomial approximation and thus heavy evaluation costs. We propose an FHE-based private LLM inference solution that allows thousands of input tokens with only a part of them being encrypted: this fits with a scenario where the context is benign and only part of the input is sensitive. To do so, we suggest an unbalanced chunked prefill framework that processes the private and public parts of the input tokens differently. Our framework contains plaintext-plaintext, plaintext-ciphertext and ciphertext-ciphertext computational components. We adopt different strategies and ingredients for each component. We also devise new homomorphic algorithms for specific matrix multiplication and polynomial evaluation tasks encountered during LLM inference. Furthermore, without retraining, we tailor the LLM inference algorithm to reduce the ranges of outlier values: we leverage machine learning strategies (token prepending and rotations) to mitigate the impact of the outliers on non-linear layers. Based on these ingredients, we describe a CKKS-based end-to-end implementation of Llama-2-7B private inference for up to 4096 input tokens, of which the last 128 are encrypted. On a cluster of 8~NVIDIA RTX-4090 GPUs, inference takes 85s for summarization and 33s for generation per output token.
title Scaling up Privacy-Preserving ML: A CKKS Implementation of Llama-2-7B
topic Cryptography and Security
url https://arxiv.org/abs/2601.18511