Training failed? NeuralDBG tells you why. It hooks into your PyTorch training loop, detects what went wrong (vanishing gradients, exploding gradients, data anomalies), and pinpoints the exact layer and step — so you fix it in seconds, not hours.
NeuralDBG treats training as a semantic trace of learning dynamics rather than a black box. It extracts meaningful events and provides causal hypotheses about training failures, enabling researchers to:
- Identify gradient health transitions (stable -> vanishing/saturated)
- Detect activation regime shifts (normal -> saturated/dead)
- Detect optimizer instability (loss plateaus, spikes, divergence)
- Catch data anomalies (NaN, Inf, distribution shifts)
- Track propagation of instabilities through network layers
- Generate ranked causal explanations for training failures
Unlike traditional monitoring tools (TensorBoard, Weights & Biases), NeuralDBG focuses on causal inference rather than metric tracking.
| Component | Availability | Role |
|---|---|---|
| NeuralDBG | Public (PyPI) | Causal diagnostics in your training loop |
| Diagnostic Workspace | Private beta | Visual causal graphs and hypothesis explorer |
| Neural Agent | Private beta | Auto-remediation from causal hypotheses |
Request early access: open an issue with label suite-access.
Or locally: python examples/quickstart_interactive.py
Reproducible causal accuracy on synthetic failures (details):
python -m benchmark_public.runLatest results: benchmark_public/results.json
| Feature | TensorBoard / W&B | NeuralDBG |
|---|---|---|
| What it shows | Graphs of loss/accuracy over time | Why the loss spiked or vanished |
| Diagnosis | Manual inspection of curves | Automated causal hypotheses |
| Actionable? | You guess the fix | Suggests root causes (LR, Init, Data) |
| Integration | Separate dashboard | One line of code in your loop |
| Privacy | Data sent to cloud | 100% Local (unless you opt-in) |
"TensorBoard tells you when it failed. NeuralDBG tells you why."
- Tier 1 Black-Swan detection: 96% — GNN 88%, MoE 100%, Diffusion 100% (104/108 bugs detected)
- Tier 2 Black-Swan detection: 94% — FlashAttention 100%, Neural ODE 100%, Quantized 83% (102/108)
- 200-architecture validation — 79% global detection across 5 families (MLP/CNN/RNN/Transformer/Hybrid)
- NeuralPrune v0.1 — Non-destructive redundancy diagnostic: dead neurons, low-rank weights, quantization opportunities
- LSTM/GRU support — Forward hooks unwrap RNN output tuples. Per-gate gradient tracking (input/forget/cell/output)
- Architecture fuzzer — 94% crash rate across 50 randomly generated architectures
- Stress test suite — 15/15 tests pass: 10x gradients, NaN/Inf, fp16, 100-layer depth, 1K token attention
- GPU v4 model — Qwen2-0.5B + LoRA trained on 538 examples across 5 architecture families, 92.3% accuracy
- Aquarium web dashboard — Zero-dependency HTML causal viewer. Open Aquarium
- 4 upstream PyTorch PRs — svdvals NaN, F.normalize zero-input, gradient health tests, varlen_attn NaN fix
- 100% detection on DeepMLP (6/6 bugs) | 96% Tier 1 black-swans | 94% Tier 2 black-swans
- 4 upstream PRs submitted to PyTorch | CI benchmark workflow on GitHub Actions
- E2E RNN pipeline — detect→diagnose→fix→validate on LSTM. 2/4 bugs auto-fixed.
- Semantic Event Extraction: Detects meaningful transitions in training dynamics
- Causal Compression: Identifies first occurrences and propagation patterns
- Post-Mortem Reasoning: Provides ranked hypotheses about failure causes
- Optimizer Instability Detection: Tracks loss plateaus, spikes, and divergence
- Data Anomaly Detection: Catches NaN, Inf, and distribution shifts in inputs
- Event Collapsing: Merges sequential events into summary traces
- Compiler-Aware: Operates at module boundaries to survive torch.compile
- Non-Invasive: Wraps existing PyTorch training loops without code changes
- Minimal API: Focused on explanations, not raw data dumps
- Diagnostic package export: JSON export for the Neural Suite visualizer (private beta)
pip install neuraldbgimport torch
import torch.nn as nn
from neuraldbg import NeuralDbg
# Your existing model and training setup
model = nn.Sequential(nn.Linear(10, 5), nn.ReLU(), nn.Linear(5, 1))
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
criterion = nn.MSELoss()
# Wrap your training loop
with NeuralDbg(model) as dbg:
for step, (inputs, targets) in enumerate(dataloader):
optimizer.zero_grad()
outputs = model(inputs)
loss = criterion(outputs, targets)
loss.backward()
dbg.record_loss(loss.item())
optimizer.step()
# After training failure, query for explanations
explanations = dbg.explain_failure()
print(explanations[0]) # "Gradient vanishing originated in layer 'linear1' at step 234..."# Get ranked causal hypotheses for the failure
hypotheses = dbg.get_causal_hypotheses()
# Query specific causal chains
chain = dbg.trace_causal_chain('vanishing_gradients')
# Check for coupled failures
couplings = dbg.detect_coupled_failures()
# Export diagnostic package (JSON) for Neural Suite visualizer
dbg.export_aquarium_package('debug_session.json')with NeuralDbg(model) as dbg:
for step in range(num_steps):
dbg.step = step
output = model(inputs)
loss = criterion(output, targets)
loss.backward()
dbg.record_loss(loss.item())
optimizer.step()
# Detect loss plateaus, spikes, or divergence
hypotheses = dbg.explain_failure("optimizer_instability")
for h in hypotheses:
print(h.description)Data anomalies (NaN, Inf, distribution shifts) are detected automatically from layer inputs during the forward pass:
with NeuralDbg(model) as dbg:
# ... training loop ...
pass
hypotheses = dbg.explain_failure("data_anomaly")
for h in hypotheses:
print(h.description) # "NaN values detected in input to layer 'linear1'..."Validated on 200 architectures, 1200 bug injections — the most comprehensive ML debugging tool validation to date.
| Family | Configs | Detection | Status |
|---|---|---|---|
| MLP (deep, residual, bottleneck) | 50 | 93% (280/300) | ✅ |
| CNN (Conv2d, varying kernel/depth/norm) | 40 | 91% (219/240) | ✅ |
| Transformer (encoder, varying heads/depth) | 40 | 92% (221/240) | ✅ |
| Hybrid non-RNN (CNN+MLP, Attention+MLP) | 12 | 86% (62/72) | ✅ |
| Feed-Forward Total | 142 | 91% | ✅ |
| Family | Configs | Detection | Status |
|---|---|---|---|
| RNN (LSTM/GRU, varying depth/width/bidir) | 40 | 49% (117/240) | |
| Hybrid with RNN | 18 | 10% (18/180) |
| Bug | Detection | Difficulty |
|---|---|---|
| Exploding gradients | 91% | Easy |
| Optimizer divergence | 91% | Easy |
| NaN in data | 83% | Moderate |
| Dead activations (bias) | 71% | Moderate |
| Zero initialization | 71% | Moderate |
| Vanishing gradients (sigmoid) | 44% | Hard |
Reproduce: python validate_combinatorial.py --full (200 configs, ~10 min on CPU).
Detailed results: combinatorial_results.json |
| Failure Type | Description |
|---|---|
vanishing_gradients |
Root cause + saturation coupling |
exploding_gradients |
First layer to explode |
dead_neurons |
Neuron death in activation layers |
saturated_activations |
Activation saturation patterns |
optimizer_instability |
Loss plateaus, spikes, divergence |
data_anomaly |
NaN/Inf/distribution shift in inputs |
- Semantic Event Extractor: Detects meaningful transitions in learning dynamics
- Causal Compressor: Identifies patterns and propagation in training failures
- Post-Mortem Reasoner: Generates ranked hypotheses about failure causes
- Compiler-Aware Monitor: Operates at safe boundaries for optimization compatibility
| Event Type | Source | Detects |
|---|---|---|
gradient_health_transition |
Backward hooks | Vanishing, exploding, saturated gradients |
activation_regime_shift |
Forward hooks | Dead neurons, saturated activations |
optimizer_instability |
record_loss() |
Loss plateaus, spikes, divergence |
data_anomaly |
Forward hooks (inputs) | NaN, Inf, distribution shifts |
| Edition | Package | License | Features |
|---|---|---|---|
| Core | pip install neuraldbg |
MIT | Hooks, events, export JSON, basic heuristics |
| Engine | pip install neuraldbg-engine |
Proprietary | Full causal inference, detailed hypotheses, coupling detection |
The Core edition works standalone with basic heuristic fallbacks. Install the Engine for advanced causal reasoning.
- ML Researchers seeking causal explanations for training failures
- PhD Students analyzing learning dynamics in novel architectures
- Research Engineers understanding optimization instabilities
- PyTorch only
- Focus on semantic events, not tensor inspection
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
make bootstrap
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # WindowsMIT License - see LICENSE.md for details.
- Landing page — branding and suite overview
- PyTorch support matrix
- CHANGELOG.md - Version history and notable changes
- logic_graph.md - System architecture and data flow
- docs/PHASE2_DOGFOODING.md - Detailed dogfooding scenarios
If you use NeuralDBG in your research, please cite:
@misc{neuraldbg2026,
title={NeuralDBG: A Causal Inference Engine for Deep Learning Training Dynamics},
author={SENOUVO Jacques-Charles Gad},
year={2026},
url={https://github.com/LambdaSection/NeuralDBG}
}
