Felid: A Flexible and Efficient Design for Transformer Fine-Tuning over Encrypted Data

Linru Zhang, Jun Jie Sim, Xiangning Wang, Jiahao Zhong, Kaiyu Zhou, Huanyi Ye, Yongsen Zheng, Lushan Song, Xiaojian Liang, Yingting Liu, Yujing Sun, Huaxiong Wang, Pu Duan, Kwok-Yan Lam

Imagine you want to fine-tune a state-of-the-art Large Language Model (LLM) on your company’s most sensitive data—medical records, legal contracts, or financial trade secrets. You’d probably want to do this in the cloud for the compute power, but sending that data in the clear is a non-starter.

Enter Fully Homomorphic Encryption (FHE), the "holy grail" of cryptography that lets you perform math on encrypted data without ever decrypting it. The catch? It’s historically been agonizingly slow. This paper introduces FELID, a framework that makes privacy-preserving Transformer fine-tuning up to 8x faster than previous methods, bringing us one step closer to practical, private AI.

TL;DR

FELID accelerates encrypted Transformer fine-tuning by rethinking how data is "packed" into ciphertexts and how we perform matrix math on those encrypted bits. By folding activation functions directly into the mandatory "noise-clearing" steps of encryption, it achieves a 30× reduction in expensive operations and an 8× overall speedup compared to the current state-of-the-art.

What Problem Does This Paper Address?

The industry currently leans on two main privacy-preserving techniques: Secure Multi-Party Computation (MPC) and FHE. MPC is fast but requires constant, low-latency back-and-forth communication between the client and the server—a nightmare for long training runs. FHE is "non-interactive" (you send the data once, the server works, and sends back the result), but it is computationally brutal.

While recent work has tried to make Transformers more "FHE-friendly" by changing the model architecture (like replacing Softmax with Gaussian kernels), the underlying bottleneck remains the ciphertext operations themselves. Specifically, "rotations" and "bootstrapping" (a process required to refresh the encryption when it gets too "noisy" from too much math) are incredibly expensive. FELID targets these low-level bottlenecks to make the math itself more efficient.

Methods

The authors introduce three major innovations to the FHE pipeline:

  1. Flexible Column-Wise Batch Packing: In FHE, you pack multiple numbers into a single "ciphertext" slot. Previous methods used row-wise packing, which requires expensive "internal rotations" to do basic math. FELID uses a column-wise strategy that supports variable batch sizes (from 4 to 64), ensuring that no "slots" in the encryption are wasted and matrix multiplication is naturally faster.

    Comparison between row packing and FELID's flexible interleaved column packing.
  2. Operation-Specific Matrix Algorithms: They designed new ways to handle the specific matrix multiplications found in Transformers (like those in Attention and LoRA layers). These algorithms drastically reduce the number of "key-switching" operations—the most expensive part of FHE math.

  3. Functional Bootstrapping: This is the "aha!" moment. In FHE, after a few multiplications, the data becomes too noisy to read, and you must perform a "bootstrapping" operation to refresh it. FELID uses functional bootstrapping to evaluate non-linear activation functions (like ReLU or GELU) during that refresh step. It’s essentially getting the activation evaluation for free while doing a task you had to do anyway.

Datasets

The researchers evaluated FELID on three key tasks from the GLUE (General Language Understanding Evaluation) benchmark:

  • MRPC (Microsoft Research Paraphrase Corpus)
  • RTE (Recognizing Textual Entailment)
  • STS-B (Semantic Textual Similarity Benchmark)

They used a 2-layer BERT-style backbone for these tests, comparing their encrypted results against standard "plaintext" models to ensure accuracy wasn't sacrificed for speed.

