ML Doctor (mldoct) 🩺
ML Doctor is an automated developer tool for PyTorch engineering workflows. It combines AST-based static code analysis with machine learning to identify training anti-patterns, repair missing loop declarations, and diagnose convergence trajectories.
Capabilities
- AST Static Code Linter (
check): Analyzes PyTorch scripts for uncalledzero_grad(), omittedmodel.eval(), double softmax activations, and missing gradient clipping. - Automated Fix Engine (
--fix): Injects missing optimization steps (optimizer.zero_grad(),model.eval()) directly into the target file while retaining backups. - OOM Sentinel: Detects un-detached loss tensor accumulation in loops (
+= loss), preventing silent CUDA memory leaks. - Live Process Watchdog (
watch): Executes training scripts as a monitored process, interceptingNaN,Inf, and exploding loss spikes in real time. - Curve Diagnostic Engine (
diagnose): Evaluates training logs (train_loss,val_loss,grad_norm) using an embedded gradient boosted model. - Directory Discovery: Diagnoses whole log directories automatically without requiring explicit file paths.
- Report Generation (
--export-report): Writes diagnosis summaries directly to Markdown.
Installation
pip install mldoct
Usage Guide
1. Static Linting & Auto-Fixing
# Scan a script for loop bugs
mldoctor check train.py
# Scan and automatically patch omissions
mldoctor check train.py --fix
2. Live Training Watchdog
# Monitor active training execution
mldoctor watch train.py --epochs 20
3. Metric Trajectory Diagnosis
# Diagnose a specific CSV
mldoctor diagnose metrics.csv
# Auto-discover the latest CSV in a log folder and export a report
mldoctor diagnose ./logs/ --export-report
4. Package Information
mldoctor info
Author & Maintainer
- Author: Shravan Gupta
- Website: shravangupta.dev
Release files for mldoct 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mldoct-0.2.0.tar.gz | 8.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mldoct-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 18.0 kB
Release files / mldoct-0.2.0.tar.gz
| Download URL | mldoct-0.2.0.tar.gz |
|---|---|
| Size | 8.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
643995735bd961cd71af2cbd733070254b43393bf3262a872327450c4d0746fd
|
|
BLAKE2b-256 checksum How to use checksums |
1dedad1801d3e97366250addf2b5ce37401835468d75fca32d8d0a49bcb8e14f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.0
|
Release files / mldoct-0.2.0-py3-none-any.whl
| Download URL | mldoct-0.2.0-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
33cdf02480551f3a2a167c468106ced656cee83f828dd7243834908a4c1c893d
|
|
BLAKE2b-256 checksum How to use checksums |
f32360e3e532fa1035f2e34092bc77a60d3972fce4fe0f1c9ce9f3be6a1d6a8c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.0
|