# AutoMegaKernel (AMK)

An agent harness that compiles a model's whole forward pass into a single, provably correct, self-tuning CUDA megakernel that beats cuBLAS at batch-1 LLM decode on several GPUs.

AutoMegaKernel is a general agent harness for GPU megakernel synthesis: a coding agent such as Claude Code or Codex drives it to compile a model into one self-retargeting megakernel covering the entire forward pass in a single persistent GPU launch, then self-tunes it, improving each time it runs. It inherits an autoresearch loop from its sibling project AutoKernel, which generates single best kernels rather than whole-model megakernels, and adds a new search axis over the scheduling.

A compile command imports a model, lowers it, validates the result for deadlocks and races, verifies it against eager execution, builds the GPU megakernel, measures it against the memory-bandwidth roofline, and emits a report. Its auto-tuned int8 megakernels beat CUDA-graphed cuBLAS bf16 at batch-1 decode across several NVIDIA inference-class GPUs, found autonomously by AMK's own correctness-gated search, though it currently trails on GPUs built for training such as the A100 and H100.

Coverage today is the HuggingFace Llama family on CUDA compute capabilities 7.5 through 12.0. It is written in Python and licensed under MIT.

Website: https://runinfra.ai/
