arXiv:2611.01450cs.CRNov 2026

Manuscript Offprint

arXiv:2611.01450

CipherFlow: Compiling AI Programs for Efficient Cryptographically Secure Inference

Hedong Zhang, Mengxin Zheng, Qian Lou

Abstract

Cryptographically secure inference faces two practical challenges: making secure programming accessible to AI developers and data scientists, and achieving efficient execution across deployment environments. Developers must compose cryptographic primitives correctly, while performance depends on hardware, networks, and evolving ciphertext states. We present CIPHERFLOW, a compiler framework that takes a high-level AI computation graph, available cryptographic primitives, and a target hardware and network configuration to generate an executable, latency-optimized secure inference program. CIPHERFLOW automates cryptographic execution decisions through three techniques: MicroBench profiles deployment-specific primitive costs; state-expanded planning jointly optimizes homomorphic encryption (HE) and secure multi-party computation (MPC) placement, conversions, and ciphertext maintenance under cryptographic-state constraints; and BlockFold summarizes branched regions to scale planning to Transformer graphs. Evaluation using measured HE/MPC backend costs across CPU/GPU and network settings shows up to 16.5× speedup on BERT-base and over 22× on ViT compared with static hybrid placement baselines. CIPHERFLOW separates model programming from cryptographic execution decisions, enabling developers to express AI computations while the compiler constructs efficient secure programs.

Figure

Figure 1: CipherFlow at a glance. Model graphs, cryptographic primitives, and hardware/network profiles inform a latency-optimized HE–MPC plan with conversions and HE maintenance.

1 Introduction

AI developers and data scientists increasingly deploy models in privacy-sensitive domains such as healthcare, finance, and biometric authentication, where plaintext cloud inference can expose user

40th Conference on Neural Information Processing Systems (NeurIPS 2026).

inputs and model intellectual property [1–6]. Cryptographically secure inference protects these assets by evaluating neural networks with homomorphic encryption (HE) [7] and secure multi-party computation (MPC) [8], without exposing inputs, model weights, or intermediate activations beyond the prescribed output [9–14]. Turning this capability into a practical way to deploy AI requires addressing two coupled challenges: programming usability and execution efficiency.

Challenge 1: Programming usability. AI programmers express models through tensor operators and data dependencies; a secure implementation must additionally specify how those computations are realized through cryptographic protocols. The developer must choose HE or MPC for each operator, insert conversions between representations, and maintain compatible ciphertext states along sequential paths and at branch joins [15, 16]. These decisions require cryptographic and systems expertise beyond model development. For example, assigning a matrix multiplication to HE is insufficient if its input ciphertext lacks the required level budget, and a residual addition cannot execute in HE until its inputs have compatible states. Prior secure-computation compilers and mixed-protocol frameworks establish the value of translating high-level programs into cryptographic execution [17, 18]. The programming challenge is therefore to let developers specify the AI computation while a compiler constructs a complete, executable secure program, including the conversions and maintenance actions needed by its backend primitives.

Challenge 2: Execution efficiency. An executable secure program must also adapt to the deployment on which it runs. HE can efficiently process linear operations such as matrix multiplications and convolutions with little interaction [6, 19, 20], whereas nonlinear functions such as ReLU and Softmax can require expensive approximations or ciphertext maintenance [10, 21–26]. MPC offers alternative protocols for these functions but incurs communication and synchronization costs [27, 28]. This complementarity motivates hybrid HE–MPC execution [26, 15, 29]. Figure 2(a,b) illustrates how explicit conversions connect the two domains and how a hybrid strategy can outperform either domain alone. Representative hybrid systems use manually designed placement strategies [30–33], but a fixed assignment by operator type cannot capture changing compute and communication costs.

(a) Hybrid Secure Inference

Figure

(b) Hybrid vs. FHE/MPC-only Performance

(c) BERT-base Latency under 3 Static Hybrid Strategies

Figure 2: (a) Hybrid secure inference executes different operators in HE or MPC with explicit conversions. (b) Hybrid execution can outperform FHE-only and MPC-only across different model architectures under the same CPU (16-core) and network setting 200 Mbps, 4 ms. (c) BERT-base latency under three static hybrid strategies across different hardware settings. (* Linear∈ HE, Nonlinear∈ MPC [32]; † Attention∈ HE, FFN∈ MPC; ‡ Attention∈ MPC, FFN∈ HE)

Execution efficiency depends on both deployment costs and cryptographic state. GPU acceleration changes the cost of HE relative to MPC [10, 34–41], while bandwidth and round-trip time change the cost of interactive protocols and cross-domain conversions [6, 42–44]. Figure 2(c) shows that the best static strategy for BERT-base changes across CPU and GPU deployments. Moreover, HE operations consume a finite ciphertext level budget [45, 46]; continuing in HE may require bootstrapping [7] or a conversion round trip. At residual and attention joins, incoming states must also be compatible. Consequently, a locally inexpensive operator choice can force costly maintenance or conversions downstream, and enumerating joint states across branches can make planning intractable for Transformer graphs [47]. Efficient compilation must optimize these coupled decisions while enforcing execution feasibility.

CipherFlow: from AI programs to secure execution. We present CIPHERFLOW (Figure 1), a compiler framework that takes a high-level AI computation graph, available cryptographic primitives, and a target hardware and network configuration, and generates a deployment-specialized, latency-optimized secure inference program. It addresses programming usability by separating model computation from cryptographic execution decisions: the compiler selects HE/MPC operators and materializes conversions, state alignment, and maintenance actions using the supported backends. It addresses execution efficiency by jointly planning these actions under measured deployment costs and cryptographic-state constraints. The resulting program composes the backend primitives under their security assumptions; the compiler automates their selection and execution planning.

CIPHERFLOW combines three techniques. MicroBench profiles HE/MPC operators, conversions, and bootstrapping on the target deployment. It benchmarks representative secure operator patterns and reuses measurements across repeated model blocks, keeping profiling costs manageable. State-expanded planning represents each operator together with its execution domain and remaining HE level, and jointly optimizes placement, conversion, and maintenance decisions. This turns feasibility-aware planning on sequential regions into shortest-path search. BlockFold extends planning to branched graphs by summarizing residual and attention regions as boundary-state transition tables. These summaries capture feasible, minimum-cost transformations through each region and support their composition without enumerating all branch-internal state combinations across the full graph. Together, the three techniques connect a high-level programming interface to executable secure computation tailored to its deployment.

We make four contributions:

  1. A compiler framework for usable and efficient secure AI inference. We formulate compilation from AI computation graphs, cryptographic primitives, and deployment configurations to executable hybrid secure programs, jointly capturing operator placement, conversions, ciphertext maintenance, and cryptographic-state feasibility.

  2. Deployment-specific cost profiling and state-aware planning. We design MicroBench and a state-expanded graph formulation that jointly optimize HE/MPC execution and auxiliary actions under measured hardware and network costs, reducing sequential planning to shortest-path search.

  3. Scalable planning for branched neural graphs. We introduce BlockFold, which summarizes branched regions using boundary-state transition tables and composes them into a global plan while respecting compatibility at joins, enabling optimization on Transformer-scale graphs.

  4. Implementation and evaluation with real cryptographic backends. We implement CIPHERFLOW on HE/MPC backends and evaluate plans using measured operator latency, communication, and maintenance costs across CPU/GPU and network settings. On BERT-base and ViT, the evaluation shows up to 16.5× and over 22× speedup, respectively, compared with static hybrid placement baselines [32, 33, 42].

References (59)