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.1

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.1
File Size Uploaded Provenance Actions
nn_htop-0.1.1.tar.gz 704.5 kB With provenance Details for nn_htop-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 714.4 kB

Release files / nn_htop-0.1.1.tar.gz

Download URL nn_htop-0.1.1.tar.gz
Size 704.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2c77030e17655989e17c9fb6871182d9e99ac19c883bac06dac6f91fc9e2ffcc
BLAKE2b-256 checksum
How to use checksums
c989afa644961cdcea7bc1fb85bb0f6f809bc9b3f2f9acb38596eafe28f07f0c
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 8, 2026.

Transparency log

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

Download URL nn_htop-0.1.1-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e92c7f06537815aad1f13aee78585d4dd1ad036581fffa0d04e12e5f04f9776b
BLAKE2b-256 checksum
How to use checksums
8e148fcf4c1e52fdeeaefd91b3f6c247ee371a66c6e4ae82b2363bc8d9387042
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 8, 2026.

Transparency log

Security for nn-htop 0.1.1

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.1.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 8, 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