Key Insights and Ideas

  • The "Internal Rotation" Tax: Most people don't realize that simply adding up a row of encrypted numbers requires "rotating" the ciphertext multiple times. By switching to column-wise packing, FELID avoids this "tax" for many common Transformer operations.
  • Efficiency via Flexibility: Fixed batch sizes in FHE are a major source of waste. If your encryption scheme is hardcoded for a batch of 256 but you only have 16 samples, you're paying for 240 empty slots. FELID’s flexibility is a massive practical win for real-world workloads.
  • Math over Architecture: While others tried to fix the problem by changing the model, FELID fixes the math. This makes it compatible with existing FHE-friendly model designs while providing a massive performance boost.

Key Results

The numbers are impressive across the board:

  • 30× Reduction in ciphertext rotations and relinearizations (the "heavy lifting" of FHE).
  • 2.5× Reduction in bootstrapping invocations across the entire computation flow.
  • 8× Speedup: A 2-layer BERT model with a batch size of 16 was fine-tuned in 650 seconds, compared to 5,238 seconds for the previous state-of-the-art.
  • Accuracy: The model maintained competitive performance, showing that the approximations required for FHE (like using polynomial kernels instead of Softmax) have a minimal impact on final task accuracy.
Table 2: Comparisons with [28]. Numbers in the table are based on evaluating all kinds of matrix op- erations (CPMM, CCMM for LoRA, CCMM for kernel, CCMM for ×V , and CCMM in classification head) in the forward pass of a single BERT layer with kernel attention on a batch of inputs (batch size b). The concrete parameters are as follows: Xi ∈R128×768, i ∈[16], WQ, WK, WV ∈R768×768, A ∈R768×nLoRA, B ∈RnLoRA×768, Wc2 ∈R768×2. We have: number of heads H = 12, batch size b = 16, and nLoRA = 2, which are consistently used in both our experiments and those of [28].

Limitations and Future Work

Despite the 8x speedup, FHE is still significantly slower than training on unencrypted data. The experiments were conducted on high-end NVIDIA H200 GPUs; running this on consumer hardware is still out of reach.

Additionally, the study focused on a 2-layer BERT model. While the authors argue that the complexity scales linearly with the number of layers, fine-tuning massive 7B+ parameter models entirely in FHE remains a monumental challenge for the future. The authors suggest that further optimizing the "functional bootstrapping" step and exploring hybrid FHE-MPC approaches could be the next frontier.

Summary updated

Abstract

Fully Homomorphic Encryption (FHE) enables non-interactive, privacy-preserving transformer fine-tuning, protecting highly sensitive data as inputs to large language models. Prior work has predominantly pursued efficiency gains through architectural refinements, yet overall performance remains bounded by the substantial cost inherent in encrypted computation. To address these issues, we target the bottleneck at the ciphertext operation level. Concretely, we propose a novel packing strategy that supports batching over a flexible number of inputs, making it well-suited for fine-tuning workloads. In addition, we design operation-specific matrix evaluation algorithms that significantly reduce (i) the number of ciphertext rotations and relinearizations, and (ii) the number of bootstrapping invocations. Additionally, we exploit functional bootstrapping to fold the evaluation of element-wise activation functions directly into the bootstrapping step, thereby reducing overall computational complexity. As a result, our framework achieves a $30\times$ reduction in ciphertext rotations and relinearizations across all matrix operations, as well as a $2.5\times$ reduction in FHE bootstrapping invocations over the entire computation flow, compared to the latest state-of-the-art work. It is worth noting that our system completes fine-tuning of a 2-layer BERT-style model with a batch size of 16 in 650 seconds, achieving a $8\times$ speedup over the state-of-the-art work.
BibTeX
@inproceedings{zhang2026felid,
  author = {Linru Zhang and Jun Jie Sim and Xiangning Wang and Jiahao Zhong and Kaiyu Zhou and Huanyi Ye and Yongsen Zheng and Lushan Song and Xiaojian Liang and Yingting Liu and Yujing Sun and Huaxiong Wang and Pu Duan and Kwok-Yan Lam},
  title = {{Felid: A Flexible and Efficient Design for Transformer Fine-Tuning over Encrypted Data}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=yglphSefi0},
}
Figure