CrypTorch: Unified PyTorch-based Auto-tuning Compiler for Private Machine Learning Inference
Organizations: The Pennsylvania State University, University Park, PA, USA
Abstract
MPC-based ML uses secure multi-party computation (MPC) to execute machine learning (ML) workloads across multiple parties without requiring any party to reveal its private data or model parameters. Our characterization study finds that the performance of state-of-the-art MPC frameworks is often dominated by operator-approximation strategies, where ML operators not natively supported by MPC are replaced with iterative methods or polynomials. These approximations are typically chosen heuristically by each framework and applied globally. As a result, they can be unnecessarily expensive in some cases, yet insufficiently accurate in others. We find that the best approximation choice depends on the context, target framework, and application, making a single globally fixed approximation fundamentally suboptimal. To address this problem, we design CrypTorch, a multi-stage compiler for MPC-based ML that supports multiple MPC frameworks as backends. At the core of CrypTorch is its auto-tuning stage, which extracts cost estimates from the target MPC backend and quality estimates from a proxy PyTorch execution, and uses them to automatically select a set of approximations that maximizes performance while satisfying the given quality constraint. We show that CrypTorch's auto-tuner improves performance across multiple MPC backends by 1.14--1.60x without degrading accuracy, and by 1.17--1.92x with less than 3% accuracy degradation. CrypTorch's unified design also improves programmability and usability by allowing multiple backends to share other common compiler functionality and optimizations. We further show that the auto-tuner extends to a related fully homomorphic encryption (FHE) backend, reducing the number of bootstrapping operations by 1.31--1.65x.
Figures & tables
| \begin{array}[]{c}\Gamma\vdash\add(e_{1},e_{2})\Rightarrow\add_{SEC}(\encode_{SEC}(E_{1},s_{max}),\encode_{SEC}(E_{2},s_{max})):\langle\secret,\textsc{I}_{d},s_{max}\rangle\Gamma\vdash e_{1}\Rightarrow E_{1}:\langle\secret,\textsc{I}_{d},s_{1}\rangle\hskip 4.62497pt\Gamma\vdash e_{2}\Rightarrow E_{2}:\langle\secret,\textsc{I}_{d},s_{2}\rangle\hskip 4.62497pt\max(s_{1},s_{2})=s_{max}\\[15.49994pt] \Gamma\vdash\add(e_{1},e_{2})\Rightarrow\add_{SEC}(\encode_{SEC}(E_{1},s_{max}),\encode(E_{2},s_{max})):\langle\secret,\textsc{I}_{d},s_{max}\rangle\Gamma\vdash e_{1}\Rightarrow E_{1}:\langle\secret,\textsc{I}_{d},s_{1}\rangle\hskip 4.62497pt\Gamma\vdash e_{2}\Rightarrow E_{2}:\langle\pub,it,s_{2}\rangle\hskip 4.62497pt\max(s_{1},s_{2})=s_{max}\\[15.49994pt] \Gamma\vdash\add(e_{1},e_{2})\Rightarrow\add_{SEC}(\encode_{SEC}(E_{1},s_{max}),\encode(E_{2},s_{max})):\langle\secret,\textsc{I}_{d},s_{max}\rangle\Gamma\vdash e_{1}\Rightarrow E_{1}:\langle\secret,\textsc{I}_{d},s\rangle\hskip 4.62497pt\Gamma\vdash e_{2}\Rightarrow E_{2}:\langle\pub,ft,1\rangle\hskip 4.62497pt\max(s,s_{d})=s_{max}\end{array} |
| \begin{array}[]{c}\Gamma\vdash\mul(e_{1},e_{2})\Rightarrow\encode_{SEC}(\mul_{SEC}(E_{1},E_{2}),s_{max}):\langle\secret,\textsc{I}_{d},s_{max}\rangle\begin{array}[]{c}\Gamma\vdash e_{1}\Rightarrow E_{1}:\langle\secret,\textsc{I}_{d},s_{1}\rangle\hskip 4.62497pt\Gamma\vdash e_{2}\Rightarrow E_{2}:\langle\secret,\textsc{I}_{d},s_{2}\rangle\hskip 4.62497pt\max(s_{1},s_{2})=s_{max}\end{array}\\[7.74997pt] \Gamma\vdash\mul(e_{1},e_{2})\Rightarrow\encode_{SEC}(\mul_{SEC}(E_{1},E_{2}),s_{max}):\langle\secret,\textsc{I}_{d},s_{max}\rangle\begin{array}[]{c}\Gamma\vdash e_{1}\Rightarrow E_{1}:\langle\secret,\textsc{I}_{d},s_{1}\rangle\hskip 4.62497pt\Gamma\vdash e_{2}\Rightarrow E_{2}:\langle\pub,it,s_{2}\rangle\hskip 4.62497pt\max(s_{1},s_{2})=s_{max}\end{array}\\[7.74997pt] \Gamma\vdash\mul(e_{1},e_{2})\Rightarrow\encode_{SEC}(\mul_{SEC}(E_{1},\encode(E_{2},s_{d})),s_{max}):\langle\secret,\textsc{I}_{d},s_{max}\rangle\begin{array}[]{c}\Gamma\vdash e_{1}\Rightarrow E_{1}:\langle\secret,\textsc{I}_{d},s\rangle\hskip 4.62497pt\Gamma\vdash e_{2}\Rightarrow E_{2}:\langle\pub,ft,1\rangle\hskip 4.62497pt\max(s,s_{d})=s_{max}\end{array}\end{array} |
Privacy-Preserving ML
Privacy-preserving machine learning develops methods to learn, share, and run models while limiting exposure of sensitive data.
See all 445 papers