Somax
Second-Order Methods in JAX
Somax is a JAX-native library for composable second-order optimization. It combines curvature operators, solvers, damping, preconditioners, and update transforms into flexible optimization methods.
Features:
- Composable: combine curvature, solvers, damping, preconditioners, and update rules.
- Matrix-free: compute curvature products without forming dense matrices.
- JAX-first: JIT-compiled steps with explicit control over execution.
- Optax integration: apply standard Optax transformations to computed directions.
- Research-friendly: swap components, run ablations, and prototype new methods.
The catfish in the logo is a small nod to som, the Belarusian word for catfish. A quiet bottom-dweller, but not a first-order creature.
Installation
Install JAX for your hardware, then:
pip install python-somax
For development:
git clone https://github.com/cor3bit/somax.git
cd somax
pip install -e ".[dev]"
The lineax package is optional and needed only for CG with backend="lineax".
Quickstart
A minimal stochastic Gauss-Newton training loop for multiclass classification:
import jax
import jax.numpy as jnp
import somax
def predict_fn(params, x):
h = jnp.tanh(x @ params["W1"] + params["b1"])
return h @ params["W2"] + params["b2"]
rng = jax.random.PRNGKey(0)
k1, k2, k3, k4 = jax.random.split(rng, 4)
params = {
"W1": 0.1 * jax.random.normal(k1, (16, 32)),
"b1": jnp.zeros((32,)),
"W2": 0.1 * jax.random.normal(k2, (32, 10)),
"b2": jnp.zeros((10,)),
}
batch = {
"x": jax.random.normal(k3, (64, 16)),
"y": jax.random.randint(k4, (64,), 0, 10),
}
method = somax.sgn_ce(
predict_fn=predict_fn,
learning_rate=0.1,
lam0=1.0,
maxiter=10,
tol=1e-4,
)
state = method.init(params)
@jax.jit
def train_step(params, batch, state, rng):
return method.step(params, batch, state, rng)
for step in range(10):
step_rng = jax.random.fold_in(rng, step)
params, state, info = train_step(params, batch, state, step_rng)
For more examples, see Usage: A paper in a few lines.
Citation
Mikalai Korbit and Mario Zanon, "Second-Order, First-Class: A Composable Stack for Curvature-Aware Training", ECML PKDD 2026, arXiv.
@inproceedings{korbit2026second,
title={Second-Order, First-Class: A Composable Stack for Curvature-Aware Training},
author={Korbit, Mikalai and Zanon, Mario},
booktitle={Joint European Conference on Machine Learning and Knowledge Discovery in Databases},
pages={90--105},
year={2026},
organization={Springer}
}
License
Apache-2.0
Metadata
Release files for python-somax 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python_somax-1.1.0.tar.gz | 53.2 kB | Without provenance | Details for python_somax-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_somax-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for python_somax-1.1.0-py3-none-any.whl |
Total release size: 128.2 kB
Release files / python_somax-1.1.0.tar.gz
| Download URL | python_somax-1.1.0.tar.gz |
|---|---|
| Size | 53.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9c8e45a479ede1132003861d12dcb175b1eb9bebc9feacb2387a920f8fd6d345
|
|
BLAKE2b-256 checksum How to use checksums |
e7cc4624888071c247ca9733c7ac619b7d52a63f06e880d5748530b5f3d2e381
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / python_somax-1.1.0-py3-none-any.whl
| Download URL | python_somax-1.1.0-py3-none-any.whl |
|---|---|
| Size | 74.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
53b7871e706d5c9e7ba5115dacf47c55dbc8fe13cba59740de426595ea06743a
|
|
BLAKE2b-256 checksum How to use checksums |
7fcc4b87e4bf0fec1b1771f66920bcaa269eb2de78bebcdb7a2622de67bd6e6a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for python-somax 1.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.