FHE-Compatible CNNs


Wei Ao

Computer Vision over Homomorphically Encrypted Data

CVPR 2025 Tutorial

June 12, 2025

how to Adapt CNNs for FHE

Polynomial approximation for non-linear activations
Packing for convolution (Pooling): transferring 3D operation to 1D operation

FHE-Compatible CNNs



Operations Support
Conv2D Packing
BatchNorm2D
AvgPool Packing
Linear
ReLU Approximation
Bootstrapping

Polynomial Approximation for Non-linear Activations

conflict between multiplicative depth and approximation precision

Polynomial Approximation for non-linear activations

  • High-degree approximation
    • Slow: more multiplications, more bootstrappings
    • Accurate: high-degree polynomials
    • Training/fine-tuning: not necessary

Polynomials for Approximation

    • Monomial Polynomials
    $1, x, x^2, \cdots, x^d$
    • Chebyshev Polynomials

Depth for Polynomials

  • Given a polynomial
$f(x)=\sum_{i=0}^d(\alpha_i x^i)$
    • What is the multiplicative depth of the polynomial?
      • How many multiplications are required to evaluate the polynomial?
      • Is it $d-1$?
      • Baby-Step Giant-Step (BSGS) algorithm gives us the minimum number of multiplications $\lceil \log_2(d + 1) \rceil$

    Low-Degree Monomial Approximation

    High-Degree Chebyshev Approximation

    Hermite Polynomial Neural Network Training

    • Polynomial neural network training suffers from numerical instability
      • Backward Propagation: clip gradients
      • Forward Propagation: cannot do clipping under FHE (function $\mathrm{max}$ is not a polynomial)

    Packing for Convolutional Layers

    less rotations, much faster

    SISO Packing for convolution

    • Single-input-single-output packing: pack a 3D tensor channel by channel

    multiplexed packing for convolution

    • Take advantage of SIMD to reduce the complexity of rotation and multiplication
      • Repeated packing: $x^{(M)} = [x, x, \cdots, x]$ with $M=\lfloor \frac{N}{2d} \rfloor$ copies
      • Multiplexed packing: pack different channels interchangeably

    co-designing between CNNs and FHE

    Homomorphic neural architectures

    Polynomial Approximation of ReLU and Bootstrapping

    • Homomorphic evaluation architecture of ResNets
    • High-degree polynomials $\rightarrow$ Levels $\Uparrow \rightarrow$ Bootstrapping $\Uparrow \rightarrow$ Latency $\Uparrow$

    Limitations of handcrafted architectures


    Co-design CNNs and FHE systems

      • Security Requirement

    Encryption Parameters
    • Cyclotomic polynomial degree: $N$
    • Level: $L$
    • Modulus: $Q_l=\prod_{i=0}^{l} q_l, 0 \leq q_l \leq L$
    • Bootstrapping Depth: $K$
    • Hamming Weight: $h$
      • Latency



    space of Homomorphic neural Architectures

    How to effectively trade-off between accuracy and latency?

    Our Key Insight


    Approximate the

    end-to-end function represented by the network

    instead of the activation function.

    How to optimize end-to-end polynomial neural architecture?

    Multi-Objective evolutionary optimization

    Joint Search for Layerwise EvoReLU and Bootstrapping Operations



    Joint Search Problem Multiobjective Search
      • Flexible Architecture
      • On demand Bootstrapping

    benchmark Homomorphic architectures on Encrypted CIFAR

    image classification task

    Experimental Setup

    Dataset: CIFAR10
    • 50,000 training images
    • 10,000 test images
    • 32x32 resolution, 10 classes


    Hardware & Software
    • Amazon AWS, r5.24xlarge
    • 96 CPUs, 768 GB RAM
    • Microsoft SEAL, 3.6

    Latency and Accuracy Trade-offs under FHE


    Summary and Takeaway

      • Polynomial Approximation : solve the conflict between depth and precision.
      • Packing for Convolutional Layers : use SIMD to reduce rotations and multiplications.
      • Co-designing CNNs and FHE : find the optimal homomorphic architecture.