Scan your whole stack
From OX Research Newsroom
Are you using thekaveh-nnx?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.5.0
thekaveh-nnx was last scanned on 26 Nov 2026 at version 0.5.0. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.5.0 LATEST | 26 Nov 2026 | No rules fired |
| 0.4.4 | 25 Nov 2026 | No rules fired |
| 0.4.3 | 23 Nov 2026 | No rules fired |
| 0.4.2 | 22 Nov 2026 | Not shown |
| 0.4.1 | 12 Oct 2026 | Not shown |
Findings for v0.5.0. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.5.0; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
NNx is a lightweight PyTorch toolkit for repeatable training, evaluation and visualization. It provides frozen configuration objects, a supervised train, evaluate and predict loop, callbacks, metrics, and content-addressed checkpoints that support resume. Your models and per-step logic stay replaceable, so one loop serves standard, graph and transformer networks and other training methods. NNx is for researchers and engineers who want transparent PyTorch code without a larger training platform.
NNModel train, evaluate and predict, with callbacks, schedulers, FP32/FP16/BF16 precision, gradient accumulation and clipping, declared metrics, and a multi-optimizer Trainer.The Capability reference describes each item with its entry points. Concepts explains how the parts fit together.
This documentation describes the source on main: NNx 0.5.0 and its unreleased changes.
Install the newest release from PyPI, then check its version:
pip install thekaveh-nnx
python -c "import nnx; print(nnx.__version__)"
The newest PyPI release can be older than this documentation. An older release lacks the features and extras added after it, as listed in the Changelog. In that case, install the current source instead:
pip install "thekaveh-nnx @ git+https://github.com/thekaveh/NNx.git@main"
pip install "thekaveh-nnx[domains] @ git+https://github.com/thekaveh/NNx.git@main" # with an extra
The requirements and extras below describe this version. pip warns when a requested extra does not exist in the version it installs.
The core install is torch, NumPy, pandas, scikit-learn and a few small utilities. import nnx loads no vision, graph or plotting stack. Those stacks are the vision, graph and plots extras, and domains installs all three. Using one without its extra raises an ImportError that names the extra.
NNx needs Python 3.11 or later and PyTorch 2.4 or later; the vision extra needs torchvision 0.19 or later. It is tested on Python 3.11 through 3.14. The PyTorch support matrix lists every tested combination and which have real CUDA evidence. Optional extras keep their own version constraints. The examples in examples/ run on CPU.
Add an extra to either install command, for example "thekaveh-nnx[graph,plots]".
pip install "thekaveh-nnx[vision]" # NNDataset (torchvision datasets)
pip install "thekaveh-nnx[graph]" # graph nets, NNGraphDataset, nnx.graph_tasks, nnx.link_tasks
pip install "thekaveh-nnx[plots]" # VisUtils, nnx.lr_finder, the NNRun chart (Plotly)
pip install "thekaveh-nnx[domains]" # vision + graph + plots
pip install "thekaveh-nnx[tensorboard]" # TensorBoardCallback
pip install "thekaveh-nnx[wandb]" # WandbCallback
pip install "thekaveh-nnx[onnx]" # NNModel.to_onnx (legacy exporter)
pip install "thekaveh-nnx[onnx-dynamo]" # NNModel.to_onnx(dynamo=True): adds onnxscript
pip install "thekaveh-nnx[onnx-runtime]" # ONNX Runtime CPU execution: nnx.export_conformance parity profiles
pip install "thekaveh-nnx[quantize]" # nnx.quantize_int8 (torchao PTQ INT8)
pip install "thekaveh-nnx[hub]" # safetensors checkpoints + HuggingFace Hub publish/load
pip install "thekaveh-nnx[embeddings]" # nnx.embeddings: FAISS export + sentence-transformers
pip install "thekaveh-nnx[lm]" # HF BPE tokenizer (train_bpe, NNTokenizerParams) + datasets
pip install "thekaveh-nnx[gguf-write]" # experimental NNx GGUF writer
pip install "thekaveh-nnx[viz]" # nnx.viz: summary + weight_histogram + activation_map + attribute + gradient_flow + netron_export (netron_export also needs [onnx])
pip install "thekaveh-nnx[viz-interactive]" # adds Netron browser viewer for nnx.viz.netron_export(launch=True)
pip install "thekaveh-nnx[jev]" # nnx.decisions.JevProvider (hosted Jev models)
pip install "thekaveh-nnx[optuna]" # nnx.search: budgeted experiment search
pip install "thekaveh-nnx[notebook]" # IPython clear_output for legacy function callbacks in notebooks
pip install "thekaveh-nnx[docs]" # local documentation build toolchain
For a reproducible contributor environment, install with the committed resolver state:
python -m pip install -r requirements-tools.txt
uv sync --all-extras --frozen
For an editable install with the test and lint toolchain, see CONTRIBUTING.md §1.
End-to-end CPU example — a tiny random-tensor classification run:
import torch
from torch.utils.data import DataLoader, TensorDataset
from nnx import (
NNModel, NNParams, NNModelParams, NNTrainParams,
NNOptimParams, NNSchedulerParams,
Activations, Devices, Losses, Nets, Optims,
EarlyStopping,
)
# 1. Data
X_train, y_train = torch.randn(256, 8), torch.randint(0, 3, (256,))
X_val, y_val = torch.randn(64, 8), torch.randint(0, 3, (64,))
train_loader = DataLoader(TensorDataset(X_train, y_train), batch_size=32, shuffle=True)
val_loader = DataLoader(TensorDataset(X_val, y_val), batch_size=32)
# 2. Model
net_params = NNParams(input_dim=8, output_dim=3, hidden_dims=[32, 16],
dropout_prob=0.1, activation=Activations.RELU)
model_params = NNModelParams(net=Nets.FEED_FWD, device=Devices.CPU,
loss=Losses.CROSS_ENTROPY)
model = NNModel(net_params=net_params, params=model_params)
# 3. Train
train_params = NNTrainParams(
n_epochs=10,
train_loader=train_loader,
val_loader=val_loader,
optim=NNOptimParams(name=Optims.ADAM, max_lr=1e-2,
momentum=(0.9, 0.999), weight_decay=5e-5),
scheduler=NNSchedulerParams(min_lr=1e-7, factor=0.5,
patience=3, cooldown=1, threshold=1e-3),
)
run = model.train(params=train_params, callbacks=[EarlyStopping(patience=5)])
# 4. Use it
print(f"trained {len(run.idps)} iterations; saved under runs/{run.id}/")
logits, classes = model.predict(X=X_val.numpy()) # returns PredictResult(logits=..., classes=...)
Run ids are content-addressed, so running the same script again in the same directory raises FileExistsError. Delete runs/ first, or pass overwrite_existing=True to NNTrainParams.
These patterns use the current source; an older PyPI release can lack some of them (see Release or source).
Change the Nets enum value passed to NNModelParams; NNModel constructs the underlying network for you:
NNModelParams(net=Nets.GRAPH_CONV, device=Devices.CPU, loss=Losses.CROSS_ENTROPY)
NNModelParams(net=Nets.GRAPH_SAGE, device=Devices.CPU, loss=Losses.CROSS_ENTROPY)
NNModelParams(net=Nets.GRAPH_ATT, device=Devices.CPU, loss=Losses.CROSS_ENTROPY)
# Then pass NNParams(..., n_heads=4) for GRAPH_ATT.
# Use NNGraphDataset (PyG NeighborLoader-backed) to feed batches.
See examples/ for runnable end-to-end scripts.
predict() returns logits and classes. For probabilities, declare the task explicitly:
from nnx import ProbabilitySpec
proba = model.predict_proba(X_val.numpy(), ProbabilitySpec(kind="categorical", class_axis=1))
proba.probabilities, proba.decoded, proba.sample_ids # softmax rows sum to 1; ids align with X_val
from nnx import set_seed, dataloader_worker_init_fn
set_seed(42) # pins torch / numpy / python / cudnn
DataLoader(..., worker_init_fn=dataloader_worker_init_fn)
NNTrainParams(seed=42, ...) # pins again at train() entry
run = model.train(params=NNTrainParams(n_epochs=10, ...))
# Build a fresh NNModel and continue from run's LAST checkpoint
# (optimizer topology/state, scheduler, scaler, epoch, loader generators,
# and Python/NumPy/PyTorch CPU/CUDA/MPS RNG state preserved):
NNModel(net_params=..., params=...).train(params=NNTrainParams(
n_epochs=10,
resume_from_run_id=run.id,
resume_from_checkpoint="last", # or "best" / "first" / "q1" / "q2" / "q3"
...
))
Callback and step state continues too. EarlyStopping's patience, the I-JEPA EMA target encoder, objective state and any object passed through train(..., components=[...]) are versioned components (nnx.components), validated before anything changes. resume_mode ("auto", "stateful" or "weights_only") chooses what is restored, and run.resume_status reports it.
resume_epochs="planned" continues a run's own plan up to its n_epochs; on an experiment plan, use resuming(..., epochs="planned"). With deterministic single-process training and in-process loaders, a run split at epoch boundaries equals the uninterrupted run bit for bit. Every checkpoint is a SHA-256-digested resume point, so a torn, mixed or corrupted one is refused with its reason (ResumePointError). The multi-optimizer Trainer resumes through NNTrainerParams.builder().resume_from(run_id). See Concepts §14.
Scope: Loader and sampler generators are restored by stable seed identity. Exact continuation still requires
train_loader.num_workers=0, because worker-local RNG state cannot be reconstructed. Resume happens at completed-epoch boundaries.
NNTrainParams(
...,
extra_metrics={
# Called as fn(y_true, y_pred): truth first, decoded predictions second.
"my_metric": lambda y_true, y_pred: float((y_true == y_pred).mean()),
},
)
# Available on idp.train_edp.extra / idp.val_edp.extra and survives NNRun.load.
# Declared metrics (labels / probabilities / continuous inputs, full-sample values)
# and one monitor for BEST, ReduceLROnPlateau and an EarlyStopping given it:
monitor = MonitorSpec(metric="nll", min_delta=0.01)
NNTrainParams(..., metrics=[MetricSpec("nll"), MetricSpec("brier")], monitor=monitor)
# ... model.train(params, callbacks=[EarlyStopping(monitor=monitor, patience=5)])
See Concepts §6.4: custom metrics register with nnx.register_metric, training records carry a whole-epoch train_summary and the epoch's monitor selection, and named-monitor runs never claim runs/best.
from nnx import VisUtils
fig = VisUtils.confusion_matrix(y_true, y_pred, class_names=["a","b","c"])
fig.show()
df = VisUtils.classification_report(y_true, y_pred) # DataFrame
from nnx import Devices
NNModelParams(net=Nets.FEED_FWD, device=Devices.get(), loss=Losses.CROSS_ENTROPY)
# Devices.get() picks MPS (Apple) > CUDA > CPU.
from nnx import PrecisionPolicy
NNModelParams(..., precision=PrecisionPolicy("bf16")) # CPU, or CUDA with bf16 support
NNModelParams(..., precision=PrecisionPolicy("fp16", fallback="fp32")) # CUDA fp16, else recorded fp32
An unsupported request fails before any run is reserved, unless it names a
fallback. run.precision records the requested and effective precision, the
fallback reason and TF32. The legacy mixed_precision=True (CUDA FP16,
silently FP32 elsewhere) keeps its meaning and run id. See
Quickstart §2.2.
By default the scheduler is ReduceLROnPlateau driven by the params dataclass. Pass kind= to switch:
from nnx import Schedulers
NNSchedulerParams(..., kind=Schedulers.COSINE_ANNEALING, T_max=100)
# Or: STEP, ONE_CYCLE, LINEAR_WARMUP_DECAY
from nnx import NNRun, NNCheckpoint, Checkpoints
run = NNRun.load(id="<md5>") # rehydrate idps + params
ckpt = NNCheckpoint.load(run=run.id, type=Checkpoints.BEST)
model = NNModel.from_checkpoint(checkpoint=ckpt)
from_checkpoint also replays persisted topology transforms before loading weights. In particular, QAT-produced LAST checkpoints record their torchao recipe and reload as converted quantized models without downstream prepare/convert code.

