Skip to content
AI.info

Research

Small Language Models as Compiler Experts: Auto-Parallelization for Heterogeneous Systems

Overview Research area: Machine learning for systems / compiler optimization — specifically using small language models (≤1B parameters) to drive automatic parallelization of C/C++ code for heterogene

Small Language Models as Compiler Experts: Auto-Parallelization for Heterogeneous Systems
arXiv
2512.19250
Published
2025-12-22
Authors
Prathamesh Devadiga

AI summary

Overview

Research area: Machine learning for systems / compiler optimization — specifically using small language models (≤1B parameters) to drive automatic parallelization of C/C++ code for heterogeneous hardware.

Technical level: Intermediate. The paper is written in accessible prose with clear tables, but readers will benefit from some familiarity with compilers, parallel programming (OpenMP-style pragmas), and speedup/benchmarking conventions.

One-sentence scope: A comprehensive evaluation of three small language models guided by six prompting strategies across 11 kernels and 376 total tests, benchmarked against LLVM Polly, TVM, Triton, GCC, Intel ICC, and Halide.

What This Paper Is About

Traditional auto-parallelizing compilers rely on rigid heuristics and conservative static analysis, which struggle with the complexity of modern heterogeneous systems (CPUs, GPUs, accelerators). Most prior "AI for Systems" work uses massive proprietary models whose latency and cost are prohibitive to embed directly in a compiler. This paper asks whether small, efficient LLMs (≤1B parameters) can supply the reasoning needed to analyze and parallelize real code — and answers affirmatively, reporting an average speedup of 6.81x and a peak of 43.25x on convolution operations.

Key Contributions

  1. Real-world application support: Evaluation across 11 kernels drawn from scientific computing, graph algorithms, and machine learning.
  2. Advanced baseline comparison: Rigorous benchmarking against LLVM Polly, TVM, Triton, GCC Advanced (-O3), Intel ICC, and Halide.
  3. Scalability analysis: Performance measured across varying input sizes (1K×1K through 16K×16K matrix multiplication) and CPU core counts (1 to 16 cores).
  4. Correctness and robustness verification: A methodology combining regression testing, sanitizers, and cross-platform compiler/hardware validation.

Main Findings

  • Small models are competitive: Across 376 total evaluations, the LLM-driven approach achieved an average speedup of 6.81x, with a peak of 43.25x on convolution operations. Speedups are measured relative to optimized single-threaded CPU baselines compiled with -O3.
  • qwen2.5 was the strongest model: qwen2.5:1.5b reached 7.2x average and 43.25x best speedup with an analysis quality of 0.85 and 18.9s response time, versus gemma3:1b (6.2x average, 38.7x best, 0.78 quality, 12.3s) and llama3.2:1b (6.8x average, 41.2x best, 0.82 quality, 15.7s).
  • Tree of Thoughts is the best prompting strategy: ToT averaged 7.1x with an 88% success rate and 0.84 quality score, best on Matrix Multiplication (39.8x). It beat Chain of Thought (6.9x, 85%, FFT 38.4x), ReAct (6.7x, 83%, Jacobi 35.2x), Few-shot (6.6x, 82%, Attention 36.9x), Step-by-Step (6.4x, 80%, BFS 33.7x), and Zero-shot (5.8x, 78%, Convolution 32.1x).
  • Reasoning strategy matters more than model scale: The authors state this explicitly as the paper's key insight.
  • Mixed results against specialized compilers: LLM (qwen2.5 + ToT) averaged 7.1x, ahead of LLVM Polly (5.8x), GCC Advanced (5.2x), Intel ICC (6.1x), and Halide (6.8x), but behind TVM (7.4x) and Triton (8.9x). Triton achieved higher peak performance on Attention (13.7x) versus the LLM's best of 43.25x on Convolution; the authors frame this as the LLM being more versatile across domains rather than deeper on any single target.
  • Compilation latency is the trade-off: The LLM averaged 15.6s compilation time versus 2.1s for traditional baselines (+643%), with 1.2GB memory usage versus 0.9GB (+33%).
  • Scalability holds: On matrix multiplication, LLM speedups rose from 4.2x (1K×1K) to 13.1x (16K×16K), consistently ahead of LLVM Polly (3.8x to 12.7x), GCC (3.5x to 12.0x), and Intel ICC (4.1x to 12.8x). Multi-core efficiency (16 cores) was 71% for the LLM versus 68% Polly, 65% GCC, and 70% ICC.
  • Correctness is high but below traditional compilers: LLM with Tree of Thoughts reached 88% verification, 91% race-free, 94% memory-safe, and 85% sanitizer pass rates. LLVM Polly reached 95% verification, 97% race-free, 98% memory-safe, 93% sanitizer pass. All incorrect transformations are automatically detected and rejected, so unsafe parallel code is never emitted in deployed settings.
  • Per-kernel gains vary widely: Convolution 2D 12.4x (vs 9.8x traditional), Attention 8.7x (vs 6.9x), Matrix Multiplication 7.2x (vs 6.1x), FFT 1D 6.8x (vs 5.2x), Pooling 6.2x (vs 5.1x), Jacobi 5.9x (vs 4.8x), PageRank 5.3x (vs 4.1x), BFS 4.1x (vs 3.2x), Shortest Path 3.8x (vs 2.9x). The paper states 11 kernels; Table 1 names nine of them.
  • Portable output: Generated code succeeded on GCC 11+ (98%), Clang 14+ (96%), Intel ICC 2021+ (94%), and MSVC 2019+ (89%). Hardware backend performance relative to traditional-specific tools ranged from 85–95% (NVIDIA GPUs), 80–90% (AMD GPUs), 90–100% (multi-core CPUs), and 85–95% (ARM processors).
  • Analysis quality is a stated weakness: The LLM's 0.82 average analysis quality trails the traditional baselines' 1.00 (-18%), which the authors attribute to the transparency of the model's reasoning.

