Overview
Researchers from Google and DeepMind have introduced REGAL (Reinforced Genetic Algorithm Learning), a hybrid approach that combines Graph Neural Networks (GNNs) with a genetic search algorithm to optimize how neural networks are executed on hardware. Unlike previous methods that take hours to optimize a single model, REGAL generalizes to new, unseen computation graphs in seconds, significantly reducing both execution time and memory usage.
The Challenge of Computation Graphs
When executing a large neural network, such as a Transformer, a compiler must make two critical decisions:
- Placement: Determining which processor (e.g., CPU or GPU) handles which specific mathematical operation.
- Scheduling: Deciding the exact sequence in which those operations occur.
This routing and scheduling task is a classic NP-hard problem. Traditionally, compilers rely on fast heuristics (educated guesses) that often leave potential performance gains on the table. While recent AI-based approaches have attempted to learn these decisions, they suffer from a major flaw: they must "re-learn" from scratch for every new model, taking hours to find a viable setup. Production compilers require solutions that are both high-quality and near-instantaneous.
The REGAL Methodology
To bridge the gap between "pure search" and "pure learning," the authors propose a hybrid system.
REGAL operates through three main components:
- The Searcher (BRKGA): The system utilizes the Biased Random-Key Genetic Algorithm. This algorithm explores a "population" of possible solutions, evolving them over time through crossover and mutation. Typically, this process starts with a random, uniform guess.
- The Guide (GNN Policy): Instead of starting blindly, REGAL employs a Graph Neural Network (GNN). The GNN analyzes the structure of the computation graph (the nodes and their dependencies) and predicts a specific "proposal distribution" (a Beta distribution) for each node.
- The Learning (RL): The GNN is trained using Reinforcement Learning (REINFORCE). The reward signal is based on how much faster or more memory-efficient the resulting execution is compared to a standard baseline.
By using the GNN to "warm start" and direct the genetic search, the system discovers superior hardware configurations much faster than the genetic algorithm could achieve independently.
Evaluation Datasets
To ensure robustness, the authors evaluated REGAL on datasets of real-world complexity:
- TF Runtime/Memory Datasets: 372 unique, real-world TensorFlow graphs mined from Google’s internal clusters, augmented into over 16,000 variants.
- Synthetic Dataset: 10,000 graphs generated using classic random graph models (like Erdos-Renyi) to test the limits of the algorithm's logic.
- XLA Benchmark: A set of graphs from a production compiler team used to test how well the model generalizes to entirely different types of operations.
Key Insights
- Search + Learning > Either Alone: Predicting the final schedule directly is too slow and scales poorly. By letting the GNN provide "hints" to a search algorithm, REGAL captures the robustness of search and the intuition of deep learning.
- Zero-Shot Generalization: This is the first paper to demonstrate a policy that can be trained offline and then immediately applied to a brand-new neural network architecture at "test time" with high success.
- Structure Matters: The paper proves that GNNs are essential. Models that ignored the graph structure (treating the operations as a simple sequence) performed significantly worse.
Key Results
REGAL consistently outperformed both classical heuristics and "tuned" versions of standard algorithms.
- Efficiency: On TensorFlow graphs, REGAL improved execution runtime by 7.09% and reduced peak memory usage by 3.56% compared to a strong genetic algorithm baseline (BRKGA 5k).
- Speed: REGAL produces these optimized decisions in about 1 second, a massive improvement over previous RL methods that required 12 to 27 hours of training per graph.
- Generalization: Even when tested on XLA graphs (which utilize different operations than the training set), REGAL still provided performance gains, proving it learned the underlying logic of scheduling rather than just memorizing specific graph patterns.
Limitations and Future Work
While the results are highly promising, the authors acknowledge a few areas for future development:
- Simplified Cost Model: The current system uses a "coarse" simulator to estimate performance. Integrating REGAL directly into a real compiler (like XLA or TVM) to measure actual hardware execution is the next logical step.
- Memory Nuances: The model does not currently account for memory fragmentation or asynchronous data transfers, which are critical factors in high-performance computing.
- Scaling Up: While it handles thousands of nodes effectively, production-scale models can be even larger, requiring further optimizations in the GNN architecture to maintain its rapid 1-second inference speed.
Summary updated