Phase 06/Shipping and being seen/Agentic performance engineering, agents that tune the stack
PHASE 06 · Shipping and being seen

Agentic performance engineering, agents that tune the stack

0%
8 h5 subtopics2 lessons · 1 required
In plain English

Imagine a tireless assistant who tries a hundred versions of a kernel overnight: change a tile size here, unroll a loop there, benchmark each one, and leave a ranked list on your desk in the morning. That assistant is exactly as useful as the tests you give it. With sloppy tests it learns to cheat, finding the version that games your timing script while quietly breaking the model. With rigorous tests, correctness first, then honest timing, it becomes a real force multiplier. This topic is about building the harness, the gates and the feedback that let an AI agent do performance work you would actually ship.

Why it matters

Kernel and configuration search spaces are far too large for humans to sweep by hand, and agent-driven optimization is how the industry is starting to cover them. The durable skill is not prompting; it is designing the environment, tools, evals and verification, that makes an agent's output trustworthy, and catching the moment it starts gaming your metrics.

Hiring signal

NVIDIA's kernel-optimization team wants experience building or directing agentic AI systems, code generation, automated optimization, or multi-step reasoning workflows; its agentic kernel org asks for experience building code agents, automated generation, review, or repair of real codebases; and its agent-driven inference-optimization role has AI agents repeatedly run benchmark, profile, and tune processes, amplifying the impact of every technique you design.

Skills this topic builds, with the number of the 46 analysed job postings that ask for each. Companies asking: Anthropic, Baseten, Cerebras, CoreWeave, Crusoe, Databricks, Fireworks, Hugging Face, Liquid AI, Modal, nvidia, OpenAI, Perplexity, Thinking Machines, Together AI, xAI.See all skills →

Learning objectives

  • Design a propose, measure, keep optimization loop for kernels or engine configs with a strict correctness gate.
  • Build benchmark hygiene for agents: warmup, repeats, medians, noise budgets and held-out eval splits.
  • Specify tool interfaces and feedback text that measurably improve an LLM agent on a tuning task.
  • Detect and defend against reward hacking and benchmark gaming in generated code.
  • Evaluate an agent on a KernelBench-style task and report verified speedups, not claimed ones.

Key concepts

Agent loop
Propose a change, verify correctness, measure performance, keep or revert; the atomic cycle of agentic optimization.
Correctness gate
The differential test every candidate must pass before its timing is even recorded.
Eval harness
The fixed environment (inputs, seeds, timing protocol, tolerances) an agent is scored in.
Reward hacking
Optimizing the measured proxy instead of the real goal, for example skipping work the eval does not check.
Search versus generation
Sweeping a structured config space versus having a model write novel code; different loops, different failure modes.
Tool interface for agents
The small set of commands (run test, run bench, show diff, show trace) with precise outputs an agent can call.
Verified speedup
A speedup that survives the correctness gate, the noise budget and a fresh-input retest, as opposed to an agent's claim.

Subtopics

  1. 1. The optimization loop and its gates

    Candidate proposal, correctness gate, measurement protocol, keep or revert ledger; why the order correctness-then-speed is non-negotiable.

  2. 2. Benchmark hygiene for agents

    Warmup, repeat counts, median and spread, clock and thermal noise, input randomization, and public versus held-out eval splits.

  3. 3. Tools and feedback for code agents

    Designing the run, bench, diff and inspect commands, error messages that teach, budgets and stopping rules, and transcript logging you can audit.

  4. 4. Reward hacking and how to catch it

    Common cheats (skipping work, caching answers, tolerance abuse), canary inputs, held-out shapes, and auditing generated diffs.

  5. 5. The landscape, KernelBench and production agent teams

    KernelBench and the AI CUDA Engineer as public baselines; what NVIDIA's agentic kernel, compiler and inference-optimization postings say about the skill set.

Resources

repo
article
documentation
  • SWE-bench ↗
    The eval design pattern (real repos, hidden tests) applied to code agents.

Hands-on lessons

L1

Build a gated tuning loop for a NumPy kernel

CPU · your Macscript150 minrequired

Goal · A propose, verify, measure, keep loop that searches schedule configurations (tile size, unroll, vectorization) for a NumPy matmul or softmax, with a differential correctness gate and noise-budgeted timing, producing a verified-best config and the full candidate ledger.

  1. 1Write a parameterized kernel (tile size, unroll factor, vectorization flag) and a differential tester against a reference on random inputs.
  2. 2Implement the measurement protocol, warmup runs, N timed repeats, median with spread, and a noise budget that rejects improvements smaller than the spread.
  3. 3Implement the loop over a config space of at least 48 candidates, gate then measure then keep, logging every candidate, verdict, timing and decision to a ledger.
  4. 4Add canary inputs designed to catch a config that only works for the benchmark shapes, and re-verify the winner.
  5. 5Produce the final table, best config, verified speedup over the naive baseline, and the three most interesting failures the gate caught.
