Skip to main content

mndopt

PyTorch implementation of the Matrix Normal Diagonal (MND) optimizer from A Statistical Viewpoint on Adam, Shampoo and Muon by Tetiana Parshakova, Robert M. Gower, and Paulo Orenstein (2026).

Requires Python 3.10+ and PyTorch 2.2+.

pip install mndopt
import torch
from mndopt import MND

model = torch.nn.Linear(8, 4)
optimizer = MND(model.parameters(), lr=0.003)

x, y = torch.randn(32, 8), torch.randn(32, 4)
optimizer.zero_grad()
loss = torch.nn.functional.mse_loss(model(x), y)
loss.backward()
optimizer.step()

Matrices use MND; other parameters use AdamW. Both use decoupled weight decay. Set matrix=False to force AdamW in a parameter group:

optimizer = MND([
    {"params": model.weight, "matrix": True},
    {"params": model.bias, "matrix": False, "lr": 0.001},
], weight_decay=0.01)

Defaults: lr=0.003, beta=0.925, eps=1e-9, weight_decay=0. AdamW uses adam_betas=(0.95, 0.95) and adam_eps=1e-8.

From a clone, run the tests and CPU example:

pip install -e '.[test]'
pytest -q
python examples/regression.py --steps 300

Citation

@misc{parshakova2026statistical,
  title  = {A Statistical Viewpoint on Adam, Shampoo and Muon},
  author = {Parshakova, Tetiana and Gower, Robert M. and Orenstein, Paulo},
  year   = {2026},
  eprint = {2610.24839},
  archivePrefix = {arXiv},
  primaryClass = {cs.LG},
  url    = {https://arxiv.org/abs/2610.24839}
}

Licensed under Apache 2.0.

Metadata

Release files for mndopt 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 mndopt 0.1.1
File Size Uploaded Provenance Actions
mndopt-0.1.1.tar.gz 14.1 kB Without provenance Details for mndopt-0.1.1.tar.gz

Built distribution (wheel)

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

Total release size: 22.6 kB

Release files / mndopt-0.1.1.tar.gz

Download URL mndopt-0.1.1.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
53ab806a8f3b40b37afdc963b8d483bb785b80ad5ae625569d512417aac72136
BLAKE2b-256 checksum
How to use checksums
0e51831c82dcfccb8ed9274130ae65d00e33699e88774f72306947ee02e109c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

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

Download URL mndopt-0.1.1-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2d5376ca1f47e8a639f1c4c9ae79ee16d4a5758dba3dbf9bdd91817b9b2a2cb7
BLAKE2b-256 checksum
How to use checksums
8a55574594ed55a22a92e3d420f21c6569cd2bb7a6827eac0fcfbd3a809b8c5a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.12

Security for mndopt 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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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