HEIR: Fully Homomorphic Machine Learning with a Universal Compiler
An FHE compiler toolchain and development platform without sacrificing generality and extensibility.
HEIR provides an MLIR-based path from ML frontends to scheme-level IRs, library backends, and lower-level arithmetic intended for hardware integration.
ML Frontend
Linalg Entry Level
Torch models are converted with torch-mlir to linalg on tensors (with tensor and arith dialects) as HEIR input.
The linalg dialect is a funnel dialect for HEIR's
MLIR frontend. Its abstraction level is required
for matching on ML kernel operations for
optimization. Canonicalization patterns
simplify and reduce memory shuffling
operations and reduce non-linear operations
at this level.
ML Compilation Pipeline
Layout Optimization Flow
Forward analysis propagates IR with default layouts and kernels.
↓Cost models select optimal kernels to minimize cost and layout conversions.
↓Backwards traversal hoists layout conversions to encodings.
New Layout Integrations
HEIR integrates bicyclic [8] and tricyclic [9] layouts and kernels to compute batched matrix multiplication for parallelized multi-head self-attention with optimal multiplicative depth.
Supported layouts and kernels are easily extended with ISL utilities and a testable MLIR-agnostic kernel library.
Optimization Variety Pack
HEIR's ML pipeline utilizes a number of generally applicable optimization patterns:
- Sparse matrix product simplification
- Baby-step giant-step for general reductions
- Minimal depth polynomials evaluation with Paterson-Stockmeyer
- Fast (hoisted) rotation rewrites
- Minimized extended key basis switching
- High level program vectorization
- Shift networks for layout conversions
- Loop support with HALO optimizations
- Multiplexed data packing for slot utilization
Hardware Integrations
Exit Dialects
Support for multiple backends (CPU, GPU, FPGA, ASICs, and photonics) allows for comprehensive testing and benchmarking. After HEIR's high level program analysis and compilation, data layouts, kernels, schemes, and parameters are selected and the IR uses scheme level operations. Scheme level IR is lowered in two possible ways to exit HEIR:
- Library dialects (e.g. Lattigo, OpenFHE,
tfhe-rs) mirror APIs and are translated to code via HEIR's emitter. Allows fast prototyping and easy integration but limits the ability to perform fusion or other cross-operation optimizations. - Low level IRs: scheme operations are implemented using polynomial and modular arithmetic dialects. Hardware specific toolchains handle further optimization, scheduling and assembly (e.g. the LLVM toolchain compiles the MLIR for CPU). This path is suitable for longer term, robust integrations.

Optalysys utilizes photonic computing technology to perform modular arithmetic operations over the Polynomial Modular Number System (PMNS). Integration with HEIR's generated low level NTT and mod arith code will allow running FHE workloads on Optalysys' optical processing chips.
Belfort integrates their FPGA-based accelerator with HEIR
through the CGGI boolean and shortint APIs. They utilize
vectorization strategies in HEIR and software optimizations in
their custom tfhe-rs library for performance.
Ian Berkenstein, Milind et al. "BTS: An Accelerator for Bootstrappable Fully Homomorphic Encryption," in Proceedings of the 49th Annual International Symposium on Computer Architecture, ACM, 2022.

Cornami's MX2 systolic array is integrated as a backend to HEIR's MLIR pipeline for CGGI and CKKS schemes. HEIR exits to Cornami's Secure Computing Interface Framework (SCIFR) with custom optimizations.
Custozimov, Denis et al. "Resource-Sensitive Integration of CGGI and CKKS schemes on the Cornami Computing Target," ArXiv, 2025.
TPU-native CKKS implementation with SoTA performance vs GPU (20ms bootstrap) using JAX. HEIR integration utilizes the CKKS dialect to lower to the CROSS API exit dialect.
Fang, Jiangteng et al. "Leveraging ASIC AI Chips for Homomorphic Encryption," in IEEE International Symposium on High-Performance Computer Architecture, 2025.

