aiter-reflection

A workflow for optimizing AMD MI300 GPU kernels in the AITER project, checking that they remain correct, benchmarking them, and saving each iteration's results. It includes guidance for tests, benchmark scripts, warmups, repetitions, and synchronization.

In plain words
What is it for?
Use it to locate target kernels and tests, run correctness checks, build benchmark scripts for common input sizes, compare timings, and record optimization results.
Why use it?
It creates a repeatable way to measure kernel changes and avoid treating compilation time or unreliable timings as performance results.

Skill for Claude CodeCodex

Install

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.

agentmods
npx agentmods add skills/amd-agi/apex/aiter-reflection
Any agent
npx skills add AMD-AGI/Apex --skill aiter-reflection
Clone the repo
git clone --depth 1 https://github.com/AMD-AGI/Apex

Made for: Claude Code, Codex.

Per session 46 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 766 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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 $0.00046 $0.00766
Opus 5 $0.00023 $0.00383
Sonnet 5 $0.00009 $0.00153
Haiku 4.5 $0.00005 $0.00077

Measured 2d ago against content hash e71dfa936c10, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

aiter-reflection scanned grade C with 1 finding 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 2d 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- `rm -f aiter/jit/*.so && rm -rf aiter/jit/build ~/.aiter`
tools/skills/aiter-reflection/SKILL.md · 73 lines

How it starts

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

Aiter Reflection

Overview

Optimize AMD MI300 GPU kernels for correctness and performance using the aiter workflow, then record each iteration to the kernel experiment database.

Workflow

1) Locate targets and understand tests

  • Use the provided context to identify target kernel files, kernels, and their op tests.
  • Run the op tests once to understand output format and verify correctness expectations. (Attention: Stucked background op test processes and lock files under jit folder may cause the op tests running failed; Op tests require JIT compiling, please be prepared to wait for a long time)

2) Build a benchmark shell script

  • Come up with a new name for this iteration and create a folder logs/. Put the shell script under this folder
  • Reuse the existing op_test python script
  • Covers common shapes: 128, 256, 512, 1024, 2048, 4096 if applies
  • Repeats each op test multiple times and reports the correctness and the average time consuming.
    • Use at least 100 iterations per configuration for reliable results
    • Include 10-20 warmup iterations to handle JIT compilation overhead
    • Add torch.cuda.synchronize() after each kernel call
    • Use fixed random seed for reproducibility
    • Use high-precision timing (time.perf_counter())
  • Implements a robust timeout to avoid hangs.
  • Outputs structured timing per shape.

3) Establish a baseline

  • Before testing: Check for background GPU processes that may interfere
    • Use rocm-smi or ps aux | grep python to identify GPU tasks
    • Stop any unrelated GPU workloads
  • Clear JIT compilation cache to ensure clean state
  • Run the benchmark script using the .venv Python environment
  • Save results under logs/ folder with timestamp

4) Iterate on kernel optimization (one iteration)

  • Read the kernel source, identify bottlenecks, and call rocprof-compute at least once to deepen bottleneck analysis.
  • Use kernel-exp-history to review related optimization history and extract ideas.
  • Modify the kernel file to improve performance for multiple shapes allowed.
  • Save the changes: (git diff > logs//iter_diff.patch)
  • Reinstall aiter and clear cache:
    • python -m pip install -e . --no-build-isolation --no-deps --force-reinstall
    • rm -f aiter/jit/*.so && rm -rf aiter/jit/build ~/.aiter
  • Re-run the benchmark to measure the new performance.
  • If results seem suspicious (unexpected regressions):
    • Verify no background processes are running
    • Re-test baseline with same methodology
    • Check if JIT compilation overhead affected measurements

Read the full file on GitHub · 73 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. 2d ago First seen · 73 lines · 46 tokens per session scan C e71dfa936c10

Subscribe to this mod's changes

aiter-reflection is a skill published in the GitHub repository AMD-AGI/Apex (76 stars, last pushed 5d ago), licensed MIT. It adds 46 tokens to every session and 766 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

write-triton-kv-cache-append-kernel

Guide the agent through implementing a Triton kernel that writes newly computed K and V tensors into a pre-allocated KV cache during LLM inference. This covers two cache layouts (contiguous and paged / vLLM-style PagedAttention), unified prefill and decode handling via a slotmapping tensor, GQA/MQA where the cache…

tensormux/kernel-skills · 0 tokens

write-triton-rope-kernel

Guide the agent through implementing a correct Triton kernel that applies Rotary Position Embeddings (RoPE) to query and key tensors before attention. This covers the two incompatible layout conventions (GPT-NeoX/HuggingFace-LLaMA vs GPT-J/original-paper), pre-computed cos/sin table consumption, per-token position…

tensormux/kernel-skills · 0 tokens

choose-launch-configuration

Guide the agent through selecting the correct and efficient thread block dimensions and grid dimensions for a CUDA kernel, covering occupancy analysis, register and shared memory constraints, tail effects, persistent kernels, and when to use cudaOccupancyMaxActiveBlocksPerMultiprocessor as a decision tool.

tensormux/kernel-skills · 0 tokens

optimize-shared-memory-tiling

Guide the agent through designing and tuning shared memory tiling strategies for CUDA kernels, covering bank conflict analysis and elimination, tile shape selection, double buffering with async copy, occupancy tradeoffs from shared memory allocation, and the decision of when smem tiling is worth the complexity.

tensormux/kernel-skills · 0 tokens

write-cuda-layernorm-kernel

Guide the agent through designing and implementing a correct, efficient CUDA LayerNorm (and RMSNorm) kernel, covering mean/variance computation strategies, Welford online accumulation, epsilon placement, affine transform application, backward pass structure, and decomposition for non-power-of-two hidden dimensions.

tensormux/kernel-skills · 0 tokens

write-cuda-reduction-kernel

Guide the agent through designing and implementing a correct, efficient CUDA reduction kernel for a given operator (sum, max, min, or custom binary associative op), covering warp-level primitives, block-level reduction, multi-block strategies, and when to use CUB instead.

tensormux/kernel-skills · 0 tokens