KernelFoundry documentation#

KernelFoundry is an open-source framework for hardware-aware GPU kernel optimization. Point a coding agent at a slow GPU kernel and get a faster one back. The agent isolates the kernel, builds a reference to beat, finds your existing tests or writes new ones, and derives benchmark sizes from how the code is actually called, asking you only about what it cannot work out on its own.

From there KernelFoundry repeatedly generates, compiles, benchmarks and profiles candidate kernels on real hardware, keeping the fastest ones that still pass those tests. On KernelBench it reaches an speedup of 2.3x (geometric mean) for SYCL. See the paper for the full evaluation.

You can also author the reference and tests yourself and drive the search from the command line. The pages below cover both, starting with the agentic path.

A coding agent turns the kernel you want faster into a task package of reference, tests, EVOLVE block and config, which you can also author yourself. The task package enters an optimization loop, driven either by (A) the evaluation tool in a modify-and-test cycle or (B) the evolution agent searching autonomously. The loop generates, compiles, benchmarks on a real GPU and profiles candidates, feeding test results, runtime stats and profiler feedback back into generation, and emits an optimized kernel to integrate back into your code. A coding agent turns the kernel you want faster into a task package of reference, tests, EVOLVE block and config, which you can also author yourself. The task package enters an optimization loop, driven either by (A) the evaluation tool in a modify-and-test cycle or (B) the evolution agent searching autonomously. The loop generates, compiles, benchmarks on a real GPU and profiles candidates, feeding test results, runtime stats and profiler feedback back into generation, and emits an optimized kernel to integrate back into your code.

Four terms run through the diagram, the guide and the CLI:

Task

One kernel you want to speed up, defined by a reference implementation plus tests.

Job

One run of the optimization on a task. A task can have many jobs.

Task package

The folder KernelFoundry evaluates: kernel file, reference, tests and config.yaml. The agent builds it for you, or you write it yourself. See Anatomy of a task package.

EVOLVE block

The region of the kernel file KernelFoundry may rewrite, marked [EVOLVE_START] / [EVOLVE_END]. Everything outside it is left untouched.

Start here#

Go to

If you

Optimize a kernel with a coding agent

Have a slow kernel and want it faster with the least work. Describe it in a sentence and a coding agent packages, validates and optimizes it. Start here.

Quickstart

Would rather drive the search yourself. Runs the shipped example end to end from the command line, with no LLM API key. The shipped example is a SYCL kernel for an Intel GPU; on NVIDIA, start from the KernelBench task the page gives instead.

Anatomy of a task package

Are writing a task package by hand. Continue to Writing tests.

Config parameters

Are tuning a run. See also Optimization strategies.

Understanding results

Have a finished run and want to know why it went that way.

Public API

Are writing tests and need the exact signatures. Assumes you know the package format.

For installation, the README is the single source of truth.

Indices and tables#