NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

FlowCompile: An Optimizing Compiler for Structured LLM Workflows

Junyan Li, Zhang-Wei Hong, Maohao Shen, Yang Zhang, Chuang GanarXiv 2026

TL;DR

FlowCompile introduces a compiler-inspired paradigm for optimizing structured LLM workflows by shifting optimization from expensive runtime routing to a single compile-time design space exploration pass. By profiling sub-agents independently and using a structure-aware analytical proxy to estimate workflow performance, it generates a reusable set of Pareto-optimal configurations that deliver up to a 6.4× speedup without requiring retraining or online adaptation.

What Problem Does This Paper Address?

As LLM applications evolve from single-prompt queries into complex multi-agent systems, developers are increasingly using structured LLM workflows—systems where specialized sub-agents execute tasks according to a predefined graph (sequential, parallel, or iterative control flows).

Optimizing these workflows is a massive combinatorial challenge. Developers must choose the right model size, reasoning token budget, and structural execution path for every single sub-agent to balance accuracy and latency. Existing methods treat this strictly as an online routing problem, tuning a policy for a single, hardcoded accuracy-latency trade-off point. If deployment constraints or user preferences change, the entire system must be retrained or re-optimized. Furthermore, exhaustively testing every combination end-to-end to find the best setup is computationally impossible, often spanning millions or billions of potential configurations.

Methods

FlowCompile addresses this by drawing inspiration from traditional machine learning compilers (like TVM or XLA), decoupling the workflow graph into modular components to perform a single, efficient compile-time search.

Figure 1: Overview of FlowCompile. (a) FlowCompile treats structured LLM workflow optimization as compilation: given a problem set, an input workflow, and a design space, it outputs a compiled set of optimized configurations spanning low-latency to high-accuracy deployment regimes. (b) FlowCompile compiles the workflow through three stages: sub-agent profiling and cost modeling, structure-aware compositional estimation of workflow-level accuracy and latency, and design-space exploration to identify configurations spanning the accuracy–latency trade-off frontier.

The compilation pipeline operates in three distinct stages:

  1. Sub-Agent Data Induction and Profiling: The workflow is initially run on a validation dataset using a high-capacity reference model (e.g., GPT-5) to collect execution traces. An LLM-as-a-judge filters out successful steps to create pseudo-ground truth datasets for each sub-agent. FlowCompile then profiles each sub-agent in isolation across candidate models and reasoning token budgets to build a component-level cost model.
  2. Workflow-Level Performance Proxy: Instead of executing full workflows during the design search, FlowCompile uses a lightweight, training-free analytical proxy. It composes the isolated sub-agent profiles using probabilistic and expected-value formulas mapped directly to the workflow's control-flow semantics (e.g., multiplying accuracies for sequential steps, or applying disjunctive rules for parallel branches).
  3. Design Space Exploration: The compiler applies Pareto pre-filtering at the sub-agent level to prune away dominated configurations. It then runs a fast numerical non-dominated sorting algorithm over the remaining workflow configurations to output a global Pareto frontier of optimized configurations.

Datasets

The authors evaluated FlowCompile across four public benchmarks spanning three distinct domains:

  • GSM8K & MATH-500: Mathematical reasoning tasks.
  • HotpotQA: Multi-hop question answering.
  • LiveCodeBench: Code generation and reasoning.

For each benchmark, the data was split into a 20% profiling set (used exclusively for compile-time data induction and baseline training) and an 80% held-out test set for final evaluation.

Key Insights and Ideas

  • Decoupling Bypasses Combinatorial Explosion: The core "aha moment" is that you don't need to test full workflows to optimize them. Expensive model inference can be restricted to the linear sub-agent level, while workflow-level performance can be accurately estimated via lightweight mathematical composition.
  • Rank Preservation Over Absolute Accuracy: The analytical proxy does not need to perfectly predict absolute accuracy or latency numbers. For successful optimization, it only needs to satisfy frontier consistency (ensuring non-dominated configurations remain non-dominated) and local order preservation (preserving relative rankings near the frontier).
  • Compilation Enables Reusable Artifacts: Generating a global Pareto frontier at compile-time provides ultimate deployment flexibility. The resulting configuration set serves as a reusable menu; developers can instantly swap configurations statically based on changing hardware budgets, or use the pruned frontier as a highly optimized candidate pool for downstream per-query routers.

Key Results

FlowCompile consistently outperformed heuristically optimized fixed workflows and dynamic routing baselines across all tasks.

Figure 3: Empirical accuracy–latency trade- offs. FlowCompile produces configurations with substantially better measured accuracy–latency trade-offs than baselines.
  • Substantial Speedups: On LiveCodeBench, FlowCompile delivered up to a 6.4× speedup while maintaining strong task performance. Across all benchmarks, its latency-priority configurations achieved an average 12.7× speedup with highly competitive accuracy.
  • Complementary to Routing: When paired with a simple downstream KNN router, FlowCompile achieved an additional boost in expected utility (+2.6 on GSM8K and +6.3 on MATH-500), proving that compile-time optimization provides an excellent foundation for runtime adaptation.

Limitations and Future Work

FlowCompile is strictly designed for structured LLM workflows with predefined execution graphs and sub-agent interfaces. It cannot be directly applied to open-ended, fully dynamic agentic systems (such as ReAct-style agents) where execution traces are generated entirely on the fly at inference time.

Additionally, the analytical proxy assumes sub-agents operate relatively independently. It does not explicitly model complex inter-agent distribution shifts—such as how a lower-quality, lower-latency output from an upstream agent might negatively impact the performance profile of a downstream agent. The authors note that explicitly modeling these downstream distribution shifts is a promising direction for extending the compiler's accuracy to even more complex workflows.

Summary updated

BibTeX
@misc{li2026flowcompile,
  author = {Junyan Li and Zhang-Wei Hong and Maohao Shen and Yang Zhang and Chuang Gan},
  title = {{FlowCompile: An Optimizing Compiler for Structured LLM Workflows}},
  year = {2026},
  eprint = {2605.13647},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.13647},
}
Figure