TL;DR
This paper introduces AlphaEvolve, an AI-driven framework that automates the optimization of Fully Homomorphic Encryption (FHE) kernels on Google TPUs. By treating kernel optimization as an evolutionary search problem guided by real-world hardware feedback and rigorous correctness checks, AlphaEvolve significantly reduces FHE computation latency, making it more practical for large-scale deployment.
What Problem Does This Paper Address?
Fully Homomorphic Encryption (FHE) is a powerful privacy-enhancing technology that allows computations on encrypted data. However, FHE incurs massive computational and memory overheads, severely limiting its practical use. While specialized hardware like Google's Tensor Processing Units (TPUs) offer high performance, mapping complex FHE operations (kernels) onto them is challenging. This is because existing compiler stacks (like XLA) abstract away low-level hardware details, forcing developers into a tedious trial-and-error process to optimize performance. This manual approach often leads to fragmented execution and underutilized hardware resources, as it's difficult to navigate the intricate trade-offs between cryptographic algorithms, compiler behavior, and TPU architecture.
Methods
The authors adapt AlphaEvolve, an agentic framework that combines Large Language Models (LLMs) with evolutionary search, to automate FHE kernel optimization. The core idea is to frame the optimization process as an evolutionary search problem. Here's how it works:
- Evolutionary Search: AlphaEvolve maintains a population of candidate FHE kernel implementations.
- LLM-driven Generation: An LLM, guided by specific prompts about the task, hardware, and optimization strategies, generates new candidate kernel implementations in JAX/Pallas.
- Hardware-in-the-Loop Evaluation: Each candidate implementation is compiled and executed on a real TPU (TPUv5e in this case).
- Rigorous Correctness and Security Checks: Before performance evaluation, candidates undergo strict correctness tests (using randomized inputs and end-to-end checks) and security validation to ensure they don't introduce vulnerabilities or break cryptographic guarantees.
- Performance Scoring: Validated kernels are profiled using XProf to measure their execution latency. The negative latency serves as the fitness score, rewarding faster kernels.
- Feedback Loop: High-scoring, correct, and secure kernels are added back to the population, driving the evolutionary process towards better optimizations.
This closed-loop system leverages real-world hardware feedback to guide the LLM and the evolutionary search, ensuring that optimizations are not just theoretical but practically beneficial on the target hardware.
Datasets
The paper does not explicitly mention specific datasets used for training the LLM or for evaluating FHE operations in the traditional sense (e.g., image classification datasets). Instead, the "datasets" are the cryptographic kernels themselves, specifically:
- TFHE bootstrapping primitive: Optimized using the Jaxite library.
- CKKS rotation and multiplication primitives: Optimized using the CROSS library.
The evaluation focuses on the performance of these cryptographic operations on TPU hardware, rather than their accuracy on a data classification task.
Key Insights and Ideas
- AI for Hardware-Aware Cryptography: This work demonstrates that AI, specifically guided LLM evolution, can effectively tackle the complex problem of optimizing cryptographic kernels for specialized hardware like TPUs, a task traditionally requiring deep domain expertise and manual effort.
- The Power of Evolutionary Search with Real Hardware Feedback: By combining LLM-generated code with actual execution and profiling on TPUs, AlphaEvolve can discover optimizations that are highly specific to the hardware's microarchitecture and the compiler's behavior, which are often missed by human experts.
- Bridging the Abstraction Gap: The paper highlights how existing high-level programming interfaces (JAX/Pallas) can obscure critical low-level hardware details. AlphaEvolve helps bridge this gap by automatically exploring the design space that influences how these high-level constructs are translated into efficient hardware execution.
- Beyond Algorithmic Improvements: The discovered optimizations are not just algorithmic tweaks but also involve low-level details like loop unrolling for parameter reuse, fine-grained scheduling to hide memory latency, and XLA-favorable tiling to improve Vector Register (VReg) utilization.
- Correctness and Security are Paramount: The rigorous correctness and security checks integrated into the evaluation engine are crucial. This addresses the inherent risk of LLM "hallucinations" and ensures that performance gains do not come at the cost of cryptographic integrity.
Key Results
AlphaEvolve achieved significant performance improvements on TPUv5e within 24 hours of automated exploration:
- TFHE Bootstrapping: Reduced blind_rotate latency from 10 ms to 3.5 ms, a 2.86x speedup. This was achieved through optimizations like loop unrolling and removal of redundant type casts.
- CKKS Rotation: Reduced latency from 4854 µs to 3714 µs, a 1.31x speedup. This was attributed to strategic tensor partitioning that improved VReg utilization.
- CKKS Multiplication: Reduced latency from 6340 µs to 5359 µs, a 1.18x speedup. This improvement stemmed from scheduling optimizations to reuse common parameters.
These results are relative to human-engineered, state-of-the-art baselines.
Limitations and Future Work
Limitations:
- Granularity of Optimization: Targeting isolated operations (like a single polynomial multiplication) proved less effective. The agent needs visibility into broader operational scopes (e.g., the entire bootstrapping process) to make significant impacts.
- Manual Review Still Needed: While AlphaEvolve generates optimized code, a human programmer still reviews and merges the best programs into the original library. Developing an automated functional equivalence checker is an open research problem.
- LLM Hallucinations: While mitigated by rigorous checks, the risk of LLM hallucinations introducing subtle bugs or security vulnerabilities remains a concern, especially for complex cryptographic implementations.
Future Work:
- Extensibility: The framework is designed to be extensible and could potentially optimize FHE primitives on other hardware accelerators or even other types of cryptographic primitives.
- Simulators for Co-design: Integration with simulators could guide specialized hardware-software co-design.
- Parameter Selection and Noise Tracking: Future work could integrate parameter selection with noise tracking to ensure security guarantees are maintained during hardware optimization.
- Automated Functional Equivalence: Developing modules to automatically check functional equivalence would reduce the reliance on manual code reviews.
Summary updated