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 Distribution

mpnewton-0.0.1.tar.gz (1.1 MB view details)

Uploaded Source

Built Distribution

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

mpnewton-0.0.1-py3-none-any.whl (1.1 MB view details)

Uploaded Python 3

File details

Details for the file mpnewton-0.0.1.tar.gz.

File metadata

  • Download URL: mpnewton-0.0.1.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for mpnewton-0.0.1.tar.gz
Algorithm Hash digest
SHA256 a633b6800a312b682098387b5a76da709a49b2dbe0deda682ec707bb0dc6cec7
MD5 181a1d44474b506e1f42e3ea7b6e4eac
BLAKE2b-256 9137c219d961b54573f5bf5721435381e19fda2ef2cdcc927be0a41836ddd89a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mpnewton-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 1.1 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.0

File hashes

Hashes for mpnewton-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ef1b9e3c0c861334f407e01f236863d5830ba7f44654e033c9e60690507ee6fc
MD5 ba2ac5175c78056149321e6d48b31cd4
BLAKE2b-256 85a5cda819384b6ca415cc21e629d60a745c5742c63dba10ccb4db8b823d2116

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