π Agentic Auto-Scheduling: COMPILOT Framework
Massinissa Merouani, Islem Kara Bernou, Riyadh Baghdadi (NYU Abu Dhabi)
2025 PACT Conference
Paper: https://arxiv.org/abs/2511.00592
Core Insight
Traditional compilers optimize via static heuristics or cost models. COMPILOT inverts this: the LLM acts as an agent inside the compiler, iteratively proposing loop transformations and receiving empirical feedback (speedup or failure reason) from the actual execution environment.
Result: off-the-shelf LLMs discover high-performance schedules without fine-tuning, outperforming the Pluto polyhedral optimizer on many benchmarks by leveraging measured performance rather than analytical proxies.
Architecture
Two-Phase Dialogue
Phase 1: Context Initialization
- Context prompt: task definition, I/O formats, transformation primitives, hardware specs
- Target loop nest: anonymized C/C++ code with comp_IDs for each computation block
- Program analysis: LLM deconstructs structure, infers optimizations, explains strategy (chain-of-thought)
Phase 2: Iterative Optimization
- Loop: LLM β proposes schedule | Compiler β tests legality & measures speedup | LLM β refines
- Stops when LLM declares
no_further_transformationsOR iteration limit reached - Multi-run (best-of-K) strategy mitigates LLM stochasticity & local optima
Transformation Primitives
Nine loop transformations (via Tiramisu compiler API):
| Transformation | Syntax Example | Use Case |
|---|---|---|
| Fusion | comp01.Fuse(comp02, L2) | Reduce memory traffic |
| Interchange | comp00.Interchange(L0, L1) | Enable parallelism or improve cache |
| Parallelization | comp00.Parallelize(L0) | Thread-level parallelism |
| 2D Tiling | comp01.Tile2D(L1, L2, 32, 32) | Cache blocking |
| 3D Tiling | comp01.Tile3D(L0, L1, L2, 16, 16, 8) | Multi-level blocking |
| Unrolling | comp00.Unroll(L3, 4) | Reduce loop overhead |
| Skewing | comp00.Skew(L1, L2) | Enable parallelism via dependency reordering |
| Reversal | comp00.Reverse(L1) | Dependency direction flip |
| Shifting | (handled automatically in Tiramisu) | Dependency-preserving loop shifts |
Feedback Loop
When LLM proposes a schedule:
- Validity check (lightweight, compiler-independent): syntax, identifiers, preconditions (e.g., perfect nesting for interchange)
- Legality check (formal polyhedral dependence analysis): does the schedule preserve semantics?
- Execution (if legal): compile, run, measure speedup
- Feedback types:
- Invalid: specific syntax error
- Illegal: data-dependency violation
- Solver failure: skewing/shifting factors canβt be computed
- Compiler crash: transformation combination failed
- Successful: speedup ratio (or slowdown if negative)
LLM in-context learns from this feedback to refine strategy across iterations.
Evaluation: PolyBench Suite (150 instances, 30 benchmarks Γ 5 sizes)
Main Results (40 runs per instance, T=30 iterations)
Single-Run (COMPILOT@30)
- Geometric mean: 2.66Γ speedup vs original
- 95% CI: [2.60, 2.77]
- 50th percentile: β₯1.24Γ
- 25th percentile: β₯3.6Γ
- 10th percentile: β₯23.65Γ
- Examples: correlation_XLARGE: 339Γ; trmm_XLARGE: 183Γ; seidel2d_SMALL: 2.41Γ
Multi-Run (COMPILOTβ @30, best-of-5)
- Geometric mean: 3.54Γ speedup vs original
- 95% CI: [3.45, 3.58]
- 50th percentile: β₯1.59Γ
- 10th percentile: β₯53.65Γ
vs State-of-the-Art Competitors
| Baseline | Speedup (COMPILOTβ @30) | Notes |
|---|---|---|
| Original unoptimized code | 3.54Γ | Geometric mean across 150 instances |
| Pluto polyhedral optimizer | 2.94Γ | Outperforms on 119/150 instances; Pluto wins on 22 (cholesky, ludcmp, lu, nussinov) |
| Tiramisu autoscheduler | 3.23Γ | (8 supported benchmarks only) |
COMPILOTβs advantage over Pluto:
- Avoids performance regressions (COMPILOT β always safeguards, Pluto sometimes applies detrimental heuristics)
- Adapts to input size (aggressive parallelization for large; tiling for small)
- Uses empirical feedback vs proxy cost model
Exploration Efficiency
Token usage grows non-linearly (context inflation). Wall-clock time β 8.9 min/benchmark (30 iter), 78.5% spent in compiler infrastructure, only 1β3 min in LLM communication.
Schedule Validity
At T=30, across all runs and benchmarks:
- 36.1% runnable (valid, legal, executes successfully)
- 31.4% invalid (syntactically/semantically flawed)
- 32.5% illegal (violates data dependencies)
β ~2/3 of LLM proposals are unproductive attempts; legality decreases early (60% at T=1) but improves over dialogue as LLM learns.
Ablation Studies
| Question | Finding | Impact |
|---|---|---|
| RQ6: Is feedback important? | With feedback: 2.66Γ; without: 2.01Γ | β23% speedup without feedback; LLM canβt learn from environment |
| RQ7: Direct code generation vs API? | Code generation: β14β16% speedup; 17.9% legal failures on re-run | Delegation to compiler + formal verification is critical |
| RQ8: Hardware context in prompt? | No statistically significant difference | LLM may rely more on empirical feedback loop than explicit specs |
| RQ10: Chain-of-thought? | Initial program analysis: +8%; explicit reasoning: +4β14% | Both beneficial, especially for multi-run scenarios |
| RQ11: Pushing LLM past early quits | Comparable to @30 only after 5+ quit attempts | Essential to override conservatism, but diminishing returns after N=5 |
Key Design Decisions
β Strengths
- LLM as agent, not code generator β offloads complexity/correctness to compiler; avoids output-comparison brittleness
- Empirical feedback β speedup measured on target hardware beats analytical cost models
- Multi-run diversity β stochastic LLM exploration + best-of-K strategy escapes local optima
- Chain-of-thought β initial analysis + per-iteration reasoning improves strategy coherence
β Challenges
- High invalid/illegal rate (~64% of proposals fail) β inefficient exploration
- Premature stopping: LLM conservatism or local optima pessimism
- Hardware context insufficient: LLMs donβt translate cache/core info into tile-size decisions
- Context bloat: non-linear token growth; ~100β200k tokens for 30 iterations
Related Work
Compares to:
- Domain-specialized LLMs (Meta LLM Compiler, etc.) β require fine-tuning; slower throughput
- Direct code generation (LLM-Vectorizer, CompilerGPT) β correctness relies on unit tests or formal verification; both imperfect
- Classical polyhedral optimizers (Pluto, Halide, TVM) β rigid heuristics; no adaptation to hardware or input scale
COMPILOTβs novelty: off-the-shelf + feedback-driven + source-level transformations (not IR passes or direct codegen).
Takeaways
π Off-the-shelf LLMs can effectively optimize complex code when embedded in an interactive compiler environment with empirical feedback.
π Feedback loop > reasoning capabilities β even without explicit reasoning models, the iterative loop + in-context learning provides sufficient guidance.
π Formal verification beats output comparison β delegating legality checks to polyhedral analysis ensures code correctness without expensive re-execution tricks.
π Stochasticity is a feature β multiple runs exploit the LLMβs exploration diversity to escape local optima.
Future Directions
- Richer feedback (cache misses, vector lane utilization via performance counters, not just wall-clock)
- Hybrid search (LLM + systematic algorithms) to escape local optima faster
- Dialogue summarization (context compression) to reduce token blowup
- Extend transformation primitives (loop distribution, computation reordering)
Links
- arXiv: https://arxiv.org/abs/2511.00592
- Tiramisu Compiler: https://tiramisu.csail.mit.edu/
- PolyBench Suite: http://www.cse.ohio-state.edu/~pouchet/software/polybench/
- PACT 2025: 34th International Conference on Parallel Architectures and Compilation Techniques
Related Notes
- Harness Engineering β agent environment design
- Context Engineering β LLM interaction design patterns
- Loop Engineering β cost/reliability tradeoffs in iterative workflows
- Token Optimization for Claude Code β managing LLM interaction costs
- Self-Improving Company β using AI to optimize business processes
- Agentic Engineering β paradigm shift from manual to agent-driven systems