Skip to content
Machine Learning
Skill

/llm-torch-profiler-analysis

Analyze existing Torch Profiler Chrome traces or capture from SGLang, vLLM, TensorRT-LLM and TokenSpeed servers. Return kernel attribution, overlap opportunities and fusion patterns; use for model dispatch, CUDA Graph gaps, stream contention or exposed kernel tails. Includes

From plugin
ai-infra-auto-driven-skills
1.2k10 skills

Claude Code

$ npx -y skills add BBuf/AI-Infra-Auto-Driven-SKILLS --skill llm-torch-profiler-analysis --agent claude-code

SKILL.md

llm-torch-profiler-analysis.SKILL.md
name: llm-torch-profiler-analysis
description: "Analyze existing Torch Profiler Chrome traces or capture from SGLang, vLLM, TensorRT-LLM and TokenSpeed servers. Return kernel attribution, overlap opportunities and fusion patterns; use for model dispatch, CUDA Graph gaps, stream contention or exposed kernel tails. Includes existing SGLang Omni traces."

LLM Torch Profiler Analysis

Produce three tables: kernel/source attribution, overlap opportunities, and fusion patterns. Start from the user's trace or running server. Inspect the actual model, framework revision, phase, device/rank and parallelism before choosing a fast path. Existing traces need no GPU or framework installation. The Python analyzers use the standard library.

Read [source contracts](../../docs/upstream-source-contracts.md) for dated source inspections and version-sensitive profiler APIs. Apply the general [dispatch and numerical principles](references/heuristics.md#establish-dispatch-and-numerical-contracts) to every model. The [fusion catalog](references/fuse-overlap-catalog.md) contains concrete operator families, eligibility examples and storage contracts; the [overlap catalog](references/overlap-catalog.md) covers scheduling. Consult the model-history knowledge base when detailed PR evidence is needed. Source checks and historical captures are not fresh GPU validation.

Choose the evidence

| Mode | Evidence and limits | |---|---| | Existing trace | All four frameworks; SGLang Omni Python roots are also recognized. Use Chrome JSON or gzip with GPU events. A generic trace may need `--framework` explicitly. | | Single live capture | Use a shared server/client output directory and a supported HTTP profiler. Save actual launch arguments and package revisions. | | Mapping + formal | Eager/graph-off trace supplies call-site context; warmed graph trace supplies timing. Match signatures, shapes and stage before transferring attribution. Never transfer eager timing to the formal run. |

For a diffusion workload, record whether it uses the framework's native backend or a Diffusers fallback. A fallback trace can be analyzed, but does not establish native-kernel performance or dispatch.

Read a trace

Commands below are relative to this skill directory.

python3 scripts/analyze_llm_torch_profile.py \
  --framework sglang --input /path/to/TP-0-DECODE.trace.json.gz

python3 scripts/analyze_llm_torch_profile.py \
  --framework vllm \
  --mapping-input /path/to/eager-mapping \
  --formal-input /path/to/warmed-graph

Do not collapse a distributed run to rank0 when investigating rank skew or collective waits. Keep the original capture; a GPU-only or compact export is for sharing, not replacement evidence. Use [torch-profiler-layer-track](../torch-profiler-layer-track/SKILL.md) for verified L0/L1 guides and synthetic display lanes, or [llm-pipeline-analysis](../llm-pipeline-analysis/SKILL.md) for layer intervals.

Capture against a running server

The common helper defaults to separately driven prefill and decode workloads: nominal input/output lengths 4090/1 and 1/2048, with 10 warmup steps and 5 requested capture steps. Override these to match the slow serving scenario. Synthetic prompt lengths are not a tokenizer-independent guarantee; save actual usage and batch/graph dimensions. A long-context decode bottleneck needs a representative KV length, not automatically the one-token-input default.

python3 scripts/analyze_llm_torch_profile.py \
  --framework sglang --url http://127.0.0.1:30000 \
  --output-dir /shared/profiles/run-001 \
  --profile-workload both --warmup-steps 10 --num-steps 5 \
  --prefill-input-len 4090 --prefill-output-len 1 \
  --decode-input-len 4090 --decode-output-len 2048

`--profile-workload` accepts `both`, `prefill`, `decode`, or `legacy` (explicit probe prompt/token settings). Workload labels alone do not make a trace purely decode: inspect stage annotations and exclude request prefill when needed. The helper targets SGLang profiler v1 (default). Declare `--sglang-profile-v2` if the remote server enables `SGLANG_PROFILE_V2=1`; the helper refuses this incompatible flow before issuing control requests. `/server_info` does not expose remote environment variables. Native v2 needs `profile_by_stage:true` and `num_steps`, without `start_step`, `merge_profiles` or `/stop_profile`. Current Rust ingress also supports start/stop with the same scheduler control. Older images may lack these routes; check the actual response. Keyed servers need the configured admin/API credential; the bundled helper has no auth flag, so use authenticated native control and offline analysis for those captures. The host launcher explicitly sets `SGLANG_PROFILE_V2=0`. The helper puts its label in `profile_id`, so merging can discover rank files. SGLang can emit stage-specific traces; its scheduler stop counter may require a final forward to close the window. The helper's SGLang workload adds a guard request/step. Check actual trace counts instead of assuming identical windows across frameworks.

For other frameworks add `--no-profile-by-stage`. Their HTTP windows and iteration controls differ:

  • **vLLM:** launch with

`--profiler-config '{"profiler":"torch","torch_profiler_dir":"/shared/profiles/run-001","max_iterations":5,"ignore_frontend":true}'`. Current start accepts per-session `profile_prefix`, `max_iterations`, `delay_iterations` and `profiler_kwargs`. The helper checks `/openapi.json` and sends a stage-qualified prefix and `--num-steps` as `max_iterations` only when advertised. Older/OpenAPI-disabled servers retain bodyless control and launch-configured limits. Output directory and optional profiler warmup remain launch settings for this helper; probe steps do not override a warmup/wait/active schedule or guarantee a pure decode window. `torch_profiler_with_stack` defaults true in the inspected source. Frontend traces can contain no kernels; select GPU-worker traces for

Read more
@bbuf
Ships withai-infra-auto-driven-skills

**Agent-ready skills for LLM serving benchmarks, profiler triage, capacity planning, model Day-0 support, incident triage, and model PR history across SGLang, vLLM, TensorRT-LLM, and TokenSpeed — plus SGLang PR and article explainer videos.** Plain SKILL.md

Stars on GitHub

Momentum

stars in total
1.2k
Star history of BBuf/AI-Infra-Auto-Driven-SKILLS on GitHub, a chart by star-history.com

More skills from other plugins.

analyze-ci

analyze-ci

Analyze failed GitHub Action jobs. Takes one or more GitHub URLs (job, workflow-run, or PR) and summarizes each failure with root…

mlflow9d29k
@mlflow@mlflowInstall Skill
hf-cli

hf-cli

Hugging Face Hub CLI (`hf`) for downloading, uploading, and managing models, datasets, spaces, buckets, repos, papers, jobs, and…

skills3w11k
@huggingface@huggingfaceInstall Skill
feast-architecture

feast-architecture

Internals of the Feast codebase — how each component works, where the key abstractions live, and the data flow through the…

feast13d7.4k
@feast-dev@feast-devInstall Skill
add-ecosystem

add-ecosystem

Add a new ecosystem and base model to basemodel.constants.ts. Use when onboarding a new model family from providers like Baidu,…

civitai9d7.3k
@civitai@civitaiInstall Skill

Questions about llm-torch-profiler-analysis.

Which coding agents can use llm-torch-profiler-analysis?
llm-torch-profiler-analysis installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.