Metadata-Version: 2.4
Name: mpnewton
Version: 0.0.1
Summary: A package implementing mixed-precision optimizers and tools to analyze their convergence.
Project-URL: Documentation, https://gcarrino.gitlabpages.inria.fr/mpnewton/
Project-URL: Repository, https://gitlab.inria.fr/gcarrino/mpnewton
Project-URL: Bug Tracker, https://gitlab.inria.fr/gcarrino/mpnewton/-/issues
Author-email: Giuseppe Carrino <giuseppe.carrino@ens-lyon.fr>, Elisa Riccietti <elisa.riccietti@ens-lyon.fr>, Theo Mary <theo.mary@lip6.fr>, Nicolas Brisebarre <nicolas.brisebarre@ens-lyon.fr>
License-Expression: BSD-2-Clause
License-File: AUTHORS.md
Keywords: mixed precision,newton's method,optimization
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.10
Requires-Dist: ml-dtypes>=0.5.4
Requires-Dist: numpy>=2.0
Description-Content-Type: text/markdown

## mpNewton

![License](https://img.shields.io/badge/License-BSD_2-blue.svg)

`mpNewton` is a python library that leverages NumPy/CuPy to provide a set of mixed precision optimizers for unconstrained optimization problems, as well as interfaces to implement custom ones.
An implementation of precision-aware Conjugate Gradient is also available.

## Get started with ``mpNewton``

Run the following command to install the ``mpNewton`` package from PyPI:

```bash
pip install mpnewton
```

Run the following commands to install from conda:

```bash
conda config --add channels conda-forge
conda config --add channels mpnewton
conda install mpnewton
```

## First steps

Optimize a given loss using mixed precision Newton:

```python3
import numpy as np
from mpnewton.optimizers.newton import Newton
from mpnewton.losses.examples.sinreg import SINREG
from mpnewton.losses.data_generator import DataGenerator
from mpnewton.optimizers.precision import PrecisionConfig

data_generator = DataGenerator(m=100, w_star=[1.0, 2.0])
sinreg, _ = SINREG.from_generator(generator=data_generator)

prec_set = PrecisionConfig(
    grad_dtype=np.float128,
    update_dtype=np.float64,
    solver_dtype=np.float32
)
optimizer = Newton(precision=prec_set)

w_star = optimizer.optimize(sinreg).w
```

## Authors

- Giuseppe Carrino
- Elisa Riccietti
- Theo Mary
- Nicolas Brisebarre

## Contribute to ``mpNewton``

You can contribute to ``mpNewton`` with bug report, feature request and merge request.

## Useful links

- Link to the documentation: [Gitlab pages](https://gcarrino.gitlabpages.inria.fr/mpnewton/)

## Running unit tests

```bash
    python3 -m unittest discover -s tests -p "test_*.py"
```