Methodology in Plain English

The system is a three-stage pipeline. First, a Code Analyzer performs static analysis on the source. Second, an LLM Reasoner receives an abstracted representation of loop nests, memory access patterns, and control flow, and is prompted to produce a structured parallelization plan — explicitly identifying loop-carried dependencies that block safe parallel execution, reduction patterns (summations, minima/maxima) that can be rewritten with reduction clauses, variables that must be privatized to avoid data races, and target-specific strategies such as CPU thread-level parallelism or GPU kernel decomposition. Third, a Parallelization Generator turns the plan into code.

Crucially, the model is not used as a black-box code generator. Every plan is validated by a static analyzer before code generation, and unsafe transformations are rejected automatically through sanitizer-based validation and regression testing. The three models — gemma3:1b, llama3.2:1b, and qwen2.5:1.5b — were each paired with six prompting strategies (Zero-shot, Chain of Thought, Tree of Thoughts, ReAct, Step-by-Step, Few-shot) and run across the kernel suite, yielding 376 total evaluations.

Why This Matters

Impact on research: The paper challenges the assumption that only massive proprietary models can perform sophisticated compiler reasoning. It positions prompting strategy (Tree of Thoughts exploring multiple reasoning paths) as a more important lever than parameter count, and it provides a reusable safety pattern — LLM proposes, static analyzer and sanitizers dispose — for combining learned flexibility with compiler-grade guarantees.

Real-world applications:

  • Legacy code modernization: Parallelizing existing C/C++ scientific or systems code without a human expert hand-writing OpenMP pragmas.
  • Machine learning kernel optimization: The convolution, attention, and pooling kernels evaluated here map directly onto deep learning workloads.
  • Scientific computing: FFT, Jacobi solvers, and matrix multiplication are core numerical routines in simulation and HPC.
  • On-device or resource-constrained toolchains: Because the models are ≤1B parameters, they are candidates for deployment where a large proprietary model's cost and latency are impractical.

Industry relevance: Compiler and toolchain vendors, hardware vendors selling heterogeneous accelerators, and HPC teams all face the same problem — automatic parallelization has plateaued. The reported trade-off is instructive: the LLM produces better average parallelization than several production compilers but at roughly 7x the compilation time (15.6s versus 2.1s), which the authors judge acceptable for offline optimization but not for just-in-time compilation.

Future Directions

  1. Improving correctness: Reaching above 95% verification success rates via verifier-in-the-loop feedback.
  2. Reducing latency: Lowering response times to under 10 seconds for seamless compiler integration.
  3. Expanding hardware support: Adding TPUs and FPGAs to the current CPU/GPU backends.
  4. Multi-language support: Extending beyond C/C++ to Python, Julia, and Rust.

The paper also flags open limitations: a non-trivial fraction of generated parallelizations fail correctness checks and must be discarded; effectiveness depends on prompt quality and abstraction design, which currently require expert tuning; and the evaluation covers representative kernels rather than full-scale applications, so results may differ on large, highly irregular real-world codebases.

Target Audience

Compiler engineers and systems researchers evaluating LLM-assisted program optimization; machine learning researchers interested in the "AI for Systems" agenda; performance engineers working with heterogeneous CPU/GPU/accelerator targets; and students or practitioners looking for a concrete, reproducible case study in applying small language models to a domain task rather than general code generation. The authors state that all code, prompts, and evaluation scripts will be released as open-source artifacts upon publication.

Authors’ abstract

Traditional auto-parallelizing compilers, reliant on rigid heuristics, struggle with the complexity of modern heterogeneous systems. This paper presents a comprehensive evaluation of small (approximately 1B parameter) language-model-driven compiler auto-parallelization. We evaluate three models: gemma3, llama3.2, and qwen2.5, using six reasoning strategies across 11 real-world kernels drawn from scientific computing, graph algorithms, and machine learning. Our system is benchmarked against strong compiler baselines, including LLVM Polly, TVM, and Triton. Across 376 total evaluations, the proposed approach achieves an average speedup of 6.81x and a peak performance of 43.25x on convolution operations. We analyze scalability, verify correctness using multiple sanitizers, and confirm robustness across diverse compilers and hardware platforms. Our results demonstrate that small, efficient language models can serve as powerful reasoning engines for complex compiler optimization tasks.

Read the original paper