TL;DR
CHLOE is a new compiler framework designed to make programs with complex loops run efficiently over Fully Homomorphic Encryption (FHE). By intelligently segmenting loops into arithmetic and non-arithmetic parts and applying advanced mathematical techniques to "oblivious" loops (where the loop condition itself is encrypted), CHLOE achieves speedups ranging from $1.5\times$ to a staggering $10^5\times$ compared to current state-of-the-art FHE compilers.
What Problem Does This Paper Address?
Fully Homomorphic Encryption (FHE) is the "holy grail" of cryptography, allowing computers to perform calculations on encrypted data without ever seeing the underlying information. However, FHE is notoriously slow—often orders of magnitude slower than plaintext computing.
A major bottleneck is the loop structure. In standard programming, loops are fundamental, but in FHE, they present two massive hurdles:
- Branching Complexity: If a loop contains an
if-elsestatement, FHE must typically execute both paths and then "mask" the result, which is computationally expensive. - Oblivious Loops: If the loop's termination condition is encrypted (e.g., "loop until the encrypted value is zero"), the computer doesn't know when to stop. Existing compilers usually resort to "full unrolling"—executing the loop for the maximum possible number of iterations—which is incredibly inefficient.
Methods
CHLOE (Loop Transformation over FHE) introduces a multi-level compiler architecture built on the MLIR framework. Its core strategy involves:
- Loop Classification: It distinguishes between Transparent Loops (public conditions) and Oblivious Loops (encrypted conditions).
- Loop Segmentation: For complex loops, CHLOE breaks the loop body into mutually independent segments of purely arithmetic operations (additions/multiplications) and non-arithmetic operations (comparisons). This allows the compiler to apply specialized optimizations to each part.
- Multi-Level Vectorization: It leverages SIMD (Single Instruction, Multiple Data) capabilities of FHE schemes like CKKS and BFV. Specifically, it uses SIMD-PBS (Programmable Bootstrapping) to process multiple non-arithmetic operations in a single, amortized "bootstrapping" step.
- Control-Path Reduction: For oblivious loops, CHLOE uses Closed-Form Analysis. If a loop follows a known mathematical recurrence (like the Fibonacci sequence), CHLOE replaces the entire iterative loop with a single analytical expression.
- Cost-Aware Type Alignment: It uses a cost model to decide the most efficient way to represent data (e.g., switching between LWE and RLWE ciphertexts) to minimize the total computational "noise" and time.
Datasets
The researchers evaluated CHLOE using several real-world algorithmic benchmarks:
- Transparent Loop Benchmarks: Database querying, SVM classification, iterative thresholding for image segmentation, and KMeans classification.
- Oblivious Loop Benchmarks: Fibonacci sequence, Markov state transition matrices, compound interest calculations, and variable-length vector summations.
These benchmarks were compared against existing FHE compilers and libraries, including Google's Transpiler, HEIR, and PEGASUS.
Key Insights and Ideas
- Don't Unroll Everything: The "aha moment" is realizing that many oblivious loops aren't truly random; they follow structured mathematical patterns. By identifying these as "C-finite recurrences," the compiler can bypass the loop entirely using a closed-form solution.
- Amortization is King: Bootstrapping (the process of refreshing an FHE ciphertext to reduce noise) is the most expensive operation. CHLOE’s use of SIMD-PBS allows it to perform bootstrapping for hundreds of data points simultaneously, making the cost per data point nearly negligible as the data size grows.
- Hybrid is Better: Rather than sticking to one FHE scheme, CHLOE acts as a "cross-scheme" compiler, picking the best tool (CKKS, BFV, or TFHE) for specific parts of the program.
Key Results
- Transparent Loops: CHLOE achieved speedups of $3.2\times$ to $54\times$ over HEIR and Transpiler. Notably, as the data size increased, CHLOE’s execution time remained nearly flat due to its vectorization strategy, while other compilers saw linear increases in latency.
- Oblivious Loops: For programs where closed-form solutions could be derived (like Fibonacci), CHLOE was up to $10^5\times$ faster than human-assisted unrolling methods.
- Efficiency: In image segmentation tasks, CHLOE was $172\times$ faster than the next best competitor.
Limitations and Future Work
- Memory Overhead: The high performance of SIMD-PBS comes at a cost; CHLOE consumes significantly more memory (RAM) than its competitors when handling large datasets.
- Nested Dependencies: If a loop has "immediate data dependencies"—where an arithmetic result is immediately used in a non-arithmetic condition within the same iteration—CHLOE cannot segment the loop, and performance reverts to levels similar to existing compilers.
- Mixed-Circuit Data Reuse: There is a specific "corner case" where a vector element is used simultaneously in both arithmetic and non-arithmetic statements, which CHLOE currently handles sub-optimally. The authors suggest this can be solved in future versions by inserting more sophisticated ciphertext conversion operators.
Summary updated