perf-torch-cuda-graphs

Captures and replays PyTorch GPU workloads using CUDA Graphs to reduce launch overhead.

Updated May 23, 2026
One-click install
npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill perf-torch-cuda-graphs
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: perf-torch-cuda-graphs
Source: https://github.com/yo-steven/skills-exploration-20260522/tree/main/skills/TensorRT-LLM/perf-torch-cuda-graphs
Command: npx skills add https://github.com/yo-steven/skills-exploration-20260522 --skill perf-torch-cuda-graphs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This skill helps you reduce PyTorch CPU→GPU launch overhead by capturing GPU workloads once and replaying them efficiently with CUDA Graphs.

Core Features & Use Cases

  • API selection for CUDA Graphs in PyTorch: Choose among torch.compile(mode="reduce-overhead"), torch.cuda.make_graphed_callables(), Transformer Engine make_graphed_callables, Megatron-LM CudaGraphManager, Megatron-LM FullCudaGraphWrapper, or manual torch.cuda.graph().
  • Compatibility and capture workflows: Guides how to structure capture/replay loops, choose warmup steps, and handle static/dynamic constraints.
  • Performance troubleshooting: Diagnoses common speedup blockers (sync points, fragmentation, wrong replay order, RNG/FP8 issues) and provides targeted fixes.

Quick Start

Use the perf-torch-cuda-graphs skill to apply CUDA Graph capture to your PyTorch training loop by selecting the best workflow for your stack (native PyTorch, TE FP8/PP, or Megatron-LM).

Frequently Asked Questions about perf-torch-cuda-graphs

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

FAQPage Schema
How do I reduce PyTorch GPU kernel launch overhead during training?▼

Reduce PyTorch GPU kernel launch overhead by capturing and replaying execution with CUDA Graphs, which records the workload once to eliminate CPU-bound iteration overhead and improve low GPU utilization.

What is the best way to capture CUDA Graphs in PyTorch for static workloads?▼

The best way to capture CUDA Graphs depends on your stack: use torch.compile(mode="reduce-overhead") for native PyTorch, Megatron-LM CudaGraphManager for large models, or manual torch.cuda.graph() for custom loops.

Does CUDA Graph capture work with FP8 training in Transformer Engine?▼

Yes, CUDA Graph capture works with Transformer Engine FP8 training by using TE's make_graphed_callables, ensuring proper warmup steps and deterministic replay order to handle FP8 scaling factors correctly.

Why does my CUDA Graph replay fail or show no speedup with DDP and pipeline parallelism?▼

CUDA Graph replay fails or shows no speedup with DDP and pipeline parallelism due to sync points, wrong replay order, or memory fragmentation, requiring targeted troubleshooting to remove sync-free constraint violations.

When should I not use CUDA Graphs for PyTorch inference?▼

Avoid using CUDA Graphs for PyTorch inference when workloads are dynamic, require frequent synchronization, or have variable tensor shapes, as graph capture demands static constraints and sync-free execution for deterministic replay.