Bridging Usability and Performance: A Tensor Compiler for Autovectorizing Homomorphic Encryption

Edward Chen, Fraser Brown, Wenting ZhengIACR ePrint 2025

Introduction

Homomorphic Encryption (HE) is often regarded as the "holy grail" of data privacy, as it permits complex computations on data while it remains in an encrypted state. However, the practical adoption of HE is hindered by its substantial computational overhead. To mitigate this, developers employ Single-Instruction, Multiple-Data (SIMD) techniques, packing thousands of data elements into a single ciphertext.

A primary challenge in this domain is that HE performance is extremely sensitive to data layout—the specific ordering of elements within the ciphertext. Inefficient layouts require frequent and expensive "rotation" operations, which are significantly slower than standard arithmetic. Manually determining the optimal layout for complex workloads, such as deep learning models, is a combinatorial problem that typically requires expert intervention and lengthy compilation cycles.

The Rotom Compiler Architecture

Rotom is a specialized tensor compiler designed to automate the optimization of data layouts for HE, providing a bridge between high-level usability and low-level performance. The compiler transforms high-level tensor programs into optimized HE kernels through a structured pipeline that emphasizes symbolic reasoning and heuristic search.

The Rotom compilation pipeline, illustrating the transition from Tensor IR to Layout IR, followed by alignment, optimization, and heuristic search.

The workflow begins by lowering a high-level Tensor IR into a Layout IR. Rotom then applies formal alignment rules to ensure that encrypted tensors are correctly positioned for subsequent operations. If misalignments are detected, the compiler automatically inserts the most efficient conversion operators. To navigate the exponential search space of potential layouts, Rotom utilizes four cost-based heuristics—including symmetry breaking and Pareto-frontier pruning—enabling it to find high-performance configurations in minutes.

Key Technical Contributions

A core innovation of the Rotom framework is the introduction of the ApplyRoll operator. Unlike traditional layout conversion methods that are computationally heavy, ApplyRoll is a lightweight operator that utilizes cyclic rotations to modify data arrangements.

The ApplyRoll operator facilitates efficient layout modifications through cyclic rotations, enabling better alignment for complex tensor operations.

Beyond the ApplyRoll operator, Rotom incorporates several advanced optimization strategies:

  • Symbolic Layout Reasoning: By using high-level symbolic representations instead of materializing full ciphertexts during compilation, Rotom can evaluate thousands of layout candidates in seconds.
  • Peephole Optimizations: The compiler identifies patterns within the Layout IR and applies cryptographic optimizations like the Baby-step Giant-step (BSGS) algorithm, which reduces rotation complexity from $O(n)$ to $O(\sqrt{n})$.
  • Axis Swapping: Rotom leverages the insight that rolling a dimension by a "repeated" dimension can effectively swap axes at a much lower cost than standard permutations.

Experimental Evaluation

The authors evaluated Rotom using seven representative tensor workloads: Euclidean distance, single and double matrix multiplications, third-order tensor-matrix products (TTM), 2D convolutions, logistic regression, and the BERT attention layer. Rotom was compared against state-of-the-art HE compilers, Fhelipe and Viaduct-HE.

Key Results

  • Performance Gains: Rotom achieved up to an 80× speedup over prior systems on complex benchmarks like BERT Attention.
  • Compilation Speed: While existing tools often required over 13 hours for a single matrix multiplication, Rotom successfully compiled all benchmarks in under five minutes.
  • Expert-Level Optimization: In tests against manually optimized cryptographic protocols, Rotom reduced the number of required rotations by up to 4×.
  • Developer Usability: A user study confirmed that students could implement a complex BERT attention layer in approximately five minutes using Rotom’s Python-based DSL, which is designed to mirror the syntax of PyTorch.

Conclusion and Future Directions

Rotom demonstrates that automated layout optimization can significantly enhance the performance and accessibility of Homomorphic Encryption. While the system provides substantial improvements, future work will focus on integrating automatic "bootstrapping" for noise management, supporting irregular tensor shapes by relaxing power-of-two constraints, and exploring coefficient-based encoding schemes to further expand the optimization space.

Summary updated

BibTeX
@article{chen2025bridging,
  author = {Edward Chen and Fraser Brown and Wenting Zheng},
  title = {{Bridging Usability and Performance: A Tensor Compiler for Autovectorizing Homomorphic Encryption}},
  journal = {IACR Cryptol. ePrint Arch.},
  year = {2025},
}
Figure