The architecture separates user-facing orchestration, per-batch extension hooks, callback lifecycle, and persisted run artifacts.
Reading the diagram top-to-bottom (summary):
NNModel (supervised) or Trainer (multi-optimizer for GAN / actor-critic).train_step_fn / eval_step_fn / trainer_step_fn hooks are the training extension bus. diffusion, paradigms, quantize, and embeddings provide hook-compatible factories; the diffusion, paradigm and embeddings steps share one step-finalization helper. The other specialization packages compose around the loop without hooks: model transforms (finetune, peft, prune, surgery), exchange formats (interop), inference utilities (generation) and diagnostics (viz).clock="epoch"), or once per committed optimizer update with NNSchedulerParams(clock="optimizer_update"). Paradigm and diffusion step factories also apply a NaN guard and gradient clipping.on_train_begin / on_epoch_begin / on_epoch_end / on_train_end to every registered listener (EarlyStopping, LRMonitor, ModelCheckpoint, TensorBoardCallback, WandbCallback).on_epoch_end, NNRun and NNCheckpoint commit durable state in order: history → LAST → phase/BEST → deferred callback checkpoints.Concepts §1 gives the full 8-layer breakdown, and Architecture gives the exact callback and commit ordering.
The documentation below covers the public API, architecture, extension contracts, and runnable examples.
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.