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

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.0
File Size Uploaded Provenance Actions
nn_htop-0.1.0.tar.gz 704.2 kB With provenance Details for nn_htop-0.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 714.0 kB

Release files / nn_htop-0.1.0.tar.gz

Download URL nn_htop-0.1.0.tar.gz
Size 704.2 kB
Tags Source
SHA-256 checksum
How to use checksums
2bac7ca71fde9397bc219bd81effc425e81ac7f91f526a32674a0b77acae00c2
BLAKE2b-256 checksum
How to use checksums
1696d5246c36d7524b5793665ab8366d09fd44318306d16e621bbb4fb61ba11e
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.0-py3-none-any.whl

Download URL nn_htop-0.1.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ff367f2f2bbfb13c629a6e866ec20387919c488c0f71e23d42057298d911e940
BLAKE2b-256 checksum
How to use checksums
436c1da0c384c6ef6d6f59de3867f78436d8d038181ea9d0daba43f55aea8f70
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.0

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