Skip to content
Machine Learning
Skill

/llm-pipeline-analysis

Inspect LLM torch profiler traces at forward-pass, layer, and kernel level. Use when you need layer timings, anchor-kernel boundaries, representative kernel flows, or Perfetto time ranges.

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

Claude Code

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

SKILL.md

llm-pipeline-analysis.SKILL.md
name: llm-pipeline-analysis
description: "Inspect LLM torch profiler traces at forward-pass, layer, and kernel level. Use when you need layer timings, anchor-kernel boundaries, representative kernel flows, or Perfetto time ranges."

LLM Pipeline Analysis

Overview

Use this when a whole-trace profiler summary is too coarse. The scripts read a Chrome-trace JSON file, find layer-boundary anchor kernels, group kernels into forward passes and layers, and print timing tables you can use for Perfetto navigation or detailed timing analysis.

When To Use It

  • when you need to know **which layers** contribute most
  • when the model has alternating layer types (e.g. models with

`compress_ratios` like DeepSeek-V4 NSA, or hybrid GDN/GQA stacks such as Qwen3.8-27B)

  • when you need to compare cold-start vs steady-state forward passes
  • when you need to navigate to a specific layer in Perfetto UI
  • when you need to select representative layers for deep-dive analysis

Verify inputs from artifacts

Resolve model config, phase, rank/device and TP/EP/DP from the run manifest, server arguments and trace. Ask only for missing information that changes the analysis. `TP-0` identifies a rank, not TP world size; do not default an unknown run to TP8/EP8 or decode BS1. Speculative request BS and target-verify M differ. If no config is available, use an explicit profile and verified layer count.

Model Profiles

Scripts use **ModelProfile** to determine layer boundary detection and kernel classification. Profiles are auto-inferred from `config.json` or selected via `--profile`:

| Profile | Anchor kernel | Blocks/layer | Auto-infer condition | |---|---|---|---| | `dsv4_csa_hca` | `mhc_pre_big_fuse` | 2 | DeepSeek-V4 or compression fallback | | `dsv41` | explicit verified anchor | 1 (override for sublayers) | V4.1 text/wrapper identity or KV-source layers | | `dsv3_mla` | explicit backend anchor or residual boundary | backend-dependent | homogeneous MLA after identity dispatch | | `mla_dsa` | verified residual boundary | 2 | GLM-5/5.2/5.3, V3.2, DSA MLA | | `kimi_k3` | explicit `attn_res_fused` (SGLang) / `attn_res_fwd_online_v2_kernel` (vLLM) | 2 + one output aggregation/pass | K3 / Kimi linear with attention residual | | `glm5_next` | `mhc_pre_big_fuse` | 2 | GLM-5.3-Flash | | `hy_v4` | explicit `ihc_pre_stage2` on Triton fallback | 2 | Hy4 (hpc symbol requires trace check) | | `qwen4_exp` | explicit `grouped_gemma_rmsnorm` | 2 | Qwen3.8-Flash-Next (vLLM may fuse norm) | | `nemotron_h` | explicit residual norm | 1 | one Mamba/attention/MoE block per config layer | | `longcat_flash` | explicit residual boundary | 4 | LongCat-Flash architecture | | `gemma4` | explicit `_gemma_qkv_rmsnorm_kernel` (SGLang CUDA) | 1 | Gemma4 text/wrapper identity | | `generic_addnorm` | verified fused-add RMSNorm or allreduce fusion | 2 | other configured models | | `generic` | explicit anchor; residual candidates only | 1, or 2 for residual candidates | config-less fallback |

Nested `text_config`, `language_config` and `llm_config` are flattened before inference. Model identity takes priority over `kv_lora_rank`: K3, GLM-5 Next, Hy4, dots3 and LongCat must not be treated as homogeneous V3 MLA. Read layer count from config: V4 Flash has 43 layers, Pro 61, V4.1 40. These anchor families are source-verified for SGLang/vLLM, with backend and phase caveats; TensorRT-LLM/TokenSpeed cadence requires separate trace evidence.

Prerequisites

  • A `torch.profiler` trace in Chrome-trace JSON format (`.json` or `.json.gz`)
  • The model's `config.json` (for profile inference, `compress_ratios`, etc.)
  • The trace must contain a recognizable layer-boundary anchor kernel

(auto-detected from the profile, or specified via `--anchor-kernel`)

Layer Boundary Detection

The scripts use an anchor kernel as a layer-boundary marker. The anchor and layer structure are determined by the active **ModelProfile**.

Find the model's residual kind at its stage boundary first. SGLang declares attention/FFN boundaries through `python/sglang/srt/layers/layer_boundary/factories.py` (add-norm, gated, iHC, mHC, post-norm and stream). Backend dispatch determines the visible boundary kernel.

V4 currently starts each half at `mhc_pre_big_fuse*`: attention-pre then FFN-pre, two anchors per layer. Fused post+pre removes `mhc_post_tilelang` for small-token SGLang traces; retain that old anchor only for verified unfused traces or the >32-token path. V4.1 uses previous-sublayer pre-mix, which cannot reuse V4's fused-post-pre formula. Its current `deepseek_v4_mhc.py` dispatch still carries fused post/combine/norm/quant across eligible boundaries; opt-in Mega mHC prefill also produces the next coefficients. Engram seams and row selection can invalidate cached inputs. It always needs explicit anchor and cadence evidence; a vanished stats/norm launch is not a missing layer. See the [current boundary matrix](../llm-torch-profiler-analysis/references/fuse-overlap-catalog.md#residual-mixing-and-collective-epilogues). FlashMLA's `flash_fwd_mla_combine` depends on backend and split count; SM100 SGLang V3 defaults to TRT-LLM MLA, while DSA models use DSA.

All scripts accept `--blocks-per-layer K --anchor-offset I --pid PID --device D`. `I` is a verified first-layer anchor in the selected GPU, not inferred from counts. Mixed ranks/devices and a count residue modulo `N*K` are rejected. A divisible count is necessary but insufficient: separate target/draft phases, MTP/DSPARK passes and TBO microbatches first. K3's extra output aggregation requires a phase-filtered trace for these timing analyzers; the layer-track helper supports the extra anchor explicitly. The final selected pass ends at the selected GPU event boundary, which must itself be verified as a complete pass. Anchors are navigation intervals; cross-stream kernels may overlap them.

For compiled vLLM traces, norms can lower to Inductor kernels. Capture a short mapping trace with explicit norm cust

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…

mlflow8d29k
@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…

feast12d7.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-pipeline-analysis.

Which coding agents can use llm-pipeline-analysis?
llm-pipeline-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.