Deliverable
tuning_loop.py, the candidate ledger, and the final verified-results table.
Check
The winner passes the gate on canary inputs; the claimed speedup exceeds the measured noise spread; the ledger records every candidate with a decision reason.
L2

LLM-in-the-loop kernel improvement with a verification gate

Colab T4 · freeexperiment150 minoptional

Goal · An agent loop where an LLM proposes mutations to a Triton kernel, your gate from l1 (or a Triton variant of it) verifies and times each proposal, and the transcript plus verified delta is reported.

  1. 1Pick a correct baseline Triton kernel from p6-triton-programming and a held-out input set.
  2. 2Define the agent's tools, run correctness test, run benchmark, show diff, show timing summary, with exact output formats.
  3. 3Drive 10 to 20 proposals, manually pasting between the agent and the harness if no API key is available, logging each proposal, the gate verdict and the measured time.
  4. 4Record every failure mode, wrong numerics, tolerance abuse, benchmark gaming, no-op changes, and how the gate caught it.
  5. 5Finish with the verified-best kernel, its speedup with spread, and a paragraph on what made the agent productive or unproductive.
Deliverable
The transcript log, the verified-best kernel, and the failure-mode table.
Check
Any claimed speedup in the report survives re-verification on held-out inputs; at least two failure modes are documented with the gate evidence.
Fallback
Replace the LLM with a scripted mutator (random program edits from a fixed menu) and run the same loop; the gates, ledger and failure analysis are the lesson.

Build your own

Build your own kernel-tuning agent

PythonCPU · your Mac~4 h

A gated propose-measure-keep loop with a correctness gate, noise-budgeted timing, a candidate ledger and held-out verification.

The real thing: github.com/ScalingIntelligence/KernelBench ↗

How you know a stage passes

You write tests/agent.spec.py first. It seeds a reference kernel and a candidate space, then asserts the gate rejects broken candidates, the timer respects its noise budget, the ledger records every decision, and the final winner survives held-out inputs.

Stages, in order. Each one leaves you with something that runs.0/5
  1. 01the correctness gate
    A differential tester compares any candidate to the reference on randomized inputs with stated tolerances.
    test · pytest asserts a deliberately broken candidate is rejected and the true reference passes.
  2. 02the measurement protocol
    Warmup plus N repeats with median and spread, and a noise budget that gates claimed improvements.
    test · pytest asserts a sub-noise improvement is rejected as unverified and a 5x improvement is accepted.
  3. 03the proposer and the ledger
    A config-space proposer drives the loop, and every candidate, verdict, timing and decision lands in a queryable ledger.
    test · pytest asserts the ledger length equals the number of proposals and every entry has a decision reason.
  4. 04an LLM proposer interface
    A prompt builder and response parser that let an LLM propose candidates through the same interface, with an offline mock for testing.
    test · pytest runs the full loop against the mock proposer and asserts the transcript parses and the gates still fire.
  5. 05held-out verification and the final report
    The winner is re-verified on held-out shapes and a report lists verified speedup, spread, and caught failure modes.
    test · pytest asserts the final report's winner passes on held-out inputs and the report includes at least two documented failure modes.

Knowledge check

QWhy must the correctness gate run before any timing is recorded?

Because a wrong fast program is worthless and timing data from it contaminates the ledger; gating first keeps every recorded number tied to a correct candidate.

QWhat is reward hacking in the context of kernel agents, and name two defenses.

Optimizing the measured proxy instead of the real goal, like skipping computation or caching benchmark answers; defenses include canary and held-out inputs, tolerance budgets, and auditing the generated diff.

QWhy report median and spread instead of best-of-N timings for agent decisions?

Best-of-N hides noise and lets luck masquerade as progress; median with a spread sets a noise budget so only real, repeatable improvements pass.

QWhat makes a good tool interface for a code agent on a performance task?

A small set of precise commands (test, bench, diff, inspect) with deterministic machine-readable outputs and error messages that state what failed and where, so each proposal gets honest feedback.

QWhy is a scripted config sweep sometimes better than an LLM proposer, and when is it not?

A sweep is exhaustive and reproducible over a small structured space; it loses when the space is unstructured or huge, where a model's guesses prune the search, at the price of verification burden.

Completion

  • All 5 subtopics marked done
  • All 1 required lessons done
  • All subtopics marked completed.
  • Lesson l1 deliverable saved and check passes.
  • Can explain, with ledger evidence, one time a gate caught a candidate that would have shipped a wrong or fake speedup.
Topic progress is derived; it reaches 100% when both checks above pass.Next recommended topic →