mcpbeat Sign in

Numerics Debugging Agent Skill

Capture and compare per-op activations between two TorchTitan runs to spot numerics divergence (eager vs aot_fx_trace, FSDP vs no-FSDP, before vs after a refactor). Use when the user wants to debug bitwise / numeric drift in training, or invokes /numerics_debugging.

3k tokens
context cost
the whole folder, loaded on every use
3
files
instructions only
0
copies elsewhere
how many repositories repackaged it
5585
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/pytorch/torchtitan --skill numerics_debugging

What comes with it

10 612 bytes besides the instruction
references/customization.md
references/patching.md

The instruction itself

3 sections, as written by the author

Numerics Debugging (DebugMode-based)

Per-op activation capture + comparison toolkit. Captures activations on a

designated step via torch.utils._debug_mode.DebugMode, then diffs two

captures into an HTML report to surface numerics divergence between runs

that should agree (bitwise, or within float32 reduction-order noise).

Two pieces live in agent_tooling/numerics_debugging/:

  • activation_tracer.py — runtime capture, driven from Profiler by

ActivationCaptureProfiler. Output:

{dump_folder}/numerics/rank_{N}_activations.log.

  • compare_numerics.py — diffs two logs, produces an HTML report.

agent_tooling/ sits outside the torchtitan package on purpose. Nothing

in core torchtitan or graph_trainer references it; an agent must edit

torchtitan to wire it in before a capture run, and revert the edits when

done (they don't belong on main).

> The two runs being compared must use the same dtype and seed. The

> matcher keys on shape + float64 L1 norm; a precision change (bf16 vs

> fp32) makes every row diverge and the matcher degrades to the

> structural-only stats pass.

Workflow

  • Patch torchtitan to wire the capture into Profiler (and

graph_trainer if you're capturing the traced path). Full patch set:

references/patching.md.

  • Capture twice, once per run you want to compare:
   ./run_train.sh \
       --dump_folder ./outputs/run_A \
       --training.steps 2 \
       --profiler.dump_numerics \
       --profiler.profile_freq 2 \
       --debug.seed 42 \
       --debug.deterministic \
       --training.mixed_precision_param float32

The capture step is profile_freq. With profile_freq=2 and

training.steps=2, step 1 warms up and step 2 is the snapshot. Capture

adds ~10–40% memory only on the capture step (stats are computed inline

in float64; tensors aren't held).

  • Diff the two logs:
   python -m agent_tooling.numerics_debugging.compare_numerics \
       outputs/run_A/numerics/rank_0_activations.log \
       outputs/run_B/numerics/rank_0_activations.log \
       --name1 run_A --name2 run_B \
       -o diff.html

Open diff.html. Each row pairs one op from each run; cells turn red

when a stat diverges; the "Match method" chip shows which of the four

matching passes (override / exact key / fuzzy key / stats) paired the

row.

Customizing

Excluded ops, numel / dtype filter, hash function, the manual-override

file format, and HTML appearance are all tunable. See

references/customization.md, which also

catalogs the common eager-vs-traced mismatch patterns (AC-recompute FQN

drift, per-layer counter shifts, collective renaming) you'll see in the

diff and how to express them as overrides.

Other skills for the same job

different authors, same section of the catalogue
Performance Testing Review AI Review
by ComeOnOliver
×2

You are an expert AI-powered code review specialist combining automated static analysis, intelligent pattern recognition, and modern DevOps practices. Leverage AI tools (GitHub Copilot, Qodo, GPT-5, C

6k tokens
Ruby Pro
by ComeOnOliver
×2

Write idiomatic Ruby code with metaprogramming, Rails patterns, and performance optimization. Specializes in Ruby on Rails, gem development, and testing frameworks. Use PROACTIVELY for Ruby refactoring, optimization, or complex Ruby features.

3k tokens
Tdd Workflows Tdd Refactor
by ComeOnOliver
×2

Use when working with tdd workflows tdd refactor

4k tokens
Setup Pre Commit
by aiskillstore
×1

Set up Husky pre-commit hooks with lint-staged (Prettier), type checking, and tests in the current repo. Use when user wants to add pre-commit hooks, set up Husky, configure lint-staged, or add commit-time formatting/typechecking/testing.

7k tokens
Pair Programming
by Microck
×1

AI-assisted pair programming with multiple modes (driver/navigator/switch), real-time verification, quality monitoring, and comprehensive testing. Supports TDD, debugging, refactoring, and learning sessions. Features automatic role switching, continuous code review, security scanning, and performance optimization with truth-score verification.

6k tokens
Audit Prep Assistant
by christophacham
×1

Prepares codebases for security review using Trail of Bits' checklist. Helps set review goals, runs static analysis tools, increases test coverage, removes dead code, ensures accessibility, and generates documentation (flowcharts, user stories, inline comments).

2k tokens
Component Refactoring
by ComeOnOliver
×1

Refactor high-complexity React components in Dify frontend. Use when `pnpm analyze-component --json` shows complexity > 50 or lineCount > 300, when the user asks for code splitting, hook extraction, or complexity reduction, or when `pnpm analyze-component` warns to refactor before testing; avoid for simple/well-structured components, third-party wrappers, or when the user explicitly wants testing without refactoring.

20k tokens
Csharp Pro
by ComeOnOliver
×1

Write modern C# code with advanced features like records, pattern matching, and async/await. Optimizes .NET applications, implements enterprise patterns, and ensures comprehensive testing. Use PROACTIVELY for C# refactoring, performance optimization, or complex .NET solutions.

3k tokens

How to use it

Copy the folder

Take pytorch/numerics_debugging from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.