Ascendc
ascend-ai-coding/awesome-ascend-skills
End-to-end AscendC custom operator development for Ascend NPU in an ascend-kernel (csrc/ops + build.sh + torchnpu PyTorch custom op) project.
Condensed debugging method and tool recipes for Unix, Python and PyTorch programs: crashes, hangs, segfaults, wrong output, CUDA OOM, NaN values and slowness.
$ npx skills add stas00/the-art-of-debugging --skill art-of-debugging -a claude-codeProject install by default; add -g for ~/.claude/skills/.
$ gh skill install stas00/the-art-of-debugging art-of-debugging --agent claude-codeProject scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).
Claude Code skills documentation · loads skills from .claude/skills/
Install the "art-of-debugging" agent skill from https://github.com/stas00/the-art-of-debugging/tree/master into .claude/skills/art-of-debugging/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "art-of-debugging", then confirm the skill loads.Claude Code copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add stas00/the-art-of-debugging --skill art-of-debugging -a codexProject install goes to .agents/skills/; add -g for ~/.codex/skills/.
$ gh skill install stas00/the-art-of-debugging art-of-debugging --agent codexProject scope by default (.agents/skills/); add --scope user for a personal install.
Codex skills documentation · loads skills from .agents/skills/
Install the "art-of-debugging" agent skill from https://github.com/stas00/the-art-of-debugging/tree/master into .agents/skills/art-of-debugging/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "art-of-debugging", then confirm the skill loads.Codex copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add stas00/the-art-of-debugging --skill art-of-debugging -a cursorProject install goes to .agents/skills/; add -g for ~/.cursor/skills/.
$ gh skill install stas00/the-art-of-debugging art-of-debugging --agent cursorProject scope by default (.agents/skills/); add --scope user for a personal install.
Cursor skills documentation · loads skills from .cursor/skills/, .agents/skills/, .claude/skills/, .codex/skills/
Install the "art-of-debugging" agent skill from https://github.com/stas00/the-art-of-debugging/tree/master into .cursor/skills/art-of-debugging/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "art-of-debugging", then confirm the skill loads.Cursor copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add stas00/the-art-of-debugging --skill art-of-debugging -a gemini-cliProject install goes to .agents/skills/; add -g for ~/.gemini/skills/.
$ gh skill install stas00/the-art-of-debugging art-of-debugging --agent gemini-cliProject scope by default (.agents/skills/); add --scope user for a personal install.
Gemini CLI skills documentation · loads skills from .gemini/skills/, .agents/skills/
Install the "art-of-debugging" agent skill from https://github.com/stas00/the-art-of-debugging/tree/master into .gemini/skills/art-of-debugging/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "art-of-debugging", then confirm the skill loads.Gemini CLI copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ gh skill install stas00/the-art-of-debugging art-of-debuggingInstalls for Copilot at project scope by default; add --scope user for a personal install. Preview a skill first with gh skill preview. Needs GitHub CLI 2.90.0 or later (public preview).
$ npx skills add stas00/the-art-of-debugging --skill art-of-debugging -a github-copilotProject install goes to .agents/skills/; add -g for ~/.copilot/skills/.
GitHub Copilot skills documentation · loads skills from .github/skills/, .claude/skills/, .agents/skills/
Install the "art-of-debugging" agent skill from https://github.com/stas00/the-art-of-debugging/tree/master into .github/skills/art-of-debugging/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "art-of-debugging", then confirm the skill loads.GitHub Copilot copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
$ npx skills add stas00/the-art-of-debugging --skill art-of-debugging -a opencodeOpenCode documents no install command of its own. Project install goes to .agents/skills/; add -g for ~/.config/opencode/skills/.
$ gh skill install stas00/the-art-of-debugging art-of-debugging --agent opencodeProject scope by default (.agents/skills/); add --scope user for a personal install.
OpenCode skills documentation · loads skills from .opencode/skills/, .claude/skills/, .agents/skills/
Install the "art-of-debugging" agent skill from https://github.com/stas00/the-art-of-debugging/tree/master into .opencode/skills/art-of-debugging/ in this project. Copy the whole folder (SKILL.md and every file beside it), keep the folder name "art-of-debugging", then confirm the skill loads.OpenCode copies the folder itself, the same result as the manual copy. Check what it changed before you commit it.
art-of-debuggingCondensed debugging method and tool recipes for Unix, Python and PyTorch programs: crashes, hangs, segfaults, wrong output, CUDA OOM, NaN values and slowness.
Debugging here follows one loop. Reproduce the failure reliably, shrink the workload so each run is fast, localize the problem by bisecting commits, files or ranks, get a precise signal such as a real traceback, a stack dump, a syscall trace or a NaN check, then change one thing at a time and verify. It also recommends making each debugging cycle a single self-contained command, since the loop will be run many times.
After the loop come cheatsheets for specific failures and tools: gdb and core files, strace, py-spy, `CUDA_LAUNCH_BLOCKING`, `ldd`, `nm` and `LD_PRELOAD`, `cProfile`, and hangs in multi-node or multi-GPU training. The skill is a condensed index of the Art of Debugging open book; each section links to the full chapter online, and it suggests pairing with the author's Machine Learning Engineering skill for large cluster work.
5 steps, taken from the first numbered list in SKILL.md.
Read from SKILL.md and the folder at commit 536de17. It shows what the files ask for, not the result of running them.
Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.
From allowed-tools in the SKILL.md frontmatter.
Ships script files (Python and Shell, from the files we listed), which the agent can run.
Shell commands in SKILL.md call:
pythonpipgitcondaFrom the folder's file list and the shell code blocks in SKILL.md.
Links to these hosts (documentation or services it may open):
github.comFrom URLs in SKILL.md, links to its own repository left out.
Names no API keys, tokens, secrets or passwords.
From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.
The Art of Debugging loads about 6.1k tokens when it runs. Until then it costs about 184 tokens; SKILL.md has 1,733 words of instructions outside code blocks.
Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.
The automated check noted patterns worth knowing about, such as sudo or a known installer.
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t # control where cores gosudo gdb --pid=PID # attach; then: thread apply all btNo sudo? `echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope`. **The first line of each dump is where it's stuck.**Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.
The full file from stas00/the-art-of-debugging at commit 536de17, republished under its CC-BY-SA-4.0 licence (© stas00). 1,733 words, ~6,054 tokens.
.claude/skills/art-of-debugging/SKILL.md (or your agent's skills folder). This skill also uses 98 other files; get the full folder from GitHub.Distilled from The Art of Debugging Open Book by Stas Bekman - source: https://github.com/stas00/the-art-of-debugging (CC BY-SA 4.0). This skill is a condensed index; each section links back to the full chapter for depth.
Actionable methodology + copy-paste recipes for debugging Unix / Python / PyTorch programs. Apply the general loop first; then jump to the domain cheatsheet for the failure at hand. For scaling this up to large-model training/inference on real clusters (compute/storage/network, SLURM, throughput/memory, instabilities, fault tolerance, inference), pair this with Machine Learning Engineering.
The single most important idea: most of the effort is in locating the cause; once you truly understand it, the fix is usually easy. Optimize everything for reaching understanding faster.
die trick), then bisect the search space: which commit, which file/function, which line, which input, which rank.perl/awk/python -c to slice logs, extract fields, transform data on the fly instead of writing throwaway scripts. See the power of one-liner programs.def suspect():
die # NameError -> proves this code runs; the traceback also names the callertraceback.print_stack() shows callers without stopping (useful when the same function is reached via many paths). See am I editing the right file and the right class?.git bisect start / bad / good <rev> walks commits automatically to the one that broke things - script the test for git bisect run. See finding a breaking commit by bisecting.watch -n1 nvidia-smi / free -h / df -h in a second visible terminal to correlate a hang/OOM with what the machine is doing. See watching and reproducing resource issues.sleep to freeze a program at the interesting moment so you can attach a debugger or snapshot state. See uses for sleep.srun instead of re-sbatch-ing to cut per-iteration overhead. See SLURM salloc and srun fast debug combo.Full chapter: Unix Tools for Debugging.
set -e # abort on first error
set -o pipefail # a failing command anywhere in a pipe fails the whole pipe
set -u # abort on undefined variables (catches typos)
set -x # trace: print each command with expanded values as it runs
set +x # turn tracing back off around a noisy regionset -euo pipefail. See controlling script execution.strace - trace system calls to see what a program actually does (files, network, why it's stuck):strace python -c "print('hi')" # trace from the start
strace --pid PID # attach to a running/stuck process
strace -o log.txt -f torchrun ... # -f follows forked children
strace -e trace=open,openat,read python prog.py # filter to specific syscalls
strace -e trace=network -p PID # is it stuck on a socket?nohup - survive logout/disconnect (don't lose a long run to a dropped SSH):nohup ./long-running-command > log.txt &make - after editing compiled sources, rebuild before re-testing, or you'll debug a stale binary. See make.Full chapter: Debugging Compiled Programs. Compile with -g for debug symbols.
ulimit -c unlimited # allow core dumps in this shell
sudo sysctl -w kernel.core_pattern=/tmp/core-%e.%p.%h.%t # control where cores go
./program # crash -> core file written
gdb ./program /tmp/core-... # or: gdb -c core ./program(gdb) prompt:bt # backtrace (read bottom-up: outermost caller -> crash site)
bt full # + local variable values at each frame
thread apply all bt # backtrace for every thread (essential for multithreaded crashes)gdb ./program
(gdb) run # then: bt / break FILE:LINE / next / step / print VAR / continuesudo gdb --pid=PID # attach; then: thread apply all bt
gcore PID # force a core dump without killing (or: kill -ABRT PID)ldd ./program # which shared libs resolve, and to what paths
LD_LIBRARY_PATH=/path/to/libs ./program # prepend a search dir
nm -D libfoo.so | grep symbol # is the symbol actually exported? (T=defined, U=undefined)
LD_PRELOAD=/path/to/shim.so ./program # force-load / override a libraryFull chapter: Debugging Python Programs.
print:q (writes to /tmp/q, doesn't pollute stdout). See q.pip install -e . # run from the source tree, not a copied install
PYTHONPATH=src python prog.py # or point Python straight at the source
python -c "import pkg; print(pkg.__file__)" # confirm which file is actually loadedtraceback.print_stack() or the die trick to reveal the caller in complex codebases. See who is calling?.py-spy - no code changes, attaches live:pip install py-spy
py-spy dump -n -p PID # -n also shows native (C/C++ extension) frames
# all Python subprocesses at once (skip the launcher):
pgrep -P $(pgrep -o python) | xargs -I {} py-spy dump --pid {}echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope. The first line of each dump is where it's stuck. See py-spy.python -m cProfile -s cumtime prog.py # what dominates cumulative time
kernprof -l -v prog.py # line_profiler: per-line timing of @profile funcspstats precision (e.g. pstats.f8 = lambda x: f"{x:6.3f}") so timings aren't all 0.000. See profilers and cProfile.Full chapter: Debugging PyTorch Programs.
Shrink the model, not the problem - make a full run finish in seconds:
CUDA is async, so the reported line is usually wrong. Force a real traceback:
CUDA_LAUNCH_BLOCKING=1 python prog.py # sync CUDA -> accurate Python traceback
CUDA_VISIBLE_DEVICES="" python prog.py # run on CPU (if feasible) for the clearest tracebackSee dealing with async CUDA bugs.
forward (activations - batch/seq len) vs backward (gradients/optimizer state). See debugging CUDA OOM in forward / backward.PYTORCH_ALLOC_CONF (e.g. expandable_segments:True, max_split_size_mb:...). See overcoming CUDA OOM due to memory fragmentation.torch.autograd.set_detect_anomaly(True) # pinpoint the op that first produced NaN/Inf in backwardFind where bad values first appear; watch fp underflow/overflow (especially fp16/bf16); expect small, benign cross-device numeric differences. Inspect tensors compactly (shape/device/dtype/stats) and use lovely-tensors for one-line summaries that surface bad tensors fast. See detecting problematic tensor values, underflow and overflow detection, floating point discrepancies across devices, dumping tensor values, and auto-dumping tensor attributes.
Same core-file + gdb flow as compiled programs, but activate the exact python env that produced the core or gdb can't unpack it:
conda activate my-env
gdb python core-python-... # then: bt / thread apply all btSee segfaults and getting a backtrace from a core file.
torch-distributed-gpu-test.py); rule out network/NCCL before app code. See getting nodes to talk to each other and InfiniBand connection.py-spy (recipes for python/deepspeed/accelerate, across nodes via srun/pdsh). Ranks stuck at different lines reveal the desync (a mismatched collective). See diagnosing crashes, hangs and tracing execution.node:rank, and target pdb at one rank. See prefixing logs, pdb on a specific rank.trace module. On AMD, a slow/hung run may be IOMMU-related.For the cluster-level context around these bugs (verifying node connectivity, NCCL/InfiniBand tuning, network benchmarking, checkpointing/fault tolerance), see Machine Learning Engineering.
s, e = torch.cuda.Event(enable_timing=True), torch.cuda.Event(enable_timing=True)
s.record(); run(); e.record(); torch.cuda.synchronize()
ms = s.elapsed_time(e)torch.profiler (CPU+GPU, op-level, small overhead); when it's not enough, drop to cProfile for pure-Python hot spots. See performance and profiling.| Symptom | Reach for |
|---|---|
| Stuck / 100% CPU / no output | py-spy dump (Python), strace --pid (syscalls), gdb --pid (native) |
| Multi-GPU/node hang | minimal collective test -> py-spy across all ranks -> node:rank logs |
| Segfault / crash in C or extension | core file + gdb (bt, bt full, thread apply all bt) |
| Cryptic CUDA error / wrong line | CUDA_LAUNCH_BLOCKING=1, or run on CPU |
| CUDA/CPU OOM | forward vs backward; fragmentation (PYTORCH_ALLOC_CONF); memory profiler |
| NaN/Inf / wrong numbers | set_detect_anomaly, under/overflow detection, per-tensor stats, lovely-tensors |
| "my edits do nothing" | the die trick; pip install -e . / PYTHONPATH; check pkg.__file__ |
| Who calls this? | traceback.print_stack() / die |
| Wrong/missing shared lib | ldd, nm -D, LD_LIBRARY_PATH, LD_PRELOAD |
| Too slow (Python) | cProfile -s cumtime, line_profiler |
| Too slow (PyTorch/GPU) | CUDA events, torch.profiler |
| Regression appeared | git bisect run |
| Script fails silently | set -euo pipefail, set -x |
| Flaky / non-deterministic | pin seeds/order/timing; force sync; check race conditions |
| Long run dies on disconnect | nohup ... > log & (or tmux/screen) |
pkg.__file__, the die trick) before deeper investigation - a huge share of "impossible" bugs are wrong-file/wrong-env.py-spy, strace, gdb, env vars) that need no source changes and work on already-running processes.© stas00, CC-BY-SA-4.0. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file
SKILL.md and 98 other files in the repository root of stas00/the-art-of-debugging.
Open the folder on GitHubat commit 536de17
The Art of Debugging next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.
| Skill | Stars | Used in | Tokens | Auto-check | Licence | Repo updated |
|---|---|---|---|---|---|---|
| The Art of Debugging this skillstas00/the-art-of-debugging | 1.7k | — | ~6.1k | Automated safety check: Notes | CC-BY-SA-4.0 | |
| Ascendcascend-ai-coding/awesome-ascend-skills | 174 | — | ~3.5k | Automated safety check: Pass | None | |
| Migrate Workflow Ec2 To Osdcpytorch/test-infra | 113 | — | ~2k | Automated safety check: Pass | Custom licence | |
| Magpie Kernel Evaluatoramd/skills | 408 | — | ~2.3k | Automated safety check: Pass | MIT | |
| Quark Torch Debugamd/Quark | 182 | — | ~1.9k | Automated safety check: Notes | MIT | |
| ExecuTorch Build Guidepytorch/executorch | 5.1k | — | ~2.3k | Automated safety check: Notes | Custom licence |
ascend-ai-coding/awesome-ascend-skills
End-to-end AscendC custom operator development for Ascend NPU in an ascend-kernel (csrc/ops + build.sh + torchnpu PyTorch custom op) project.
pytorch/test-infra
Step-by-step playbook for migrating a pytorch/pytorch .github/workflows/.yml from EC2 to OSDC (ARC) runners — covers both dial-up and 100% opt-in patterns, with the inputs that must be plumbed…
amd/skills
Benchmarks LLM inference and drives GPU kernel optimization with Magpie.
amd/Quark
Diagnose failed Quark installation, PTQ execution, script generation, or export attempts.
pytorch/executorch
Builds ExecuTorch from source: the Python package, C++ runtime, model runners, Android and iOS cross-compilation and backend-specific builds, with environment checks.
ByteDance-Seed/VeOmni
A skill your agent uses for ANY bug, error, crash, wrong output, loss divergence, gradient explosion, test failure, CUDA error, distributed training hang, checkpoint load failure, or unexpected…
Categories
Condensed debugging method and tool recipes for Unix, Python and PyTorch programs: crashes, hangs, segfaults, wrong output, CUDA OOM, NaN values and slowness. Debugging here follows one loop. Reproduce the failure reliably, shrink the workload so each run is fast, localize the problem by bisecting commits, files or ranks, get a precise signal such as a real traceback, a stack dump, a syscall trace or a NaN check, then change one thing at a time and verify.
The Art of Debugging fits situations like: A program crashes, segfaults or hangs and the cause is unclear; A PyTorch run produces NaN or Inf values or wrong numbers; training runs out of CUDA memory or stalls across nodes or GPUs; A Python program is too slow and needs profiling.
Run `npx skills add stas00/the-art-of-debugging --skill art-of-debugging -a claude-code`. Or copy the skill folder (the stas00/the-art-of-debugging repository) into .claude/skills/art-of-debugging in your project. Claude Code loads it when a task matches its description.
Run `npx skills add stas00/the-art-of-debugging --skill art-of-debugging -a codex`. Or copy the skill folder (the stas00/the-art-of-debugging repository) into .agents/skills/art-of-debugging in your project. Codex loads it when a task matches its description.
Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add stas00/the-art-of-debugging --skill art-of-debugging -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/art-of-debugging, .gemini/skills/art-of-debugging, .github/skills/art-of-debugging and .opencode/skills/art-of-debugging in your project.
Going by SKILL.md and its folder, The Art of Debugging needs Python and a shell for the scripts in its folder and the command-line tools its instructions call (python, pip, git and conda). Our summary lists: Debugging tools named in the recipes, such as gdb, strace and py-spy.
SKILL.md names 1 domain. As links in the text: github.com. This is read from the text; nothing was executed.
Our automated static check of SKILL.md found notes only (runs commands with sudo), nothing it rates as a warning. It is not a guarantee. Review the folder before installing.
The Art of Debugging is published under the CC-BY-SA-4.0 licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.
About 6.1k tokens (SKILL.md is roughly 24k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.
Skills that share tags, products or a category with The Art of Debugging: Ascendc (ascend-ai-coding/awesome-ascend-skills, 174 stars), Migrate Workflow Ec2 To Osdc (pytorch/test-infra, 113 stars), Magpie Kernel Evaluator (amd/skills, 408 stars) and Quark Torch Debug (amd/Quark, 182 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.
stas00 (a GitHub user) maintains it in stas00/the-art-of-debugging, which has 1,736 GitHub stars. The repository was last updated on October 6, 2026.
Source: stas00/the-art-of-debugging on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.