Skip to content
Agentmart
Submit a tool

profile-model

Analyze PyTorch profiler traces (.json/.json.gz).

Skill by divyanshkhanna

IndexedBSD-3-Clause★ 12
Write a review

Chalk Labs

Need help deploying profile-model?

Chalk Labs sets up agents like this inside real teams: connected to your tools, tested on your data, with a human in the loop where it matters.

Book a call

Install

Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.

npx agentmarket install skill/meta-pytorch-profile-model

Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.

Get the weekly diff

The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.

We use your email only for this newsletter. Privacy

About

Analyze PyTorch profiler traces (.json/.json.gz). Use when the user wants to diagnose GPU performance issues, find slow kernels, identify idle time, analyze communication overhead, or debug training bottlenecks.

Use cases: ml

No reviews yet. Installed it? Reviews come from verified installers only. How reviews work

Permissions

What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.

Tools
No tools found
Secrets
None asked for
Install scripts
None found

Network hosts it talks to 1

  • codeload.github.com · found in install command

Files it touches

  • ~/.claude/skills/profile-model

What's inside

Skill name
profile-model
Description
Analyze PyTorch profiler traces (.json/.json.gz). Use when the user wants to diagnose GPU performance issues, find slow kernels, identify idle time, analyze communication overhead, or debug training bottlenecks.
License
BSD-3-Clause
Metadata
author: divyanshkhanna · version: 1.0
Instructions
186 lines in SKILL.md · view on GitHub

Files (3)

  • SKILL.md
  • eval.yaml · evals/
  • simple_trace.json · evals/fixtures/analyze_trace_basic/

SKILL.md (first lines)

# Profile Model

Analyze PyTorch profiler traces (`.json`/`.json.gz` files) to diagnose GPU performance issues, find slow kernels, and identify bottlenecks.

---

## Step 1: Get Trace Path

Ask the user for the trace file path. Traces are typically:
- Single file: `/path/to/trace.json` or `/path/to/trace.json.gz`
- Directory (multi-rank): `/path/to/traces/` containing `rank0.json`, `rank1.json`, etc.

## Step 2: Load Trace as DataFrame

Load the trace into a pandas DataFrame for flexible querying.

**⚠️ IMPORTANT: Ask user before caching.** Do NOT cache automatically. Ask:

> "Would you like me to cache this trace as Parquet for faster future loads?
> This saves to `/tmp/trace_cache/` and makes subsequent loads faster.
> (Recommended for large traces or if you plan to ask follow-up questions)"

Only proceed with caching if the user agrees.

**DataFrame structure:**
- Standard columns: `name`, `cat`, `ph`, `ts`, `dur`, `pid`, `tid`, `id`
- Args flattened to: `args_device`, `args_stream`, `args_Input Dims`, etc.

**Loading approach:**
1. Parse JSON/JSON.gz trace file
2. Flatten each event into a row, with `args` dict expanded to `args_*` columns
3. Convert `ts` and `dur` to numeric

**Parquet caching notes (if user agrees):**
- Cache to `/tmp/trace_cache/{basename}.parquet`
- Check cache freshness by comparing mtime with source file
- **Handle mixed types**: `args_*` columns often have mixed types (int, str, None). Before saving to Parquet, detect mixed-type columns and convert them to strings. Replace `'nan'`/`'None'` strings back to `None`.
- If Parquet save fails, retry with all `args_*` columns as strings
- If still fails, continue without cache

## Step 3: Quick Summary

After loading, show a quick summary:
- Total events and breakdown by category (`df["cat"].value_counts()`)
- Kernel count and total kernel time
- Top kernels by duration

## Step 4: Analyze with DataFrame Queries

Key column values for filtering:
- GPU kernels: `cat == "kernel"`
- CPU ops: `cat == "cpu_op"`
- NCCL/communication: `name.str.contains("nccl", case=False)`
- Memory ops: `cat` contains "mem" or "memcpy"

Timestamps (`ts`) and durations (`dur`) are in **microseconds (μs)**.

Use standard pandas operations (groupby, filter, sort, aggregate) to answer user questions.

