An enterprise-grade PyTorch monitoring and analytics toolkit.
Project description
🔥 GradLens
An enterprise-grade PyTorch monitoring and analytics toolkit.
🚀 Quick Start (v0.1)
gradlens provides a lightweight, zero-overhead monitoring engine for your PyTorch training loops.
Installation
pip install gradlens
Usage
Use the gl.watch() context manager to automatically attach hooks to your model. The monitor.log() method captures statistics with near-zero performance impact.
import torch
import torch.nn as nn
import gradlens as gl # Import the library
# 1. Define your model and data (example)
model = nn.Sequential(nn.Linear(10, 20), nn.ReLU(), nn.Linear(20, 1))
data = torch.randn(16, 10)
target = torch.randn(16, 1)
optimizer = torch.optim.SGD(model.parameters(), lr=0.01)
criterion = nn.MSELoss()
# 2. Wrap your training loop with gl.watch()
try:
with gl.watch(model) as monitor:
for _ in range(10): # Example training loop
# --- Training Step ---
optimizer.zero_grad()
output = model(data)
loss = criterion(output, target)
loss.backward() # Hooks capture data here
optimizer.step()
# 3. Log the loss
monitor.log(loss=loss.item())
except Exception as e:
print(f"Training failed: {e}")
finally:
# 4. Get the results
history = monitor.get_history()
print("\n--- Training History ---")
print(f"Total steps: {len(history['loss'])}")
print(f"Final loss: {history['loss'][-1]}")
# Show stats for the last step
last_stats = monitor.get_stats()
print("\n--- Last Step Stats ---")
print(f"Gradient Norms: {last_stats['grad_norm']}")
print(f"Dead Neuron %: {last_stats['dead_neuron_pct']}")
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file gradlens-0.2.0.tar.gz.
File metadata
- Download URL: gradlens-0.2.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ccaeec553a6880bcdc5da9b7340c1ceccd4b4d92586ef8675aa10dc39c0bb507
|
|
| MD5 |
b184aef0899bfa93063a75b348752325
|
|
| BLAKE2b-256 |
086466659b1fbc1797c9728bf16393262eb666dbe276f5e3c0ce563e573e33cd
|
File details
Details for the file gradlens-0.2.0-py3-none-any.whl.
File metadata
- Download URL: gradlens-0.2.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
183aaa3f6d9a7455dc335b68faebf1cfad8c4c1c26521065a394bd553e2aa2ea
|
|
| MD5 |
ec5c33a93b75114cb18c76a70d19664b
|
|
| BLAKE2b-256 |
1b5800e0880c11a8334422c6f11eec4064e3a6eee6b8600340f1102356424834
|