AutoMegaKernel: Agent for Claude Code

.claude/agents/amk-megakernel-optimizer.md

amk-megakernel-optimizer is an agent for Claude Code from RightNow-AI/AutoMegaKernel. It costs 62 tokens per session (1,759 once invoked), scanned A, original, MIT.

An agent that searches for faster settings for an AutoMegaKernel running a Llama-family model on a GPU. AutoMegaKernel compiles a model into one persistent CUDA kernel.

In plain words
What is it for?
It helps propose, evaluate, and keep or reject GPU scheduling changes, including tiling, fusion, memory, threading, and asynchronous-copy settings. It reports measured speed improvements over AutoMegaKernel's own default schedule.
Why use it?
It automates repeated performance experiments while requiring each candidate to remain correct. It restricts tuning to approved schedule and kernel settings, protecting the model's core code and interface.

Agent for Claude Code

Written for Claude Code: installed under .claude/.

This is RightNow-AI/AutoMegaKernel's own configuration. It tells Claude Code how to work on AutoMegaKernel itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything AutoMegaKernel configures →

Reuse

Borrowing it

Nothing to install: this file belongs to RightNow-AI/AutoMegaKernel. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/RightNow-AI/AutoMegaKernel/main/.claude/agents/amk-megakernel-optimizer.md
Clone the repo
git clone --depth 1 https://github.com/RightNow-AI/AutoMegaKernel

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for amk-megakernel-optimizer

README.md
[![agentmods](https://agentmods.dev/badge/agents/rightnow-ai/automegakernel/amk-megakernel-optimizer.svg)](https://agentmods.dev/agents/rightnow-ai/automegakernel/amk-megakernel-optimizer)
Your own site
<a href="https://agentmods.dev/agents/rightnow-ai/automegakernel/amk-megakernel-optimizer"><img src="https://agentmods.dev/badge/agents/rightnow-ai/automegakernel/amk-megakernel-optimizer.svg" alt="Measured on agentmods" height="20"></a>
Per session 62 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,759 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00062 $0.01759
Opus 5 $0.00031 $0.00879
Sonnet 5 $0.00012 $0.00352
Haiku 4.5 $0.00006 $0.00176

Measured 6d ago against content hash 94f65ca03a68, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

amk-megakernel-optimizer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 6d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.claude/agents/amk-megakernel-optimizer.md · 110 lines

How it starts

The opening of the file, as written. The whole thing — 110 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AMK Megakernel Optimizer, operating manual

You optimize a HuggingFace Llama-family model's AutoMegaKernel (AMK) schedule. AMK compiles the model into ONE persistent CUDA megakernel; your job is to search the edit surface for a schedule that is correct and measurably faster than AMK's own default, then record it to the campaign orchestrator. Read HARNESS.md (the full contract) before you start.

What you may edit (and ONLY this)

The edit surface is a ScheduleConfig (a JSON dict of typed knobs) plus an optional kernel_knobs sub-object. Never raw kernel code, never vm/, never Task.sm, never the frozen ABI.

ScheduleConfig knobs (see HARNESS.md §2 for choices): tiling.gemv.N_tile, tiling.attention.kv_block, fusion_grouping, sm_assignment, pipelining_depth, page_allocation, threads_per_block, smem_bytes_per_block.

kernel_knobs (the MegakernelVM build levers that actually move measured latency): cols_per_warp, cpasync, cpa_stages, cpa_cols. Embed them under the reserved "kernel_knobs" key inside the config JSON.

Read the live surface programmatically, do not guess:

uv run python amk_cli.py propose <model> --gpu <gpu>   # incumbent config + search_space (with choices)

The HARD honesty rules (you MUST obey and state these)

  • Correctness FIRST. A latency is NEVER reported without a correctness PASS vs the CPU ReferenceVM. Keep a candidate only if it is correct AND >=1% faster than the incumbent.
  • validate-before-launch. An unsafe ScheduleConfig is a clean REJECTED (proven deadlock/race-free), never a hung GPU. A rejected/incorrect config has NO latency.
  • Edit surface = ScheduleConfig + kernel_knobs ONLY, never kernel code, never vm/, never the frozen ABI.
  • Measured latency is drift-robust (interleaved keep/revert vs the resident incumbent); physically-impossible sub-roofline latencies are withheld as artifacts.
  • All speedups are vs AMK's OWN baseline, NOT a claim of beating cuBLAS/vLLM (AMK is currently within ~13% of cuBLAS at batch-1, behind it). Report it this way, honestly, even at ~1.0x.

Read the full file on GitHub · 110 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 6d ago First seen · 110 lines · 62 tokens per session scan A 94f65ca03a68

Subscribe to this mod's changes

amk-megakernel-optimizer is an agent published in the GitHub repository RightNow-AI/AutoMegaKernel (137 stars, last pushed 2mo ago), licensed MIT. It adds 62 tokens to every session and 1,759 once invoked, about $0.0003 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.