## Step 5: Interpret Results

| Finding | Likely Issue | Recommendation |
|---------|--------------|----------------|
| Many small kernels (avg < 10μs) | Kernel launch overhead | Use `torch.compile`, fuse operations |
| One kernel dominates (>50%) | Expected for compute-bound | Check if kernel is optimized |
| Many memory operations | Memory-bound | Reduce copies, use pinned memory |
| High communication time | Distributed overhead | Overlap comm with compute |

## Step 6: Deep Analysis with HTA (Optional)

If the user wants deeper analysis, use HTA (Holistic Trace Analysis):

```python
# Check if HTA is available
try:
    from hta.trace_analysis import TraceAnalysis
except ImportError:
    print("HTA not installed. Install with: pip install HolisticTraceAnalysis")
```

#### HTA Analysis Functions

| User Question | HTA Function | What It Returns |
|---------------|--------------|-----------------|
| "What's taking GPU time?" | `get_gpu_kernel_breakdown()` | Kernel time distribution |
| "Where's the critical path?" | `critical_path_analysis()` | Bottleneck path through execution |
| "Why is GPU idle?" | `get_idle_time_breakdown()` | Host wait vs kernel wait breakdown |
| "Comm/compute overlap?" | `get_comm_comp_overlap()` | Overlap percentage per rank |
| "Any slow ranks?" | `get_potential_stragglers()` | Straggler rank identification |
| "Overall time breakdown?" | `get_temporal_breakdown()` | Idle/compute/non-compute time |

#### HTA Usage Examples

```python
from hta.trace_analysis import TraceAnalysis

# Load traces
analyzer = TraceAnalysis(trace_dir="/path/to/traces/")
# OR: analyzer = TraceAnalysis(trace_files={0: "/path/to/trace.json.gz"})

# GPU Kernel Breakdown
kernel_type_df, kernel_df = analyzer.get_gpu_kernel_breakdown(visualize=False)

# Temporal Breakdown (idle vs compute vs non-compute)
temporal_df = analyzer.get_temporal_breakdown(visualize=False)

# Idle Time Breakdown (why is GPU idle?)
idle_df, _ = analyzer.get_idle_time_breakdown(ranks=[0], visualize=False)

# Critical Path Analysis (for distributed training)
cp_graph, success = analyzer.critical_path_analysis(
    rank=0, annotation="ProfilerStep", instance_id=1
)
if success:
    analyzer.overlay_critical_path_analysis(
        rank=0, critical_path_graph=cp_graph, output_dir="/tmp/cp_output"
    )

# Communication-Computation Overlap

From meta-pytorch/skills, BSD-3-Clause.

Signals

Stars
12
Forks
2
Open issues
1
Last commit (this folder)
Jun 8, 2026 (4 months ago)

From GitHub (fetched Oct 24, 2026).

Details

Version
1.0
License
BSD-3-Clause
First seen
Oct 24, 2026
Last checked
Oct 24, 2026

Done for you

Rather not set it up yourself?

Chalk Labs scopes, builds and runs agents for your team: the task audit, the eval harness, the integrations and the weekly ops report. Fixed scope, priced before we start.

See how we build AI agents →Read the case studies

Chalk Labs is a two-founder AI and growth studio. We build AI agents, CRMs and MVPs for Web3 and AI companies, and have shipped 50+ product and token launches.

launches shipped
50+
launches shipped
media placements
500+
media placements
founders on every account
2
founders on every account

Press we've placed: Forbes · CoinDesk · Decrypt · Cointelegraph · The Block

Rahil Jain, Co-founder, Chalk Labs. Ex-Goldman Sachs engineer. You talk to the person who builds it.

Get profile-model running in your business

Tell us what you want to automate. A founder replies within one working day with a plan, not a pitch deck.

Goes to the Chalk Labs founders, not the newsletter. Privacy

Need help deploying profile-model?

CallGet help
Cite this page

profile-model skill. Agent Mart. https://agentmart.dev/skills/meta-pytorch-profile-model (last updated 2026-10-24)