AutoMegaKernel: Command for Claude Code

.claude/commands/amk-compile.md

amk-compile is a command for Claude Code from RightNow-AI/AutoMegaKernel. It costs 29 tokens per session (623 once invoked), scanned A, original, MIT.

A command for compiling and checking a machine-learning model into one persistent CUDA megakernel using AutoMegaKernel. CUDA is NVIDIA's system for running computations on its graphics processors.

In plain words
What is it for?
It helps developers compile a model, compare its output with eager PyTorch and a CPU reference, build the GPU kernel, and produce a performance report. A CUDA GPU and the NVIDIA compiler nvcc are required for building and measuring.
Why use it?
It combines model import, safety checks, correctness tests, GPU building, and performance measurement in one run. Unsafe schedules are rejected before they can hang the GPU.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution.

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/commands/amk-compile.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-compile

README.md
[![agentmods](https://agentmods.dev/badge/commands/rightnow-ai/automegakernel/amk-compile.svg)](https://agentmods.dev/commands/rightnow-ai/automegakernel/amk-compile)
Your own site
<a href="https://agentmods.dev/commands/rightnow-ai/automegakernel/amk-compile"><img src="https://agentmods.dev/badge/commands/rightnow-ai/automegakernel/amk-compile.svg" alt="Measured on agentmods" height="20"></a>
Per session 29 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 623 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
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.00029 $0.00623
Opus 5 $0.00015 $0.00311
Sonnet 5 $0.00006 $0.00125
Haiku 4.5 $0.00003 $0.00062

Measured 8d ago against content hash 130f34cd7d13, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

amk-compile 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 8d 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/commands/amk-compile.md · 40 lines

What it actually says

One-shot compile and verify a model into a single persistent CUDA megakernel with AutoMegaKernel (AMK) on $ARGUMENTS (parse as model [gpu]; default gpu = rtx5090; default model = toy). This is THE product path: import -> lower -> validate (deadlock + race free) -> verify vs eager -> build the GPU megakernel -> measure against the HBM roofline -> emit a correct megakernel

  • report.

HARD HONESTY RULES (state them, obey them):

  • Correctness FIRST: the compile path verifies vs eager PyTorch AND the CPU ReferenceVM; a latency is NEVER reported without a correctness PASS.
  • validate-before-launch: an unsafe schedule is a clean REJECTED (deadlock/race-free proof), never a hung GPU.
  • The edit surface (if you tune afterward) is ScheduleConfig + kernel_knobs ONLY, never kernel code, never vm/ or the frozen ABI.
  • Measured-gpu latency is drift-robust; impossible sub-roofline latencies are withheld.
  • Any speedup is vs AMK's OWN baseline, NOT a claim of beating cuBLAS/vLLM.

Do this:

  1. Confirm the environment with amk_doctor() (CLI: amk doctor), torch/cuda, device name, nvcc, registered targets. A CUDA GPU + nvcc is required to build and measure the megakernel.
  2. Compile and verify in one shot via the CLI: amk compile <model> --gpu <gpu> --regime single-stream (equivalently uv run python amk_cli.py compile <model> --gpu <gpu> --regime single-stream). This lowers, statically validates, verifies correctness vs eager, builds the GPU megakernel, and measures it against the weights / HBM_bandwidth roofline, emitting the megakernel + report.
  3. Report the result: correctness PASS (vs eager + ReferenceVM), measured per-token latency_us
    • latency_kind, pct_of_roofline, and the schedule_id. If correctness did not PASS, report the failure honestly and do NOT report a latency.

Optional next step: to tune the compiled schedule, run /amk-optimize <model> <gpu> (interactive propose -> eval -> keep/revert) or /amk-autoresearch <model> <gpu> (unattended). Speedups there are vs AMK's own default schedule, not vs cuBLAS/vLLM.

Use only the canonical names: CLI amk compile and amk doctor (MCP amk_doctor for the environment check).

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. 8d ago First seen · 40 lines · 29 tokens per session scan A 130f34cd7d13

Subscribe to this mod's changes

amk-compile is a command published in the GitHub repository RightNow-AI/AutoMegaKernel (138 stars, last pushed 2mo ago), licensed MIT. It adds 29 tokens to every session and 623 once invoked, about $0.0001 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.