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

python -m pip install .
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.

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

Built distribution (wheel)

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

Total release size: 22.6 kB

Release files / mndopt-0.1.0.tar.gz

Download URL mndopt-0.1.0.tar.gz
Size 14.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7e112ff91fe27d464c812e8598b88d1a50dd17f8b49dbef0a25a1cf120d65d44
BLAKE2b-256 checksum
How to use checksums
35ac06f0be2cebddc6d26834f7f7202be3cdf72b86b707aad44d94178db6a9f0
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.0-py3-none-any.whl

Download URL mndopt-0.1.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b0e92044a264ba61697005f5ebd2dd26a038148510abef790547650d209bf5e
BLAKE2b-256 checksum
How to use checksums
d7e64a1fee15671dd2fd9ee1832236cefbdfb5a554cdc8bcaaffeb51c4194fbc
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.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.

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