MetaFORGE: A Meta-Learning Framework for Harness Optimization in Automated Code Generation for Parallel Computing

Scott Piersall, Yang Gao, Shenyang Liu, Liqiang WangarXiv 2026

TL;DR

Writing parallel code is notoriously unforgiving: a program can compile cleanly and pass every unit test, yet still crawl at a snail's pace due to communication bottlenecks or uneven workloads across processors. Instead of just nudging an LLM to patch broken code one program at a time, MetaFORGE uses real-world execution profiling to iteratively rewrite the instructions that guide the LLM—and banks those hard-won optimization lessons in long-term memory. The result is an automated harness that learns how to write faster, cleaner, and better-balanced parallel C code across entirely different tasks without touching a single model weight.

What Problem Does This Paper Address?

Asking an LLM to generate standard sequential code is old news; asking it to write distributed-memory parallel code using MPI (Message Passing Interface, the workhorse standard of supercomputing) is a minefield. In MPI, independent processes coordinate by explicitly passing messages. A slight miscalculation in data decomposition or synchronization doesn't just look messy—it causes deadlocks or silent performance killers like load imbalance, where three processors sit idle waiting for one overworked straggler to finish.

Existing iterative LLM frameworks usually stop once the code compiles and passes functional unit tests. They rarely look at compiler warnings, static analysis, or per-processor profiling—signals that only emerge when code actually runs at scale. Worse, standard coding agents suffer from amnesia: once they finish optimizing a task, they throw away the playbook and start from scratch on the next one.

Methods

Rather than treating the generated C code as the final target of optimization, MetaFORGE treats the skill specification—the persistent natural-language prompt conditioning the generator—as a policy to be trained.

Figure 1: MetaFORGE: An automated meta-learning skill-refinement architecture. MetaFORGE optimizes LLM coding skills through execution-grounded feedback. Generated MPI C code is compiled, statically analyzed, executed, and scored using Eq. (1). Diagnostics and reward trends are converted into a textual gradient for skill- prompt rewriting, while iteration artifacts are stored, distilled, indexed, and retrieved as long-term memory, enabling future updates to reuse prior reward-improving strategies.

The framework operates via two coupled loops:

  • Execution-Grounded Evaluation: Every candidate MPI program is compiled, statically analyzed, tested for correctness, and executed 20 times externally across four MPI processes. The harness combines compiler warnings, static-analysis warnings, end-to-end runtime, per-process load imbalance, and a massive penalty for incorrect outputs into a single scalar reward. (Measuring timing externally prevents the LLM from cheekily rigging its own stopwatch.)
  • Two-Stage Textual Gradient Refinement: Standard prompt optimizers often blur diagnosis and editing together. MetaFORGE deliberately splits them into two LLM calls. First, a diagnostic step compares current metrics against the best run so far to produce a textual gradient—an explicit natural-language critique targeting the worst bottlenecks. Second, a rewriter applies that critique to update the persistent skill prompt while leaving unrelated instructions intact.
  • Persistent Cross-Task Memory: While the skill captures broad coding habits, an external memory store captures specific tactics. After a run finishes, MetaFORGE compresses reward-improving episodes into concise lessons indexed by MPI constructs, parallel patterns, and performance symptoms—retrieving them as advisory context for future tasks.

Datasets

Rather than training or evaluating on a static text dataset, the authors built a criterion-driven suite of six MPI C programming tasks, each tested at small, medium, and large workload sizes on a four-node OpenMPI cluster:

  1. $\pi$ Calculation and Dot Product (terminal reductions stressing floating-point throughput vs. memory bandwidth)
  2. Matrix Multiplication (cache locality and collective communication)
  3. Mandelbrot Set (data-dependent load imbalance)
  4. Heat Transfer (repeated point-to-point halo exchanges)
  5. Distributed PCA (repeated collectives)

