KeyMemRT-Compiler is an FHE (Fully Homomorphic Encryption) compiler that reduces the memory footprint of FHE applications. It reuses the IR and infrastructure of HEIR.
More information is available in the KeyMemRT paper here.
KeyMemRT Compiler is built the same way as HEIR. Please follow HEIR docs to build from source.
Alternatively, here are the commands for an Ubuntu/x86 machine:
- Install the prerequisites:
sudo apt update && sudo apt install wget python3 \
clang lld libomp-dev \
mold zlib1g-dev- Install
Bazelisk
wget -c https://github.com/bazelbuild/bazelisk/releases/latest/download/bazelisk-linux-amd64 && \
mv bazelisk-linux-amd64 bazel && \
chmod +x bazel && \
mkdir -p ~/bin && \
echo 'export PATH=$PATH:~/bin' >> ~/.bashrc && \
mv bazel ~/bin/bazel && \
source ~/.bashrc- Clone and build the repo:
git clone https://github.com/eymay/KeyMemRT-Compiler.git && cd KeyMemRT-Compiler/
bazel build //tools:keymemrt-opt
bazel build //tools:keymemrt-translateKeyMemRT Compiler is a series of passes that can be called from the newly built driver ./bazel-bin/tools/keymemrt-opt.
- Run KeyMemRT tests:
bazel test //tests:keymemrt_testsKeyMemRT adds the passes listed below:
--lower-linear-transform
--symbolic-bsgs-decomposition
--kmrt-merge-rotation-keys
--kmrt-key-prefetching
--profile-annotator
--remove-unnecessary-bootstraps
--bootstrap-rotation-analysis
--openfhe-insert-clear-ops
--kmrt-key-prefetchingKeyMemRT reuses these HEIR and MLIR passes, some with modifications:
--ckks-to-lwe
--lwe-to-openfhe
--openfhe-configure-crypto-context
--openfhe-fast-rotation-precompute
--cse
--lower-affineAn example pipeline to lower the HEIR ckks dialect to openfhe dialect with KeyMemRT key management is:
./bazel-bin/tools/keymemrt-opt \
--ckks-to-lwe \
--lwe-to-openfhe \
--lower-linear-transform \
--symbolic-bsgs-decomposition \
--kmrt-merge-rotation-keys \
--annotate-module="backend=openfhe scheme=ckks" \
--openfhe-configure-crypto-context \
--openfhe-fast-rotation-precompute \
--bootstrap-rotation-analysis \
--kmrt-merge-rotation-keys \
--cse \
--openfhe-insert-clear-ops \
<ckks-input.mlir> > <static-out.mlir>
This will result in the KeyMemRT Low Memory mode execution that disk IO and computation will block each other. To enable prefetching and to get to KeyMemRT Balanced mode, these passes can be added in the end:
...
--kmrt-key-prefetching="runtime-delegated=1" \
--lower-affine` \
@misc{ünay2026keymemrt,
title={KeyMemRT Compiler and Runtime: Unlocking Memory-Scalable FHE},
author={Eymen Ünay and Björn Franke and Jackson Woodruff},
year={2026},
eprint={2601.18445},
archivePrefix={arXiv},
primaryClass={cs.CR},
url={https://arxiv.org/abs/2601.18445},
}