# RuleFlow : Generating Reusable Program Optimizations with LLMs

arXiv: https://arxiv.org/abs/2602.09051 · HTML: https://mlsanity.com/paper/2602.09051/

## Key facts

- Cited by 1 papers in the map (data through 14 Oct 2026).
- Builds on 8 of its 29 references that are in the map.
- First posted on arXiv 6 Feb 2026.

## Builds on (most cited first, 8 of 8)

- [KernelBench: Can LLMs Write Efficient GPU Kernels?](https://mlsanity.com/paper/2502.10517/) (2025)
- [Barbarians at the Gate: How AI is Upending Systems Research](https://mlsanity.com/paper/2510.06189/) (2025)
- [AccelOpt: A Self-Improving LLM Agentic System for AI Accelerator Kernel Optimization](https://mlsanity.com/paper/2511.15915/) (2025)
- [Adaptive Self-improvement LLM Agentic System for ML Library Development](https://mlsanity.com/paper/2502.02534/) (2025)
- [GenRewrite: Query Rewriting via Large Language Models](https://mlsanity.com/paper/2403.09060/) (2024)
- [KGTorrent: A Dataset of Python Jupyter Notebooks from Kaggle](https://mlsanity.com/paper/2103.10558/) (2021)
- [An Empirical Study on How the Developers Discussed about Pandas Topics](https://mlsanity.com/paper/2210.03519/) (2022)
- [PandasBench: A Benchmark for the Pandas API](https://mlsanity.com/paper/2506.02345/) (2025)

## Built on by (most cited first, 1 of 1)

- [SkillEffect: Checked Lowering for Memory-Bounded Agent Tools](https://mlsanity.com/paper/2608.17007/) (2026)

## Abstract (arXiv)

Optimizing Pandas programs is a challenging problem. Existing systems and compiler-based approaches offer reliability but are either heavyweight or support only a limited set of optimizations. Conversely, using LLMs in a per-program optimization methodology can synthesize nontrivial optimizations, but is unreliable, expensive, and offers a low yield. In this work, we introduce a hybrid approach that works in a 3-stage manner that decouples discovery from deployment and connects them via a novel bridge. First, it discovers per-program optimizations (discovery). Second, they are converted into generalised rewrite rules (bridge). Finally, these rules are incorporated into a compiler that can automatically apply them wherever applicable, eliminating repeated reliance on LLMs (deployment). We demonstrate that RuleFlow is the new state-of-the-art (SOTA) Pandas optimization framework on PandasBench, a challenging Pandas benchmark consisting of Python notebooks. Across these notebooks, we achieve a speedup of up to 4.3x over Dias, the previous compiler-based SOTA, and 1914.9x over Modin, the previous systems-based SOTA. Our code is available at https://github.com/ADAPT-uiuc/RuleFlow.
