Skip to main content

A package implementing mixed-precision optimizers and tools to analyze their convergence.

Project description

mpNewton

License

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:

pip install mpnewton

Run the following commands to install from conda:

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

First steps

Optimize a given loss using mixed precision Newton:

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

Running unit tests

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mpnewton-0.0.2-py3-none-any.whl (863.6 kB view details)

Uploaded Python 3

File details

Details for the file mpnewton-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: mpnewton-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 863.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for mpnewton-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4be674ab935fa2035d37c683a65513d18dfb96f1eb79e19a29b4a73a2af17489
MD5 d1e4b14db06b5f04c95cba9674c56396
BLAKE2b-256 00cd06289ae74e3afc8bc35de1de7d61f6c9ef91fedec5e4bc551aef5e566f22

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page