ml-debug

ml-debug is a skill for Claude Code, Codex from giacomogaglione/claude-awesome-stack. It costs 38 tokens per session (642 once invoked), scanned A, original, MIT.

A step-by-step guide for finding common machine-learning bugs. It checks tensor shapes, number types, computing devices, invalid values such as NaN or infinity, and whether gradients flow through training.

In plain words
What is it for?
Debugging tensor dimension errors, CPU/GPU mismatches, mixed data types, NaN values, unstable calculations, and broken gradient flow.
Why use it?
It narrows down why training fails or produces unexpected results by checking likely numerical and data-handling problems in order.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Debugging tensor dimension errors, CPU/GPU mismatches, mixed data types, NaN values, unstable calculations, and broken gradient flow.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/giacomogaglione/claude-awesome-stack/ml-debug
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add giacomogaglione/claude-awesome-stack --skill ml-debug
Clone the repo
git clone --depth 1 https://github.com/giacomogaglione/claude-awesome-stack

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for ml-debug

README.md
[![agentmods](https://agentmods.dev/badge/skills/giacomogaglione/claude-awesome-stack/ml-debug.svg)](https://agentmods.dev/skills/giacomogaglione/claude-awesome-stack/ml-debug)
Your own site
<a href="https://agentmods.dev/skills/giacomogaglione/claude-awesome-stack/ml-debug"><img src="https://agentmods.dev/badge/skills/giacomogaglione/claude-awesome-stack/ml-debug.svg" alt="Measured on agentmods" height="20"></a>
Per session 38 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 642 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00038 $0.00642
Opus 5 $0.00019 $0.00321
Sonnet 5 $0.00008 $0.00128
Haiku 4.5 $0.00004 $0.00064

Measured 8d ago against content hash 3a421436bb38, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

ml-debug scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

stacks/python-ml/skills/ml-debug/SKILL.md · 74 lines

How it starts

The opening of the file, as written. The whole thing — 74 lines — stays where its author put it; the contents beside it link to each section on GitHub.

ML Debugging Skill

When debugging an ML issue, work through these checks in order. Stop at the first check that reveals the problem.

1. Shape Verification

Trace tensor shapes through the computation:

  • Print shapes at every function boundary: print(f"input: {x.shape}, output: {y.shape}")
  • Verify batch dimension is preserved through all operations
  • Check that reshape/view operations don't silently permute data
  • Verify attention mask shapes match query/key dimensions

2. Dtype and Device Checks

Look for silent type/device mismatches:

  • Print tensor.dtype and tensor.device at suspicious points
  • Check for float32/float64 mixing (common in loss computation)
  • Verify all tensors in an operation are on the same device
  • Check for integer overflow in index operations

3. NaN/Inf Propagation

Trace where NaN or Inf first appears:

  • Insert assert not torch.isnan(x).any(), f"NaN at {name}" after each operation
  • Enable anomaly detection: torch.autograd.set_detect_anomaly(True)
  • Check for division by zero in normalization layers
  • Check for log(0) or log(negative) in loss functions
  • Check for extremely large values before softmax

4. Gradient Flow

Diagnose vanishing or exploding gradients:

  • Print gradient norms: torch.nn.utils.clip_grad_norm_(model.parameters(), max_norm=1.0)
  • Check if any parameter has requires_grad=False unintentionally
  • Check for dead ReLU units (all-zero activations)
  • Verify loss is connected to all trainable parameters

5. Data Pipeline

Check if the issue is in the data, not the model:

  • Verify labels match inputs (visualize a few samples)
  • Check for data leakage between train/val/test
  • Verify normalization statistics (mean, std) are computed on training set only
  • Check class imbalance
  • Verify data augmentation isn't corrupting labels

6. Common Library Gotchas

PyTorch

  • model.eval() vs model.train() -- affects dropout and batchnorm
  • torch.no_grad() must wrap inference code
  • loss.backward() accumulates gradients -- call optimizer.zero_grad() first
  • DataLoader with num_workers > 0 can hide errors in worker processes

Read the full file on GitHub · 74 lines

Files

What ships with it

1 file beside SKILL.md in the same directory: the scripts, references and assets a skill reads on demand. Not counted in the per-session cost; read them before you install if any of them is executable.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 74 lines · 38 tokens per session scan A 3a421436bb38

Subscribe to this mod's changes

ml-debug is a skill published in the GitHub repository giacomogaglione/claude-awesome-stack (2 stars, last pushed 6mo ago), licensed MIT. It adds 38 tokens to every session and 642 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.