Skip to main content

nn-htop

nn-htop

A terminal-based monitor for PyTorch neural network layer activations and gradient norms (htop for PyTorch neural networks).

Installation

pip install nn-htop

Quickstart

Run the built-in demonstration harness (a 3-layer MLP training on synthetic tensor batches):

nn-htop

Integration

Attach Monitor to any torch.nn.Module using context-managed hook lifecycle and launch the non-blocking Textual interface:

import torch
import torch.nn as nn
from nn_htop import Monitor, launch_tui

model = nn.Sequential(
    nn.Linear(128, 64),
    nn.ReLU(),
    nn.Linear(64, 10),
)

with Monitor(model) as monitor:
    # Launches Textual TUI; non-blocking telemetry reads at 5 FPS
    launch_tui(monitor)

Manual Training Loop Integration

If integrating into an existing custom training workflow:

import threading
from nn_htop import Monitor, launch_tui

model = MyCustomModel()

with Monitor(model) as monitor:
    # Monitor registers full backward hooks and forward hooks on all leaf layers.
    # Metrics (mean activation, L2 gradient norm) are stored in a thread-safe state dictionary.
    launch_tui(monitor, train_fn=my_training_loop)

Architecture

  • Hook Instrumentation: Attaches register_forward_hook (mean activation tracking) and register_full_backward_hook (L2 gradient norm) to leaf modules. Automatically overrides inplace=True during monitoring to prevent autograd graph conflicts.
  • Memory Safety: Tensors are detached and reduced to Python floats immediately inside hook callbacks to eliminate computational graph retention.
  • Decoupled Telemetry: PyTorch training threads write strictly to atomic state dictionaries; the UI polls via set_interval(0.2) at 5 FPS to guarantee zero impact on training throughput.

Metadata

Release files for nn-htop 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nn-htop 0.1.2
File Size Uploaded Provenance Actions
nn_htop-0.1.2.tar.gz 704.8 kB With provenance Details for nn_htop-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nn-htop 0.1.2
File Interpreter ABI Platform Actions
nn_htop-0.1.2-py3-none-any.whl Python 3 none any Details for nn_htop-0.1.2-py3-none-any.whl

Total release size: 714.8 kB

Release files / nn_htop-0.1.2.tar.gz

Download URL nn_htop-0.1.2.tar.gz
Size 704.8 kB
Tags Source
SHA-256 checksum
How to use checksums
b5cf4e5cbc79374e653fb4fec47237c3a8d5ff9cd6651cfa25a4ac10148bd542
BLAKE2b-256 checksum
How to use checksums
412090145d2933eb7b10cc318c4c74d73cc7a20f3e90c54736fef2b902c65d8e
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 Oct 13, 2026.

Transparency log

Release files / nn_htop-0.1.2-py3-none-any.whl

Download URL nn_htop-0.1.2-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3b0d1f50df11c171fecef552d84228adff32bc1adc5a2756e71bb95a11138d33
BLAKE2b-256 checksum
How to use checksums
1b265763e6e727583fbb9fbeda5678c16dc9698ecc5c528cd0e4f9d32b8375e2
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 Oct 13, 2026.

Transparency log

Security for nn-htop 0.1.2

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nn_htop-0.1.2.tar.gz

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 Oct 13, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page