Skip to content
AMD-AGIPublic

About

Agentic Kernel Library for ROCm, the agent-first kernel library

Resources

Contributing

Stars

15 stars

Watchers

0 watching

Forks

Repository files navigation

AKLR

Agentic Kernel Library for ROCm

AKLR is a kernel library for LLM inference on ROCm, where agents write the kernels and every kernel is validated automatically before it serves. It is a step toward AI improving the systems that run AI.

We believe kernel performance will no longer come from rare, hand-tuned efforts but from continuous, automatic improvement, with AI driving each speedup on ROCm.

AKLR architecture

Repository map

AKLR has two main parts: aklr/ runs kernels, while harness/ helps agents build and deliver them.

Path What is here
aklr/plugins/aiter/ Each operator's API, correctness check, speed-test baseline, and kernel files.
aklr/core/ Shared code that checks inputs, loads kernels, picks one for each workload, and validates results.
aklr/plugins/ Plugins for other projects. SGLang works today; vLLM and AITER are planned.
harness/ Guides and tools for agents to write, test, review, and submit kernels. forge_task sends an AKLR problem to KernelForge.
tests/ and .github/workflows/ Local tests and CI checks.

An engine calls an AKLR operator. AKLR checks the inputs and picks a kernel that passed validation. If no kernel fits, the engine uses its original code. AKLR uses AITER as a speed-test baseline for library kernels; it does not ship AITER as a runtime fallback.

The Kernel Rosetta Stone

The Kernel Rosetta Stone is a guide for agents writing AMD kernels. It brings together tips from handwritten kernels, AMD architecture and CDNA3/CDNA4 ISA documents, and real examples. Start at SKILL.md.

It aims to help agents reach the same speed sooner, use fewer tokens, and find faster kernels. Below is our first measurement on one GEMM (details):

Kernel Rosetta Stone: GEMM comparison

  • Same 1.28x speedup: 5h20m and ~$52 with the AKLR knowledge base, against 14h46m and ~$205 without, about a third of the time and a quarter of the spend.
  • After 8 hours: 1.286x against 1.177x.
  • At the end: 1.300x for ~$133 with the AKLR knowledge base; without, the best was 1.289x for ~$230.

Install

Framework Development image
SGLang lmsysorg/sglang:v0.5.23-rocm10-mi35x (stack.json)
vLLM vllm/vllm-openai-rocm:v0.34.0-rocm100 (stack.json)

Inside the image, install AKLR, one pure-Python package aklr (Python 3.11 or later), versioned 0.1.devN+g<commit> before the first tag. It uses the image's torch, Triton and SGLang and replaces none of them:

git clone https://github.com/AMD-AGI/AKLR.git && cd AKLR
pip install -e .

Usage

SGLang loads AKLR at startup and, with AKLR_SGLANG_PLUGIN=1, runs AKLR's kernels through the SGLang plugin. vLLM also loads AKLR, but no vLLM code calls AKLR's ops yet. Other code calls aiter's functions: with AKLR_AITER_PLUGIN=1 aiter asks AKLR's provider (aklr/plugins/aiter/provider) about each call it routes, and runs its own kernel for a call AKLR declines.

Variable Effect
AKLR_DISABLE=1 Turn AKLR off
AKLR_DISABLE=<contract id>,... Turn off the listed ops, e.g. gemm@1.0
AKLR_SGLANG_PLUGIN=1 Hook SGLang's functions to the plugin's ops (aklr/plugins/README.md)
AKLR_MIN_SPEEDUP=<x> Serve only kernels with a measured speedup of at least x (default 1.05)

Development

Read in this order:

  1. Ops tutorial (中文): add a kernel to an op in aklr/plugins/aiter/. The example is a bf16 gemm (gemm@1.0 at n=1024, k=4096).
  2. SGLang plugin tutorial (中文): when an optimization crosses one op's boundary, replace a whole SGLang function. The example, deepseek_v2_mxfp4_moe, takes GLM-5's whole MoE layer. The vLLM plugin tutorial (中文) does the same for vLLM.
  3. forge_task: let agents write and tune a kernel.

For reference: aklr/plugins/aiter/README.md (schema fields, the kernel interface, names, commands), aklr/plugins/README.md (the plugin layout, rules for routes, upgrading SGLang), harness/README.md (agent skills and the kernel lifecycle).

Testing

pytest tests                                                # unit tests
python -m aklr validate --stages audit,bench --devices 0-7  # full validation

Contributing

About

Agentic Kernel Library for ROCm, the agent-first kernel library

Resources

Contributing

Stars

15 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages