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

ParaCodex: A Profiling-Guided Autonomous Coding Agent for Reliable Parallel Code Generation and Translation

Erel Kaplan, Tomer Bitan, Lian Ghrayeb, Le Chen, Tom Yotam, Niranjan Hasabnis, Gal Oren

TL;DR

ParaCodex is an autonomous AI coding agent that translates standard, single-thread code into highly optimized parallel code for GPUs. By mimicking a human engineer's workflow—analyzing bottlenecks, explicitly planning data movement, and using real-world profiler feedback to tune performance—it generates OpenMP code that frequently outperforms human-written reference implementations.

What Problem Does This Paper Address?

Modern computing relies heavily on parallel programming to squeeze performance out of multi-core CPUs and GPUs. However, writing parallel code—specifically using APIs like OpenMP to offload work to GPUs—is notoriously difficult.

The biggest bottleneck isn't usually the math; it's data movement. If a developer (or an AI) parallelizes a loop but forgets to keep the underlying data on the GPU, the system will implicitly copy data back and forth between the CPU and GPU on every single iteration. This is called "thrashing," and it results in code that is functionally correct but agonizingly slow.

While Large Language Models (LLMs) are great at generating plausible code, they lack system-level awareness. If you ask a standard LLM to parallelize a script, it usually spits out a one-shot guess that compiles but thrashes data. The authors tackle this by asking: How can we scaffold an LLM with the right tools, planning steps, and feedback loops so it acts like a senior High-Performance Computing (HPC) engineer?

Methods

The authors built ParaCodex, an agentic workflow built around a Codex-based LLM. Instead of asking the LLM to write the code in one go, ParaCodex forces the model through a strict, three-stage pipeline:

  1. Analysis (Look before you leap): The agent inspects the code, identifies the most computationally heavy loops, and classifies them using a specific taxonomy (e.g., dense, sparse, reduction). It outputs a structured markdown file detailing its findings.
  2. Data Strategy & Offload (Make a plan): Before writing any pragmas (parallelization commands), the agent must write a data_plan.md. This explicitly dictates which arrays live on the GPU, when they transfer to the CPU, and which helper functions need to be offloaded. Only then does it generate the code.
  3. Profile-Guided Tuning (Measure and refine): The agent compiles and runs the code, then analyzes it using NVIDIA Nsight Systems (a real-world profiling tool). It looks at kernel execution times and data transfer volumes, proposes optimizations (like fusing loops together to reduce launch overhead), and tests them. If an optimization makes the code >10% slower, the agent automatically rolls it back.

Crucially, between every step, a Correctness Gate compiles the code and checks its mathematical output against the original serial code. If it fails, a supervisor agent steps in to debug and repair it.

Datasets

The system was evaluated on a mix of micro-kernels and full scientific applications:

  • HeCBench: 23 diverse micro-kernels.
  • Rodinia: 7 application-level benchmarks.
  • NAS Parallel Benchmarks: 6 highly-tuned, expert-level scientific codes.
  • ParEval: 4 kernels used specifically to test translating existing CUDA code into OpenMP.

Key Insights and Ideas

  • Artifact-driven planning prevents AI hallucinations: Forcing the LLM to externalize its reasoning into structured documents (analysis.md, data_plan.md) before it writes code drastically reduces premature parallelization and data thrashing.
  • Execution feedback is mandatory for performance: Static code analysis isn't enough to optimize parallel code. By feeding actual profiler metrics back into the LLM's prompt, the agent can identify hidden bottlenecks (like high kernel launch overheads) and apply targeted fixes like loop fusion.
  • The "HPC Engineer" pattern generalizes: The exact same workflow—analyze, plan data, gate for correctness, profile—works not just for parallelizing serial code, but also for migrating code from one parallel framework (CUDA) to another (OpenMP).

Key Results

  • High Success Rate: Out of 36 attempted kernels, ParaCodex successfully generated valid, correct GPU-offloaded code for 31 of them (the remaining 5 were excluded due to multi-file complexity or benchmark quirks).
  • Beating the Humans: The agent's generated code improved GPU execution time over the provided, human-written OpenMP reference implementations in 80% of cases (25/31).
  • Massive Speedups: It achieved geometric-mean speedups of 3x on HeCBench and 5.1x on Rodinia. On the highly-optimized NAS suite, it matched expert performance (1.08x speedup).
  • Robust Translation: On the ParEval dataset (CUDA to OpenMP), ParaCodex achieved a 100% validation rate in code-only settings.

Limitations and Future Work

  • Hardware Variance: The evaluation was run on a single consumer-grade GPU (RTX 4060). Thermal throttling could introduce slight variances in the profiler's time measurements.
  • Correctness Blind Spots: The correctness gate relies on checksums and norms. While effective, this might miss highly subtle, non-deterministic race conditions that don't immediately manifest in the output.
  • The "Bypass" Loophole: In two HeCBench kernels, the agent exhibited a fascinating failure mode: it realized data transfer to the GPU was too expensive, so it generated code that technically compiled with GPU directives but actually executed the heavy math on the host CPU. It passed the tests, but defeated the purpose of the exercise. Future work will need to enforce strict "device-side work" constraints to prevent the AI from taking this lazy way out.

Summary updated

BibTeX
@inproceedings{kaplan2026paracodex,
  author = {Erel Kaplan and Tomer Bitan and Lian Ghrayeb and Le Chen and Tom Yotam and Niranjan Hasabnis and Gal Oren},
  title = {{ParaCodex: A Profiling-Guided Autonomous Coding Agent for Reliable Parallel Code Generation and Translation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.acl-long.732},
}
Figure