profile-model

Profile MAX model inference to measure GPU utilization and identify dominant kernels.

Updated Sep 15, 2026
One-click install
npx skills add https://github.com/shakfu/mdsp --skill profile-model-shakfu
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: profile-model
Source: https://github.com/shakfu/mdsp/tree/main/.claude/skills/profile-model
Command: npx skills add https://github.com/shakfu/mdsp --skill profile-model-shakfu

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires max, and includes scripts (resource) and references (resource) components.

What problem does it solve? When a model running on MAX feels slow, you need to know whether the GPU is actually saturated, which kernels consume the most time, and why a specific kernel underperforms. This Skill provides a cheapest-first diagnostic workflow that answers those three questions without capturing more profiling data than necessary. ## Core Features & Use Cases - GPU Utilization Check: Sample compute usage, memory, and throttle reasons on NVIDIA and AMD GPUs using the pure-Python max.profiler.gpu API and the bundled gpu_snapshot.py script. - Kernel Breakdown: Capture ranked top-N GPU kernel tables via max generate --profile, Nsight Systems on NVIDIA, or rocprofv3 on AMD, with NVTX phase markers for prefill, decode, and sampling. - Single-Kernel Deep Dive: Use Nsight Compute (ncu) to analyze occupancy, stalls, and roofline position for one dominant kernel. - Custom Architecture Support: Profile models loaded with --custom-architectures, including import-drift checks, PYTHONPATH traps, and chat-template workarounds. - Use Case: A user serving Llama-3.1-8B notices low tokens per second. The Skill first confirms the GPU is busy, then captures a kernel breakdown showing gemv_split_k GEMVs dominating decode — the healthy expected shape — ruling out a kernel problem and pointing at batch configuration instead. ## Quick Start Ask the assistant to profile your model on MAX, for example: "Profile my model running with max serve and tell me where it spends GPU time."

Frequently Asked Questions about profile-model

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I profile a model running on MAX?▼

Start with the cheapest check: run the bundled gpu_snapshot.py script alongside your workload to measure GPU utilization. If the GPU is busy, run max generate --profile for a ranked kernel table, and only use ncu for a single-kernel deep dive when one kernel dominates.

How do I check GPU utilization during MAX inference?▼

Use the max.profiler.gpu API, which works on NVIDIA via NVML and AMD via ROCm SMI with no extra profiler install. The gpu_snapshot.py script records samples while your workload runs and prints peak and mean utilization, peak memory, and throttle reasons per GPU.

Does MAX profiling work on AMD GPUs?▼

Yes. On AMD GPUs such as MI300, use rocprofv3 with --kernel-trace and --marker-trace to capture a Perfetto trace of max serve. The utilization check via max.profiler.gpu also works on AMD through ROCm SMI.

Can I profile a custom architecture loaded with --custom-architectures?▼

Yes, decoder architectures profile the same as built-in ones using max generate --profile --no-device-graph-capture --custom-architectures <dir>. Verify the architecture imports cleanly on your MAX version first, and note that serving custom embeddings architectures via max serve is currently broken.

Why does my nsys profile show no NVTX phase markers?▼

MAX only emits NVTX markers when profiling is explicitly enabled. Set MODULAR_ENABLE_PROFILING=detailed before launching, or use the --gpu-profiling detailed flag, then verify with nsys stats --report nvtx_pushpop_sum on the captured file.

Why is my GPU utilization low while my model runs?▼

Low gpu_usage_percent during a workload means the bottleneck is host-side: CPU overhead, launch and sync gaps, host-device transfers, or a batch that is too small. A kernel trace will not help here; fix the host-side pipeline or increase batch size first.