Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/rightnow-ai/automegakernel/megakernel-optimizationnpx skills add RightNow-AI/AutoMegaKernel --skill megakernel-optimizationgit clone --depth 1 https://github.com/RightNow-AI/AutoMegaKernelWrote 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.
[](https://agentmods.dev/skills/rightnow-ai/automegakernel/megakernel-optimization)<a href="https://agentmods.dev/skills/rightnow-ai/automegakernel/megakernel-optimization"><img src="https://agentmods.dev/badge/skills/rightnow-ai/automegakernel/megakernel-optimization.svg" alt="Measured on agentmods" height="20"></a>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.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00057 | $0.02026 |
| Opus 5 | $0.00028 | $0.01013 |
| Sonnet 5 | $0.00011 | $0.00405 |
| Haiku 4.5 | $0.00006 | $0.00203 |
Grade A, and why
megakernel-optimization 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 5d 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.
How it starts
The opening of the file, as written. The whole thing — 124 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AutoMegaKernel (AMK), megakernel schedule optimization
AMK compiles a HuggingFace Llama-family model into ONE persistent CUDA megakernel and tunes it
with an AutoKernel-style loop: read the edit surface -> propose ONE knob change -> eval ->
keep/revert -> record -> repeat. This skill drives Loop 2 (schedule + kernel_knobs search).
You never write kernel code; you only edit a structured ScheduleConfig (plus its reserved
kernel_knobs sub-object). The frozen VM lowers your config deterministically and the CPU
ReferenceVM judges correctness vs eager PyTorch.
HARD HONESTY RULES (state and obey these every time)
- 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
ScheduleConfigis a clean REJECTED (a deadlock/race-free proof rejects it before launch), never a hung GPU. - The edit surface is
ScheduleConfig+kernel_knobsONLY, never raw kernel code, nevervm/, never the frozen ABI. - Measured-gpu latency is drift-robust; physically-impossible sub-roofline latencies are withheld as artifacts.
- All speedups are vs AMK's OWN baseline (default schedule), NOT a claim of beating cuBLAS/vLLM. AMK is currently within ~13% of cuBLAS at batch-1, behind it.
The edit surface (read it before proposing)
Read the surface programmatically, never guess knob names. Prefer the canonical MCP tool; fall back to the CLI if MCP is unavailable.
- MCP:
amk_propose(model, gpu="rtx5090")->{ schedule_config, schedule_id, search_space, ... }.search_spaceincludes thekernel_knobs.*sub-surface. - CLI:
amk propose <model> --gpu <arch>(oruv run python amk_cli.py propose <model> --gpu <arch>) prints the same surface as JSON on stdout.
The ScheduleConfig knobs (edit ONE per trial): tiling.gemv.N_tile,
tiling.attention.kv_block, fusion_grouping, sm_assignment, pipelining_depth,
page_allocation, threads_per_block, smem_bytes_per_block. The reserved kernel_knobs
object holds GEMV build knobs: cols_per_warp, cpasync, cpa_stages, cpa_cols (these move
MEASURED latency under device=cuda; the predicted/CPU path does not model them). A config
WITHOUT kernel_knobs is byte-identical to the production incumbent.
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.
- 5d ago First seen · 124 lines · 57 tokens per session scan A 88f899547ee6
megakernel-optimization is a skill published in the GitHub repository RightNow-AI/AutoMegaKernel (137 stars, last pushed 2mo ago), licensed MIT. It adds 57 tokens to every session and 2,026 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.
Other skills, from other repositories
cutedsl_megamoe
Skill "cutedsl_megamoe" from flashinfer-ai/flashinfer, covering updating the cutedsl megamoe kernel src, layout, when the kernel team drops a new version of src/ and what not to update here.
add-cuda-kernel
Step-by-step tutorial for adding new CUDA kernels to FlashInfer.
swapab_cutedsl_megakernel
Skill "swapab_cutedsl_megakernel" from flashinfer-ai/flashinfer, covering updating the sm120 swap-ab cutedsl megamoe kernel src, layout, when the kernel team drops a new version of src/ and what not to update here.
cuopt-developer
Modify, build, test, debug, and contribute to NVIDIA cuOpt (C++/CUDA, Python, server, CI). Use for solver internals, PRs, DCO, and code conventions.
add-sgl-kernel
Step-by-step tutorial for adding a heavyweight AOT CUDA/C++ kernel to sgl-kernel (including tests & benchmarks).
debug-cuda-crash
Tutorial for debugging CUDA crashes using API logging.