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

GPU Kernel Scientist: An LLM-Driven Framework for Iterative Kernel Optimization

Martin Andrews, Sam Witteveen

TL;DR

Optimizing low-level GPU code usually requires deep hardware expertise, high-end profilers, and endless manual tweaking—especially on non-CUDA architectures with sparse documentation. This paper presents GPU Kernel Scientist, an automated evolutionary framework powered by Gemini 2.5 models that iteratively discovers, writes, and refines AMD HIP kernels using nothing more than end-to-end timing numbers. Operating without profiling tools or local hardware access, the system cut execution time from $\sim$5000 µs (naïve HIP) down to $\sim$450 µs, comfortably beating an optimized PyTorch baseline ($\sim$850 µs).

What Problem Does This Paper Address?

Writing high-performance GPU kernels for Nvidia hardware is hard enough, but doing so for alternative accelerators—such as AMD's MI300—is significantly tougher due to sparse documentation, scarce open-source code examples, and immature tooling. Most existing automated agent frameworks (like AI CUDA Engineer) focus on Nvidia GPUs with rich profiling tools and massive corpora of existing code.

The authors asked: Can an LLM agent autonomously optimize a complex accelerator kernel on unfamiliar hardware when human developers have limited domain expertise, no access to hardware profilers, and only black-box execution times as feedback?

Methods

The framework structures kernel optimization as an evolutionary discovery loop driven by two Gemini models (Gemini 2.5 Flash and Pro), structured across three key stages:

  1. Evolutionary Selector (Gemini 2.5 Flash): Rather than using simple fitness-proportionate selection, the LLM analyzes a population of past kernels, their parent-child lineage, and benchmark scores across matrix shapes. It selects a Base kernel to mutate and a divergent Reference kernel to provide context on previous trade-offs.
  2. Experiment Designer (Gemini 2.5 Flash): Brainstorms 10 architectural "avenues" of research, then drafts 5 structured experiment rubrics with predicted performance gains and "innovation" scores. The framework selects the top three candidates based on distinct criteria: most innovative, highest maximum potential, and safest minimum gain.
  3. Kernel Writer (Gemini 2.5 Pro): Implements code modifications as diffs against the Base kernel. It is supplied with problem specs, human-in-the-loop bootstrapped hardware notes, the Reference kernel, and the experiment rubric to produce complete, syntactically correct HIP kernels ready for PyTorch binding.
  4. Closed-Loop Testing & Evaluation: Submits kernels to an automated evaluation runner. If compilation or numerical correctness fails, errors bounce back to the Kernel Writer. Successful kernels are timed across 18 benchmark configurations and added back to the evolutionary population.
       ┌────────────────────────┐
       │ Benchmarks & Ancestry  │
       └───────────┬────────────┘
                   ▼
       ┌────────────────────────┐
       │  Evolutionary Selector │ (Flash)
       └───────────┬────────────┘
                   ▼
       ┌────────────────────────┐
       │   Experiment Designer  │ (Flash)
       └───────────┬────────────┘
                   ▼
       ┌────────────────────────┐
       │      Kernel Writer     │ (Pro)
       └───────────┬────────────┘
                   ▼
       ┌────────────────────────┐
       │ Benchmarking Platform  │ ──(Feedback: Times / Errors)──► [Loop]
       └────────────────────────┘

Datasets

The framework was evaluated on the problem suite from The AMD Developer Challenge 2025.

  • The target task is a scaled, mixed-precision General Matrix Multiply (GEMM): FP8 inputs (_hip_fp8_e4m3_fnuz), single-precision FP32 accumulation via AMD Matrix Fused Multiply-Add (MFMA) hardware instructions, per-element dynamic scaling factors, and BF16 output.
  • Performance was benchmarked across 18 distinct $M \times K \times N$ matrix dimensions.

Key Insights and Ideas

  • Bootstrapping via Deliberate Hardware Probing: With little public documentation on AMD's FP8 Matrix Core intrinsics (rocWMMA), the LLM actively designed probe kernels to trigger informative compiler/runtime errors, synthesizing its own working "hardware findings" cheat sheet.
  • Cross-Architectural Knowledge Transfer: When given Nvidia Tensor Core tutorials and CUDA optimization worklogs, the LLM successfully translated concepts (such as warp-level data flow and memory staging) into idiomatic AMD HIP equivalents.
  • Advanced Autonomous Optimizations: The agent independently implemented non-trivial optimizations:
  • Ping-pong double buffering in Local Data Share (LDS) to overlap global memory loads with math.
  • LDS buffer reuse: Repurposing empty FP8 tile buffers as float* storage for quantization scales, maximizing shared memory efficiency.
  • Cooperative multi-wave execution: Splitting vectorized global memory loads across all threads, but restricting final global writes to wave 0 to prevent bank conflicts.
  • Deducing Bottlenecks from Black-Box Timings: Without hardware profiler metrics (e.g., register spills or memory stall percentages), the LLM designed targeted experiments to isolate specific variables, inferring architectural behavior purely from runtimes.

Key Results

Evaluating geometric average runtime across 18 matrix configurations:

Implementation Execution Time ($\mu\text{s}$) Notes
Naïve HIP $\approx 5000$ Basic, unoptimized translation
PyTorch Reference $\approx 850$ Uses optimized internal FP16 libraries
GPU Kernel Scientist (This Work) $\approx 450$ Fully automated LLM, no hardware access
Human 1st Place (Competition) $105$ Top-8 finishers had native MI300 access

The LLM-driven process produced an $11\times$ speedup over naïve HIP and outperformed the tuned PyTorch baseline by nearly $2\times$, without any human author writing low-level code.

Limitations and Future Work

  • No Profiler Integration: The system relied strictly on wall-clock timings. Incorporating GPU profilers (e.g., ROCm Omnitrace/rocprof) to feed register pressure and memory throughput directly into prompts would yield more targeted explorations.
  • Sequential Evaluation Bottleneck: To remain polite to the competition API, jobs were submitted sequentially, heavily restricting the total number of explored iterations.
  • Single Kernel Focus: While deep, the experiments focused on one GEMM variant rather than a broad suite like KernelBench.
  • Future Directions: The authors plan to connect the system to dynamic retrieval tools for automated documentation ingest, explore other non-Nvidia accelerators, and integrate auto-tuners (e.g., Kernel Tuner) for rapid hyperparameter sweeps.

Summary updated

BibTeX
@inproceedings{andrews2025gpu,
  author = {Martin Andrews and Sam Witteveen},
  title = {{GPU Kernel Scientist: An LLM-Driven Framework for Iterative Kernel Optimization}},
  booktitle = {ES-FoMo-III @ ICML},
  year = {2025},
  url = {https://openreview.net/forum?id=K4XSvet59a},
}
Figure