Key Insights and Ideas

  • Optimize the chef's recipe, not just the dish: Refining the persistent skill prompt and distilling execution trajectories into an external database creates inspectable meta-learning. In leave-one-task-out tests, transferring a learned skill and read-only memory to an unseen task boosted performance immediately—even with zero task-specific updates.
  • It’s the harness, not just a smarter critic: You might suspect MetaFORGE beats baselines simply because it uses a stronger reasoning model to critique the code. Yet in a head-to-head ablation where MetaFORGE's refiner was downgraded to gpt-4o (matching the native TextGrad baseline), MetaFORGE still significantly outperformed TextGrad. Feeding structured, domain-aware execution metrics into a separated diagnose-then-rewrite pipeline matters more than raw refiner horsepower.
  • Memory pays rent without bloating prompts: Adding retrieved optimization lessons improved runtime across all 18 task–workload configurations while actually reducing average per-iteration token usage by 1.8%.

Key Results

Evaluated across five independent trials per workload using gpt-5.1-codex-max, MetaFORGE beat zero-shot generation across the board and outperformed the iterative TextGrad baseline on all 18 task-average outcome comparisons (and 52 of 54 individual workload comparisons).

Table 1: Task-average results over 15 trials per row (three workloads and five trials per workload). Static-analysis, runtime, and load-balance values are percentage improvements over zero-shot Codex; higher is better. Tokens are mean per-iteration consumption; lower is better. Bold indicates the better value within each method pair.

Some standout gains over zero-shot baselines:

  • Runtime speedups: Massive average runtime improvements on Matrix Multiplication (87.99% vs. TextGrad's 55.46%), Distributed PCA (86.36% vs. 31.75%), and Heat Transfer (82.46% vs. 14.87%).
  • Load balance & code quality: Achieved 100% elimination of static-analysis warnings on $\pi$ Calculation and Dot Product, alongside a 96.41% load-balance improvement on $\pi$ Calculation.
  • Retrieval impact: Enabling cross-task memory jumped mean runtime improvement across all 18 configurations from 35.99% to 51.59%, and static-analysis improvement from 63.34% to 82.19%.

Limitations and Future Work

The authors are admirably candid about the boundaries of their setup:

  • Bounded scope and scale: Testing was restricted to six structured MPI C tasks running at a fixed count of four processes. Irregular graph algorithms, sparse matrices, unstructured meshes, and massive node counts remain untested.
  • Unnormalized rewards: The scalar reward uses fixed weights. Because raw runtime scales vary wildly between tasks, reward magnitudes aren't directly comparable across tasks, which can slightly skew how cross-task memories are ranked during retrieval.
  • API shifting sands: Reliance on closed-source commercial APIs bit the researchers mid-study when OpenAI deprecated gpt-5.1-codex-max, forcing later sensitivity and transfer experiments onto gpt-5.3-codex.

Looking ahead, the team plans to expand MetaFORGE to GPU and shared-memory paradigms (CUDA, OpenMP, SYCL, and hybrid MPI+X), introduce task-normalized retrieval scoring, and automate the tuning of reward weights.

Summary updated

Abstract

Large language models (LLMs) can generate parallel programs, but their correctness and performance depend strongly on the instructions that guide generation. We present \textsc{MetaFORGE}, an execution-grounded meta-learning framework that iteratively optimizes persistent natural-language skill specifications for MPI C code generation. \textsc{MetaFORGE} combines correctness testing, compiler diagnostics, static-analysis findings, runtime measurements, and rank-level load-imbalance profiles into a scalar reward that drives textual-gradient refinement, while an external memory distills and retrieves reward-supported optimization knowledge across runs. Across six MPI tasks and three workload sizes, \textsc{MetaFORGE} improves static-analysis quality, runtime, and load balance relative to zero-shot generation and generally exceeds the evaluated \textsc{TextGrad} iterative baseline. A model-matched refinement ablation shows that the MetaFORGE advantage persists when its refinement model is reduced to \texttt{gpt-4o}. An expanded retrieval ablation across all 18 task--workload configurations shows consistent runtime benefit and broad static-analysis and load-balance benefit from retrieved context. Leakage-controlled held-out and zero-update experiments further provide evidence that optimization knowledge persists in both the transferred skill and external memory under the evaluated protocol.
BibTeX
@misc{piersall2026metaforge,
  author = {Scott Piersall and Yang Gao and Shenyang Liu and Liqiang Wang},
  title = {{MetaFORGE: A Meta-Learning Framework for Harness Optimization in Automated Code Generation for Parallel Computing}},
  year = {2026},
  eprint = {2611.33119},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.33119},
}
Figure