google / google/heir

Investigate what parts of SmartPAF can be ported to HEIR

Open
#1,559 0 comments 0 reactions 0 assignees View on GitHub
research synthesis
Dominant language
MLIR
Stars
906
Forks
171
Avg merge
4d 12h
Merged PRs (30d)
32

Description

This paper (by our current student researcher Jianming Tong) designs a number of methods to improve the accuracy of a trained model whose activation functions have been replaced by polynomial approximations.

https://arxiv.org/abs/2404.03216

> Accurate Low-Degree Polynomial Approximation of Non-polynomial Operators for Fast Private Inference in Homomorphic Encryption
> [Jianming Tong](https://arxiv.org/search/cs?searchtype=author&query=Tong,+J), [Jingtian Dang](https://arxiv.org/search/cs?searchtype=author&query=Dang,+J), [Anupam Golder](https://arxiv.org/search/cs?searchtype=author&query=Golder,+A), [Callie Hao](https://arxiv.org/search/cs?searchtype=author&query=Hao,+C), [Arijit Raychowdhury](https://arxiv.org/search/cs?searchtype=author&query=Raychowdhury,+A), [Tushar Krishna](https://arxiv.org/search/cs?searchtype=author&query=Krishna,+T)
>
> Abstract:
> As machine learning (ML) permeates fields like healthcare, facial recognition, and blockchain, the need to protect sensitive data intensifies. Fully Homomorphic Encryption (FHE) allows inference on encrypted data, preserving the privacy of both data and the ML model. However, it slows down non-secure inference by up to five magnitudes, with a root cause of replacing non-polynomial operators (ReLU and MaxPooling) with high-degree Polynomial Approximated Function (PAF). We propose SmartPAF, a framework to replace non-polynomial operators with low-degree PAF and then recover the accuracy of PAF-approximated model through four techniques: (1) Coefficient Tuning (CT) -- adjust PAF coefficients based on the input distributions before training, (2) Progressive Approximation (PA) -- progressively replace one non-polynomial operator at a time followed by a fine-tuning, (3) Alternate Training (AT) -- alternate the training between PAFs and other linear operators in the decoupled manner, and (4) Dynamic Scale (DS) / Static Scale (SS) -- dynamically scale PAF input value within (-1, 1) in training, and fix the scale as the running max value in FHE deployment. The synergistic effect of CT, PA, AT, and DS/SS enables SmartPAF to enhance the accuracy of the various models approximated by PAFs with various low degrees under multiple datasets. For ResNet-18 under ImageNet-1k, the Pareto-frontier spotted by SmartPAF in latency-accuracy tradeoff space achieves 1.42x ~ 13.64x accuracy improvement and 6.79x ~ 14.9x speedup than prior works. Further, SmartPAF enables a 14-degree PAF (f1^2 g_1^2) to achieve 7.81x speedup compared to the 27-degree PAF obtained by minimax approximation with the same 69.4% post-replacement accuracy. Our code is available at [this https URL](https://github.com/EfficientFHE/SmartPAF).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.