TL;DR
Prism is the first symbolic superoptimizer for tensor programs, designed to automatically discover highly optimized GPU kernels for deep learning workloads. By introducing a symbolic graph representation (sGraph) that abstracts hardware execution parameters into symbolic variables, Prism avoids the combinatorial explosion faced by traditional superoptimizers. It achieves up to a 2.2× speedup over state-of-the-art superoptimizers and a 4.9× speedup over standard compilers while cutting optimization time by up to 3.4×.
What Problem Does This Paper Address?
Maximizing the execution efficiency of machine learning models on GPUs is critical for modern AI applications. Traditional deep learning compilers (like TVM or TensorRT) rely on hand-crafted heuristics and manual rewrite rules designed by domain experts. However, human intuition often misses non-obvious optimization opportunities arising from complex interactions between algebraic transformations, data layouts, and hardware scheduling.
"Superoptimization" addresses this by exhaustively searching the space of mathematically equivalent programs to find the fastest implementation. Unfortunately, existing superoptimizers suffer from a severe scalability bottleneck: they evaluate every possible parallelization strategy (e.g., specific grid dimensions, thread block sizes, and data layouts) as concrete values. This leads to a combinatorial explosion, making exhaustive search intractable for complex modern workloads like Large Language Model (LLM) attention layers.
Methods
Prism overcomes the scalability bottleneck by organizing the optimization space into a two-level hierarchy using a novel representation called sGraph.
Instead of fixing execution parameters to concrete integers, an sGraph represents grid dimensions, block dimensions, and tensor-to-thread mappings symbolically using integer and Boolean variables. This allows a single symbolic graph to compactly represent an entire family of concrete program implementations.
The Prism pipeline operates in three main phases:
- sGraph Generation & Pruning: Prism incrementally constructs candidate sGraphs. It uses Symbolic Dimension Matching and Expression-Guided Pruning to mathematically rule out invalid or suboptimal graph structures before generating any concrete code.
- sGraph Verification: Traditional superoptimizers use random testing with concrete data shapes to verify program equivalence. Because Prism's graphs are symbolic, it instead translates the programs into mathematical expressions and uses an e-graph (equality saturation) framework with ~70 algebraic axioms to formally prove functional equivalence.
- sGraph Instantiation: Once a symbolic graph is verified, Prism instantiates the symbolic parameters into concrete values using random sampling and GPU profiling (auto-tuning) to find the fastest configuration for the target hardware.
Datasets
The authors evaluated Prism on five heavy-duty workloads common to modern LLM architectures (such as LLaMA):
- RMSNorm: Fused normalization followed by a linear layer.
- RMSNorm-MLP: A GLU-style gated MLP with fused normalization.
- SwiGLU: A gated activation function layout.
- Attention: Group-query attention (GQA) in the decode setting.
- QK-Attention: GQA featuring query-key normalization.
Each workload was evaluated across multiple tensor size and hidden dimension configurations on NVIDIA A100 GPUs.
Key Insights and Ideas
- Decoupling Structure from Parameters: Separating high-level computational graph search from low-level hardware parameter tuning shrinks the initial search space from $O(|G||M||D|)$ to just $O(|G|)$, where $G$ represents graph structures, $M$ represents mappings, and $D$ represents dimensions.
- Sound Pruning: Unlike stochastic or LLM-guided search methods, Prism’s symbolic pruning is mathematically sound. It guarantees that it will not accidentally eliminate the optimal solution during the pruning phase.
- Pushing Operators Outward: To handle complex, nested parallel operations in the e-graph framework, the authors introduced "inverse" rewrite rules. This technique allows the e-graph to establish equivalences by pushing parallelization operators outward, peeling away nested complexities that would otherwise stall standard rewrite rules.
Key Results
- Kernel Performance: Prism found strictly better kernels than all baselines on 8 out of 10 evaluated configurations. It achieved up to a 2.2× speedup over Mirage (the state-of-the-art superoptimizer) on QK-Attention and up to a 4.9× speedup over PyTorch Compiled (
torch.compile) on RMSNorm-MLP. - Optimization Speed: Prism reduced end-to-end optimization time by up to 3.4× compared to Mirage. On the complex RMSNorm-MLP workload, Mirage timed out after an hour without finishing, whereas Prism completed the search in under 20 minutes while discovering faster kernels.
- Graph Diversity: By exploring the parallelization space symbolically, Prism discovered up to 23 unique graph structures per workload, compared to just 1 to 14 discovered by Mirage's heuristic-driven approach.
Limitations and Future Work
- Simplified Loop Structure: Prism currently assumes a single for-loop dimension within its execution blocks. While sufficient for many workloads, extending the framework to handle multi-loop dimensions is an explicit direction for future work.
- Basic Auto-Tuning: The parameter instantiation phase currently relies on uniform random sampling. Incorporating more advanced auto-tuning techniques, such as learned cost models or evolutionary algorithms, could find optimal hardware parameters even faster.
- Axiom Completeness: The e-graph verification relies on a manually curated set of axioms. While sound, this set is not mathematically complete, meaning Prism might still miss certain valid algebraic optimizations.
Summary updated