FELID fine-tunes a 2-layer BERT on ciphertext in 650s, 8× faster

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

NeurIPS 2026 (Oral)

cs.CR, cs.AI

2026-11-20

FELID redesigns ciphertext packing and matrix evaluation, cutting 2-layer BERT fine-tuning at batch 16 from 5238s to 650s (8×).

What problem this solves

Fine-tuning on private text cannot send plaintext to the cloud. Multiparty computation can run the job, but the client has to stay online the whole time. Fully homomorphic encryption (FHE) lets the server compute the forward pass, the loss, and the weight update on ciphertext, so the client only decrypts. The arithmetic is expensive enough that most FHE work on Transformers never leaves inference.

Rho et al. (ICLR 2025) swapped softmax for a Gaussian kernel and trained only a LoRA update, which makes the network easier to evaluate under encryption. Matrix evaluation and bootstrapping still take about 70% to 85% of their runtime. FELID keeps that network and reworks packing and matrix evaluation.

Method

The scheme is CKKS, with 2^15 slots, polynomial degree 2^16, 128-bit security, and 12 multiplicative levels after bootstrapping. Rho et al. store one sample in each ciphertext, row by row, and imitate a batch by putting one sample on each of eight GPUs. NEXUS locks the batch size at 32. MOAI and ARION lock it at 256. At batch 16 those fixed layouts can leave up to about 50% and 93% of slots empty.

FELID interleaves one column from every sample in the batch into the same ciphertext. The batch size can be anything from 4 to 64. Multiplying encrypted activations by a plaintext weight, Enc(X)W, then needs no rotation inside a row. That ciphertext-plaintext product spends 1 multiplicative level against 3, and at batch 16 the attention block uses about 213× fewer rotations. LoRA is computed as (XA)B, so the low-rank factors are not multiplied into a full matrix first. Key-switches drop 21×, levels go from 3 to 2, and the rank in the experiments is 2.

Kernel attention needs squared distances between rows, not a QK product. Reading the columns as diagonals cuts that depth from 7 to 3 and opens the door to double BSGS, which takes rotations from linear in sequence length down to a square root. The kernel matrix alone uses about 1.16× more key-switches. Together with the multiply by V, the two steps use 1.4× fewer, at 6 levels against 12. Maps such as exp, GELU, and Tanh run inside functional bootstrapping, so the refresh applies the activation. The client encrypts embeddings locally. The server follows the protocol and may still try to infer the private data.

Results

Rho et al. are reimplemented in PhantomFHE on the same H200. Their paper used the closed HEaaN library and an RTX 4090. The model is a 2-layer BERT, hidden size 768, 12 heads, sequence length 128, batch 16. Key-switches in the forward pass of one layer:

OpFELIDRho et al.Levels
Ciphertext-plaintext4801024801 / 3
LoRA10222082 / 3
Kernel matrix23448201603 / 7
Multiply by V7512234243 / 5

The two classification-head multiplies use 1.4× and 17.4× fewer key-switches. Across the full two-layer fine-tuning flow, rotations and relinearizations fall by up to 30×, and total multiplicative depth is about halved. Bootstrapping calls go from 2300 to 919, and bootstrapping time from 1094s to 407s.

One batch takes 650.6s against 5238s, about 8×, or 40.66s against 327.38s per example. The forward matrix block falls from 1429s to 67.79s. Feed-forward activations take 4.02s once they sit inside functional bootstrapping, against 17.4s for a separate polynomial plus a refresh. In single-threaded microbenchmarks, ciphertext-plaintext multiplies are 32× to 63× faster.

MRPC, RTE, and STS-B are each trained for 5 epochs. Ciphertext LoRA averages 0.7456 for FELID's Gaussian kernel, 0.7379 for Rho et al., and 0.7356 for the Epanechnikov kernel. Plaintext full fine-tuning averages 0.7542 with softmax, 0.7582 with Rho's Gaussian kernel, 0.7539 with FELID's, and 0.7595 with Epanechnikov. FELID's Gaussian STS-B moves from 0.8184 in plaintext LoRA to 0.8155 in ciphertext.

Why it matters

The gain comes from column packing, matrix algorithms written per operator, and activations folded into bootstrapping. The network is still Rho et al.'s kernel attention plus LoRA. At two layers, sequence length 128, and batch 16, one encrypted update is about 11 minutes on a single H200. A cut of up to 30× in rotations and relinearizations puts the cost on how values sit inside ciphertexts.

BERT-base has 12 layers, and this paper does not time that model. A generative LLM is further away.

Limitations

The 650 seconds are one batch, not a finished run on a full training set. Flexible batches are described from 4 to 64, but the end-to-end numbers are only for 16. Batch 64 appears in matrix microbenchmarks, not in the full loop.

Models labeled FELID in the accuracy table went through continued pre-training and distillation, so they are not the same training pipeline as the published Rho et al. numbers. Epanechnikov STS-B falls from 0.8274 in plaintext LoRA to 0.7824 in ciphertext, while the Gaussian kernel barely moves. A claim of tiny approximation error fits the Gaussian kernel and fails for the other one. Rho et al. replace the classification matrix with rank-32 LoRA blocks. FELID keeps a dense 768×768 matrix, so the graphs are not the same. Functional bootstrapping has a smaller worst-case error, about 2^-13.5 versus 2^-10, and a larger average error, about 2^-14 versus 2^-16.4. The server is only assumed honest-but-curious, and embeddings are computed in plaintext on the client.

Terms

Source

What people are saying

Related papers

All paper explainers