NeuralDBG
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.
Overview
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.
Neural Suite
| 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.
Try it in 60 seconds (Colab)
Or locally: python examples/quickstart_interactive.py
Public benchmark
Reproducible causal accuracy on synthetic failures (details):
python -m benchmark_public.run
Latest results: benchmark_public/results.json
Why NeuralDBG?
| 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."
Key Features
- 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)
Quick Start
Installation
pip install neuraldbg
Basic Usage
import 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..."
Inference API
# 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')
Optimizer Instability Detection
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 Anomaly Detection
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'..."
Supported Architectures
NeuralDBG has been validated across 9 architectures:
| Architecture | Failure Modes Tested |
|---|---|
| Transformer (nanoGPT) | Attention collapse, NaN softmax, LR warmup |
| GANs (DCGAN) | Vanishing, exploding, NaN injection |
| LLM fine-tuning (LoRA) | Catastrophic forgetting, loss spikes |
| Diffusion (DDPM) | NaN UNet, exploding gradients |
| LSTM / Time Series | Vanishing recurrent gradients |
| GNN (GCN/GAT) | Oversmoothing, deep GNN |
| RL (PPO-style) | Policy collapse, value explosion |
| torch.compile | Dynamo graph compatibility |
| DataParallel | Multi-GPU hook integrity |
Supported Failure Types
| 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 |
Architecture
Core Components
- 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 Types
| 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 |
Editions
| 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.
Target Users
- ML Researchers seeking causal explanations for training failures
- PhD Students analyzing learning dynamics in novel architectures
- Research Engineers understanding optimization instabilities
Limitations
- PyTorch only
- Focus on semantic events, not tensor inspection
Contributing
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
Developer Setup
make bootstrap
source .venv/bin/activate # Linux/macOS
# or
.venv\Scripts\activate # Windows
License
MIT License - see LICENSE.md for details.
Documentation
- 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
Citation
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}
}
Metadata
Release files for neuraldbg 1.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| neuraldbg-1.3.2.tar.gz | 25.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| neuraldbg-1.3.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 46.0 kB
Release files / neuraldbg-1.3.2.tar.gz
| Download URL | neuraldbg-1.3.2.tar.gz |
|---|---|
| Size | 25.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3bd8027144130b9ce5f30a67e2659db2b6e5aefd27bd3c6fa3e5365eddb5f8fb
|
|
BLAKE2b-256 checksum How to use checksums |
95c2bb0474ea24b03bdafbe2cf90b8f2d4b0be00e74aa375d95dc7f348018fd0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency logRelease files / neuraldbg-1.3.2-py3-none-any.whl
| Download URL | neuraldbg-1.3.2-py3-none-any.whl |
|---|---|
| Size | 21.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a365a2d5a4c0792280f556c65cbc6b6174e76c07b11a2ee36edd0987475fd93a
|
|
BLAKE2b-256 checksum How to use checksums |
9bcfd27bf75e7c321c7d91d3a85b04d35e574caa5e9bb397e8ec35ce6ca9a081
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Sep 17, 2026.
Transparency log