# rightnow-ai/autokernel architecture

> Architecture diagram of the GitHub repository rightnow-ai/autokernel, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-09). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rightnow-ai/autokernel
- Repository: https://github.com/rightnow-ai/autokernel

## Overview

AutoKernel is an autonomous GPU-kernel optimization system: it profiles a PyTorch model, extracts bottlenecks, iteratively benchmarks kernel edits, then verifies end-to-end speedup. Separate capabilities include KernelBench evaluation and HuggingFace kernel export. The graph follows README-documented workflow links; CUDA implementation-to-compiler links are supported by the source index. Most other implementation details were not sampled, so their internal links are omitted.

Main entry points: [`kernels/cuda/_compile.py`](https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/_compile.py) (CUDA compiler), [`kernel.py`](https://github.com/rightnow-ai/autokernel/blob/main/kernel.py) (Kernel under edit), [`bench.py`](https://github.com/rightnow-ai/autokernel/blob/main/bench.py) (Fixed benchmark), [`profile.py`](https://github.com/rightnow-ai/autokernel/blob/main/profile.py) (Profile bottlenecks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Optimization workflow"]
  node_profile["Profile bottlenecks<br/>[profile.py]"]
  node_extract["Extract kernels<br/>[extract.py]"]
  node_editable["Kernel under edit<br/>[kernel.py]"]
  node_scheduler["Kernel scheduler<br/>[orchestrate.py]"]
end

subgraph group_kernels["Kernel implementations"]
  node_triton_kernels["Triton kernels"]
  node_cuda_compile["CUDA compiler<br/>[_compile.py]"]
  node_cuda_matmul["CUDA matmul<br/>[matmul.py]"]
  node_cuda_flash["CUDA attention<br/>[flash_attention.py]"]
  node_cuda_layernorm["CUDA layernorm<br/>[layernorm.py]"]
  node_cuda_softmax["CUDA softmax<br/>[softmax.py]"]
  node_cuda_other["Other CUDA kernels"]
end

subgraph group_evaluation["Evaluation"]
  node_benchmark["Fixed benchmark<br/>[bench.py]"]
  node_reference["Correctness references<br/>[reference.py]"]
  node_verify["End-to-end verify<br/>[verify.py]"]
end

subgraph group_integrations["Distribution and benchmarks"]
  node_kernelbench_bridge["KernelBench bridge<br/>[bridge.py]"]
  node_kernelbench_bench["KernelBench benchmark<br/>[bench_kb.py]"]
  node_kernelbench_score["KernelBench scorer<br/>[scorer.py]"]
  node_hf_export["HuggingFace export<br/>[export_hf.py]"]
end

subgraph group_models["Model inputs"]
  node_models["PyTorch models"]
end

node_user(("Engineer / agent"))
node_hf_hub[("HuggingFace Hub")]
node_result["Speedup report"]

node_user -->|"provides model"| node_models
node_models -->|"profiles model"| node_profile
node_profile -->|"ranks bottlenecks"| node_extract
node_extract -->|"generates kernels"| node_editable
node_user -->|"edits kernel"| node_editable
node_user -->|"runs benchmark"| node_benchmark
node_benchmark -->|"checks correctness"| node_reference
node_editable -->|"evaluates edit"| node_benchmark
node_scheduler -->|"selects next kernel"| node_user
node_user -->|"requests verification"| node_verify
node_verify -->|"reports speedup"| node_result
node_cuda_matmul -->|"compiles through"| node_cuda_compile
node_cuda_flash -->|"compiles through"| node_cuda_compile
node_cuda_layernorm -->|"compiles through"| node_cuda_compile
node_cuda_softmax -->|"compiles through"| node_cuda_compile
node_cuda_other -.->|"compiles through"| node_cuda_compile
node_kernelbench_bridge -->|"sets up problem"| node_kernelbench_bench
node_kernelbench_bench -->|"feeds evaluation"| node_kernelbench_score
node_user -->|"exports kernels"| node_hf_export
node_hf_export -->|"packages for upload"| node_hf_hub

click node_models "https://github.com/rightnow-ai/autokernel/tree/main/models"
click node_profile "https://github.com/rightnow-ai/autokernel/blob/main/profile.py"
click node_extract "https://github.com/rightnow-ai/autokernel/blob/main/extract.py"
click node_editable "https://github.com/rightnow-ai/autokernel/blob/main/kernel.py"
click node_scheduler "https://github.com/rightnow-ai/autokernel/blob/main/orchestrate.py"
click node_benchmark "https://github.com/rightnow-ai/autokernel/blob/main/bench.py"
click node_reference "https://github.com/rightnow-ai/autokernel/blob/main/reference.py"
click node_verify "https://github.com/rightnow-ai/autokernel/blob/main/verify.py"
click node_triton_kernels "https://github.com/rightnow-ai/autokernel/tree/main/kernels"
click node_cuda_compile "https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/_compile.py"
click node_cuda_matmul "https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/matmul.py"
click node_cuda_flash "https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/flash_attention.py"
click node_cuda_layernorm "https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/layernorm.py"
click node_cuda_softmax "https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/softmax.py"
click node_cuda_other "https://github.com/rightnow-ai/autokernel/tree/main/kernels/cuda"
click node_kernelbench_bridge "https://github.com/rightnow-ai/autokernel/blob/main/kernelbench/bridge.py"
click node_kernelbench_bench "https://github.com/rightnow-ai/autokernel/blob/main/kernelbench/bench_kb.py"
click node_kernelbench_score "https://github.com/rightnow-ai/autokernel/blob/main/kernelbench/scorer.py"
click node_hf_export "https://github.com/rightnow-ai/autokernel/blob/main/export_hf.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_profile,node_extract,node_editable,node_scheduler toneBlue
class node_triton_kernels,node_cuda_compile,node_cuda_matmul,node_cuda_flash,node_cuda_layernorm,node_cuda_softmax,node_cuda_other,node_hf_hub toneAmber
class node_benchmark,node_reference,node_verify toneMint
class node_kernelbench_bridge,node_kernelbench_bench,node_kernelbench_score,node_hf_export toneRose
class node_models,node_user,node_result toneIndigo
```

## Components

### Optimization workflow

- [Profile bottlenecks](https://github.com/rightnow-ai/autokernel/blob/main/profile.py): `profile.py`
- [Extract kernels](https://github.com/rightnow-ai/autokernel/blob/main/extract.py): `extract.py`
- [Kernel under edit](https://github.com/rightnow-ai/autokernel/blob/main/kernel.py): `kernel.py`
- [Kernel scheduler](https://github.com/rightnow-ai/autokernel/blob/main/orchestrate.py): `orchestrate.py`

### Kernel implementations

- [Triton kernels](https://github.com/rightnow-ai/autokernel/tree/main/kernels): `kernels`
- [CUDA compiler](https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/_compile.py): `kernels/cuda/_compile.py`
- [CUDA matmul](https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/matmul.py): `kernels/cuda/matmul.py`
- [CUDA attention](https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/flash_attention.py): `kernels/cuda/flash_attention.py`
- [CUDA layernorm](https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/layernorm.py): `kernels/cuda/layernorm.py`
- [CUDA softmax](https://github.com/rightnow-ai/autokernel/blob/main/kernels/cuda/softmax.py): `kernels/cuda/softmax.py`
- [Other CUDA kernels](https://github.com/rightnow-ai/autokernel/tree/main/kernels/cuda): `kernels/cuda`

### Evaluation

- [Fixed benchmark](https://github.com/rightnow-ai/autokernel/blob/main/bench.py): `bench.py`
- [Correctness references](https://github.com/rightnow-ai/autokernel/blob/main/reference.py): `reference.py`
- [End-to-end verify](https://github.com/rightnow-ai/autokernel/blob/main/verify.py): `verify.py`

### Distribution and benchmarks

- [KernelBench bridge](https://github.com/rightnow-ai/autokernel/blob/main/kernelbench/bridge.py): `kernelbench/bridge.py`
- [KernelBench benchmark](https://github.com/rightnow-ai/autokernel/blob/main/kernelbench/bench_kb.py): `kernelbench/bench_kb.py`
- [KernelBench scorer](https://github.com/rightnow-ai/autokernel/blob/main/kernelbench/scorer.py): `kernelbench/scorer.py`
- [HuggingFace export](https://github.com/rightnow-ai/autokernel/blob/main/export_hf.py): `export_hf.py`

### Model inputs

- [PyTorch models](https://github.com/rightnow-ai/autokernel/tree/main/models): `models`

### Other components

- **Engineer / agent**
- **HuggingFace Hub**
- **Speedup report**

## Connections

- Engineer / agent → PyTorch models: provides model (evidence: `README.md`)
- PyTorch models → Profile bottlenecks: profiles model (evidence: `README.md`)
- Profile bottlenecks → Extract kernels: ranks bottlenecks (evidence: `README.md`)
- Extract kernels → Kernel under edit: generates kernels (evidence: `README.md`)
- Engineer / agent → Kernel under edit: edits kernel (evidence: `README.md`)
- Engineer / agent → Fixed benchmark: runs benchmark (evidence: `README.md`)
- Fixed benchmark → Correctness references: checks correctness (evidence: `README.md`)
- Kernel under edit → Fixed benchmark: evaluates edit (evidence: `README.md`)
- Kernel scheduler → Engineer / agent: selects next kernel (evidence: `README.md`)
- Engineer / agent → End-to-end verify: requests verification (evidence: `README.md`)
- End-to-end verify → Speedup report: reports speedup (evidence: `README.md`)
- CUDA matmul → CUDA compiler: compiles through (evidence: `kernels/cuda/matmul.py`)
- CUDA attention → CUDA compiler: compiles through (evidence: `kernels/cuda/flash_attention.py`)
- CUDA layernorm → CUDA compiler: compiles through (evidence: `kernels/cuda/layernorm.py`)
- CUDA softmax → CUDA compiler: compiles through (evidence: `kernels/cuda/softmax.py`)
- Other CUDA kernels → CUDA compiler: compiles through (evidence: `kernels/cuda/rotary_embedding.py`)
- KernelBench bridge → KernelBench benchmark: sets up problem (evidence: `README.md`)
- KernelBench benchmark → KernelBench scorer: feeds evaluation (evidence: `README.md`)
- Engineer / agent → HuggingFace export: exports kernels (evidence: `README.md`)
- HuggingFace export → HuggingFace Hub: packages for upload (evidence: `README.md`)
