Profiles a model running on MAX to identify GPU utilization, kernel breakdown, and single-kernel bottlenecks. Works with NVIDIA and AMD GPUs for any MAX-compatible model.
Ships in max-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill answers three questions about any model you can run on MAX, whether
it's a built-in architecture or a custom one loaded with
--custom-architectures:
It works from a pip or pixi install of MAX, driving the public max CLI or
a Python script.
Each question needs a deeper, more expensive capture than the last. Work from the cheapest check toward the most invasive, and let each result decide whether going deeper is even worth it — don't capture more than the question needs.
| What you're answering | Tool | Cost |
|---|---|---|
| Is the GPU busy? | max.profiler.gpu (pure Python, NVIDIA + AMD) | seconds, no extra installs |
| Where does time go? | max ... --profile, or nsys (NVIDIA) / rocprofv3 (AMD) | a couple of profiled runs |
| Why is one kernel slow? | Nsight Compute (ncu), NVIDIA only | one slow capture per kernel |
Read the reference for the step you're on rather than loading all of them:
references/utilization-api.md (and the
bundled scripts/gpu_snapshot.py)references/nsys.mdreferences/rocprofv3.mdreferences/ncu.md--custom-architecturesProfiling itself works the same for a custom architecture as for a built-in
one. What differs is loading: a custom architecture has extra prerequisites and
failure modes — import compatibility with your installed MAX version,
PYTHONPATH traps, architecture-name collisions, base models with no chat
template, and a max serve limitation for custom embeddings models. Those stop
the model from loading before any profiling can run. If you're profiling a
model passed via --custom-architectures, read
references/custom-architectures.md
first.
Profiling answers two things: is the GPU saturated (the utilization check) and where does time go (the kernel breakdown). Map what you see back to a diagnosis:
gemv_split_k_* GEMVs, with *_mha_* attention and
rms_norm below — this is the normal, healthy shape for a dense LLM token
generation (decode is memory-bound GEMV). Nothing to chase.*grouped* / block_scaled_*
matmul) is the dominant kernel instead of a dense GEMM, alongside top-k
routing (topk_*, moe_create_indices) and expert gather/scatter; on
multi-GPU, EP dispatch/combine collectives appear too. This is the healthy
shape for a Mixture-of-Experts model — routing and gather overhead is
expected, and only worth chasing if it rivals the matmul itself.*quantize*, *block_scales*) and block-scaled matmul variants rather than
plain gemv/gemm. Time spent in quant/dequant prep is normal for a low-bit
model; flag it only if it dwarfs the matmul it feeds. Kernel prefixes are
GPU-arch-specific (sm100_* on Blackwell, different on Hopper / MI) — match
on the kernel family, not the exact name.elementwise/matmul instead of a *_mha_*
kernel, or norms/RoPE unfused) — a wiring signal: the graph may not be built
the way you think, even if logits pass. Worth a look during bring-up.gpu_usage_percent while a workload runs — host-bound, launch/sync
overhead, or batch too small; the GPU isn't the bottleneck.Tooling and MAX packaging change often; this shape is the part worth preserving. Whichever capture you run, follow it:
nvidia-smi or
rocm-smi to learn the vendor — the kernel-breakdown and deep-dive tools
differ by vendor. Confirm the profiler is installed (which nsys /
which rocprofv3 / which ncu); if it's missing, tell the user the exact
install line (see the reference) rather than failing midway.max serve warms a
compile cache (cold compile can take minutes), launches a server, and runs a
benchmark. Before doing that, show the user the model, the flags, and the
planned commands, and wait for confirmation. A one-shot
max generate --profile on a tiny model is cheap enough to skip this./health. Don't wait out a full timeout
on a server that already died.pkill -f max on a shared box — you may
stop someone else's run.Profiling features land in nightly before stable, so this skill targets the
nightly max-serve build. Install it with pixi:
pixi init quickstart -c https://conda.modular.com/max-nightly/ -c conda-forge
cd quickstart && pixi add max-serve
pixi run max --version # expect a *.dev build
The utilization API (GPUDiagContext, BackgroundRecorder) ships in the
conda max package, so install via pixi or conda rather than a plain
pip install max wheel, which may not expose max.profiler.gpu. If a
command below 404s or an import fails, confirm you're on a recent nightly
build.
max-serve package installed via pixi
(see Nightly vs stable above). All
max CLI commands below assume you can run pixi run max ... in that
project. The max-serve package includes extra dependencies required to
serve a model with MAX, which aren't included with the main max package.nsys and ncu ship with the CUDA Toolkit. If which nsys fails but CUDA is
present, export PATH=/usr/local/cuda/bin:$PATH. Otherwise install Nsight
Systems / Nsight Compute from NVIDIA, or
sudo apt-get install nsight-systems.rocprofv3 ships with ROCm (/opt/rocm/bin). Add it to PATH if needed.max — it talks to
NVML / ROCm SMI directly through max.profiler.gpu.The lowest-friction commands, each expanded in its reference file:
scripts/gpu_snapshot.py alongside a short
benchmark. Pure Python, works on NVIDIA and AMD.pixi run max generate --model <m> --prompt "hello" --num-warmups 1 --profile. Prints a ranked top-N GPU-kernel
table
and writes a .nsys-rep (NVIDIA). Falls back to a CPU summary without a GPU.MODULAR_ENABLE_PROFILING=detailed + nsys launch / rocprofv3.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
8 skills in this plugin
/benchmark-modelBenchmark a model served on MAX with the `max benchmark` command: measure throughput (tokens/sec), latency (TTFT, TPOT, inter-token latency), and GPU utilization by driving load against a running `max serve` endpoint. Use this whenever the user wants to benchmark, load-test, or measure the performance of a MAX model, get tokens-per-second / TTFT / TPOT numbers, run a concurrency or request-rate sweep, compare latency vs throughput, size a deployment, or produce benchmark JSON, even if they don't say "benchmark" by name. Also use when a `max benchmark` run fails to connect or reports zero/garbage numbers.
/debug-modelDebug a MAX model that loads, compiles, serves, and generates tokens but whose output disagrees with a reference implementation. Use whenever parity debugging stalls on scalar taps, the model returns gibberish or wrong greedy tokens, logit cosine is high but argmax differs, or generation is coherent then diverges. Applies during an architecture port, a quantization bring-up, a multi-GPU conversion, or after a MAX upgrade. Triggers on "parity failure", "silent corruption", "logits match but tokens diverge", "top-1 mismatch", "greedy divergence", and "model serves but generates garbage". Not for crashes on load or pre-serve scaffolding (use import-model). Mandates reference-vs-MAX tensor-dump comparators first, numerical verification of fixes before recompiling, and a serve-vs-pipeline bisect when dumps match but text diverges.
/max-skills:profile-model [model-path] [serve/generate flags]from max-skills
npx claudepluginhub modular/skills --plugin max-skillsOther plugins' skills for the same job