debugging-toolkit
Skill0 starsChanged 2 days agoMITView on GitHub
Numerical debugging in Julia: localise the first wrong value, rule dtype and precision in or out, then fix the cause. Use when a Julia program fails or returns a wrong number.
In this repository55 other files it gives its agents.
- advanced-optimizationSkill
- bayesian-inferenceSkill
- bayesian-pinnSkill
- bayesian-ude-workflowSkill
- catalyst-reactionsSkill
- continuum-mechanics-and-rheologySkill
- control-theorySkill
- creating-julia-appSkill
- differential-equationsSkill
- differentiationSkill
- equation-discoverySkill
- experiment-trackingSkill
- fem-feaSkill
- julia-graph-neural-networksSkill
- julia-languageSkill
- julia-ml-and-dlSkill
- julia-model-deploymentSkill
- julia-paper-implementationSkill
- julia-pro-helpSkill
- julia-pro-modeSkill
- julia-reinforcement-learningSkill
- modeling-toolkitSkill
- neural-pdeSkill
- nonlinear-dynamicsSkill
- numerical-methods-implementationSkill
- package-development-workflowSkill
- performance-tuningSkill
- physical-learning-systemsSkill
- playbook-debugSkill
- playbook-model-validateSkill
- playbook-package-releaseSkill
- playbook-paper-implementSkill
- playbook-perfSkill
- playbook-test-specSkill
- principle-both-sidesSkill
- principle-breakingSkill
- principle-file-is-truthSkill
- principle-gateSkill
- principle-limitsSkill
- principle-loud-failureSkill
- principle-one-stepSkill
- principle-proof-listSkill
- principle-rebuttalSkill
- principle-runtime-surfaceSkill
- principle-three-boundsSkill
- principle-three-clocksSkill
- scientific-visualizationSkill
- sciml-and-diffeqSkill
- setup-julia-proSkill
- signal-processingSkill
- simulation-and-hpcSkill
- statistical-physicsSkill
- symbolic-mathSkill
- web-development-juliaSkill
- zarr-cloud-arraysSkill
The file
Files
Numerical debugging
A wrong number is a different failure from a crash: there is no stack, no exception, and the line that produced it ran without complaint. The work is to find the first place the value diverges from what it should be, which is why the order below starts at reproduction and not at a hypothesis.
The order
| Step | Done when |
| Reproduce | the same wrong value comes out of a seed plus one minimal input, in the environment recorded with it |
| Localise | the first line where the value diverges is named, with the value before and after |
| Rule precision in or out | the same run in Float64 either changes the answer or does not, and that is stated |
| Bisect | the commit that introduced it is identified, not guessed |
| Fix the cause | the reproduction goes green with the fix and stays red without it |
The localisation step is where most time goes and where most shortcuts fail: bisecting inside a function range finds a suspect but not a line, and a suspect gets rewritten.
Julia
@code_warntype f(x) # Any or Union in the body: the instability is here
@inferred f(x) # fails in the test suite instead of in production
@allocated f(x) # bytes per call; 0 means allocation-free
@btime f($x) # time and allocations, via BenchmarkTools
using Debugger; @enter f(x) # step through when reading is not enoughA type instability shows up as a boxed value and a 10-100× slowdown long before it shows up as a wrong answer, so it is worth checking whenever a numerical function is slower than its arithmetic.
NaN and infinity
| Signal | Likely cause | Check |
| NaN at step 1 to 3 | learning rate or an unnormalised input | run one step with the rate divided by 100 |
| NaN spreading from one variable | divide by zero or log(0) | clip the argument, print the argument not the result |
| inf then NaN | overflow in Float32 (finfo.max ≈ 3.4e38) | rerun in Float64; if it survives, the model is wrong, not the dtype |
| gradient exploding, value fine | long product of Jacobians | clip by global norm, then check whether the clip is doing the work |
| NaN only at the boundary | masked or padded entries entering a reduction | print the mask, not the tensor |
Reproducibility
Pin the seed, the dtype, and the thread count before comparing two runs; a difference that survives all three is a real difference. A threaded reduction can change the last bits with the thread count, which is why a race is compared against the serial run before the code is blamed.
Done when
The failure reproduces from a seed and a minimal input; the first wrong value is localised to a line rather than a function; precision and dtype are ruled in or out by rerunning in Float64; the change that introduced it is identified by bisect; and the reproduction turns green with the fix while staying red without it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

