Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

profile-model

БесплатноЗапускает вложенные скриптыНе проверен

Profile a model running on MAX to find where it spends time and whether the GPU is saturated. Use when the user asks to "profile my model," "where is my model…

modularот modular★ 215 звёзд на GitHub

Об этом скилле

Profile a model on MAX

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:

  1. Is my GPU actually being used? (utilization, memory, clocks)
  2. Where does my model spend the most time? (which kernels / phases)
  3. Why is this kernel slow? (occupancy, stalls, roofline)

It works from a pip or pixi install of MAX, driving the public max CLI or a Python script.

How to decide what to run

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.

  1. Start with the utilization check. If the GPU is idle or lightly loaded while the workload runs, the bottleneck is host-side (CPU, transfers, small batch) — stop and report that. A kernel trace won't tell you anything a busy GPU wouldn't.
  2. If the GPU is busy, capture a kernel breakdown. This is the common case and usually the final answer: it shows which kernels dominate GPU time.
  3. Only if one kernel dominates and you need to know why, do a single-kernel deep dive on that one kernel. Skip this unless a breakdown has already pointed at a specific kernel — it replays the kernel many times and is slow.
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:

Models loaded with --custom-architectures

Profiling 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.

Reading the result (what the kernel mix tells you)

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:

  • Decode dominated by 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.
  • Sparse-MoE decode dominated by grouped / block-scaled matmul plus routing kernels — the per-expert grouped matmul (*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.
  • Low-bit weights (FP8 / FP4 / NVFP4) add quant-prep kernels — alongside the matmul you'll see dynamic activation-quantization and scale-layout kernels (*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.
  • A custom architecture not hitting the expected fused kernel (for example attention showing as generic 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.
  • **Pathologically low decode tok/s + an outsized prefill-shaped kernel mix repeating every st
Полный SKILL.md на GitHub

Установить profile-model в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

references/custom-architectures.mdreferences/ncu.mdreferences/nsys.mdreferences/rocprofv3.mdreferences/utilization-api.mdscripts/gpu_snapshot.py

FAQ

Что делает скилл profile-model?

Profile a model running on MAX to find where it spends time and whether the GPU is saturated. Use when the user asks to "profile my model," "where is my model spending time," "why is inference slow," "is my GPU being utilized," "how much GPU am I using," "get a kernel breakdown," "capture an nsys/rocprof/ncu trace of max serve," or wants to measure MAX inference performance. Works for any model MAX can run — built-in architectures and custom ones loaded with --custom-architectures — from a pip or pixi install (max generate, max serve, or a Python script) on NVIDIA or AMD GPUs. Decide cheapest-first: a GPU utilization check, then a kernel breakdown, then a single-kernel deep dive only when one kernel dominates.

Как установить скилл profile-model?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл profile-model запускает скрипты?

Да, скилл несёт исполняемые скрипты. Проверь исходник перед установкой.

Похожие скиллы

Сравнить profile-model с