debug:pytorch

Diagnose and fix PyTorch training issues across CUDA, gradients, and data pipelines.

9|1|Updated Jan 12, 2026
One-click install
npx skills add https://github.com/SnakeO/claude-debug-and-refactor-skills-plugin --skill debug-pytorch
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: debug:pytorch
Source: https://github.com/SnakeO/claude-debug-and-refactor-skills-plugin/tree/main/plugins/debug-and-refactor/skills/debug-pytorch
Command: npx skills add https://github.com/SnakeO/claude-debug-and-refactor-skills-plugin --skill debug-pytorch

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Debug PyTorch issues systematically. Use when encountering tensor errors, CUDA out of memory errors, gradient problems like NaN loss or exploding gradients, shape mismatches between layers, device conflicts between CPU and GPU, autograd graph issues, DataLoader problems, dtype mismatches, or training instabilities in deep learning workflows.

Core Features & Use Cases

  • Systematic debugging: Structured steps to locate root causes across model code, data pipelines, and training loops.
  • Error coverage: Handles CUDA OOM, NaN/Inf losses, shape mismatches, device placement, inplace operations, and DataLoader stability.
  • Use Case: For a model failing with NaN loss, apply this Skill to enable anomaly detection, inspect logit shapes, verify devices, and stabilize training.

Quick Start

Use the PyTorch debugging skill to reproduce a failing training step with a minimal repro.

Frequently Asked Questions about debug:pytorch

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

FAQPage Schema
How do I fix NaN loss in PyTorch training?

Fix NaN loss in PyTorch training by applying systematic debugging steps: enable anomaly detection, inspect logit shapes, verify devices, and apply gradient clipping to stabilize the training loop.

What is the best way to debug CUDA out of memory errors during deep learning?

Debugging CUDA out of memory errors involves systematically checking tensor shapes, resolving device conflicts between CPU and GPU, and optimizing DataLoader configurations to reduce VRAM consumption during PyTorch training.

How do I resolve shape mismatches between layers in PyTorch?

Resolve shape mismatches between layers by systematically debugging your PyTorch model code, verifying tensor dimensions across the autograd graph, and ensuring dtype consistency throughout the data pipeline and training loop.

Can I use anomaly detection to fix autograd graph issues in PyTorch?

Yes, using anomaly detection is a recommended way to fix autograd graph issues in PyTorch, as it helps identify problematic inplace operations and trace NaN/Inf gradients back to their source layers quickly.

Do I need deterministic seeds to debug DataLoader problems in PyTorch?

Yes, using deterministic seeds is recommended when debugging DataLoader problems in PyTorch, as it ensures reproducible minimal repros and stable testing environments to isolate tensor errors and training instabilities.