HEIR tracks progress of the polynomial intermediate representation (IR) developed by FHE Technical Consortium for Hardware (FHETCH). The IR aims to provide a standardised set of hardware-level operations for interoperable platform integration. HEIR's polynomial dialect aligns with the evolving standard.
The global FHE hardware consortium (www.fhetch.org)
Plus more backends in progress (e.g. FIDESlib GPU backend) and under NDA.
C. Aguilo-Domingo et al., "FIDESlib: A Fully-Fledged Open-Source FHE Library for Efficient CKKS on GPUs," in 2025 IEEE International Symposium on Performance Analysis of Systems and Software (ISPASS), Ghent, Belgium, 2025, pp. 1-3.
Community
HEIR's open-source framework supports major homomorphic encryption methods, enabling efficient research and benchmarking. Its architecture facilitates the integration of state of the art and emerging methodologies, as evidenced by various projects built with or incorporated into HEIR.
Call for Contributions
Connect with us to explore potential research directions and integrations, including:
- Integrating Gentry-Lee FHE scheme "Fully Homomorphic Encryption for Matrix Arithmetic"
- Layout optimizer that uses the structure of Presburger relations, and/or the general joint layout+kernel selection problem
- New FHE scheme implementations (e.g. GBFV) and optimizations
- Incorporating memory constraints into cost models for kernel compilation
- Profile-guided optimizations for parameter selection & scale management
Fhelipe Layout Hoisting
HEIR uses a FHelipe's hoisting heuristic to minimize layout conversions between operations.
Average-Case Noise Analysis
HEIR was used to experimentally demonstrate underestimations of average-case noise analysis.
HALO Compiler Loop Support
HEIR adopts transforms from the HALO compiler for loop-aware bootstrapping placement.
ROTOM: Autovectorizing HE
ROTOM's tensor vectorization strategy is integrated as an option for layout optimization.
Orion Compiler Kernels
HEIR incorporates Orion's convolution data layout and kernel with double-hoisting and BSGS.
KeyMemRT Memory Scalability
Key memory management minimization strategies are incorporated into HEIR.
Tricycle: Private Transformers
HEIR supports tricyclic layouts to enable ciphertext matrix multiplications for self-attention.
Vos-Vos-Erkin Shift Networks
Efficient shift network implementation of layout conversions using graph coloring.
References
- E. Chen et al., Bridging Usability and Performance: A Tensor Compiler for Autovectorizing Homomorphic Encryption, IACR Cryptol. ePrint Arch., 2025/1319.
- Z. Zhou et al., Orbit: Optimizing Rescale and Bootstrap Placement with Integer Linear Programming Techniques for Secure Inference, Cryptology ePrint Archive, 2026/213.
- E. Ünay et al., KeyMemRT Compiler and Runtime: Unlocking Memory-Scalable FHE, arXiv:2601.18445, 2026.
- M. Gao and H. Zheng, A Critique on Average-Case Noise Analysis in RLWE-Based Homomorphic Encryption, Proceedings of the 13th Workshop on Encrypted Computing & Applied Homomorphic Computing, 2025.
- A. Krastev et al., A Tensor Compiler with Automatic Data Packing for Simple and Efficient Fully Homomorphic Encryption, Proceedings of the ACM on Programming Languages, vol. 8, no. PLDI, June 2024, pp. 126–50.
- S. Cheon et al., HALO: Loop-Aware Bootstrapping Management for Fully Homomorphic Encryption, Proceedings of the 30th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 1, 2025, pp. 572–85.
- A. Ebel et al., Orion: A Fully Homomorphic Encryption Framework for Deep Learning, Proceedings of the 30th ACM International Conference on Architectural Support for Programming Languages and Operating Systems, Volume 2, 2025, pp. 734–49.
- J. Chen, L. Yang, W. Wu, Y. Liu, and Y. Feng, Homomorphic Matrix Operations Under Bicyclic Encoding, IEEE Transactions on Information Forensics and Security, vol. 20, 2025, pp. 1390–404.
- L. Lim et al., Tricycle: Private Transformer Inference with Tricyclic Encodings, Cryptology ePrint Archive, 2025/1200.
- J. Vos et al., Efficient Circuits for Permuting and Mapping Packed Values Across Leveled Homomorphic Ciphertexts, Computer Security – ESORICS 2022, Springer, 2022, pp. 408–23.