invexapi
A minimal, PyTorch-only toolkit for invex optimization: penalties with proven optimality certificates, and the solvers that use them.
Why invexity?
Invex functions are a strict generalization of convexity: every stationary point is still a global minimum, but the function itself need not be convex. That gives non-convex penalties (sparsity-promoting, non-smooth, highly structured) the same global-optimality guarantee convex optimization enjoys - without paying for it with local minima.
invexapi packages this idea as code: penalties that carry a machine-checkable
certificate of which mathematical class they belong to (convex, invex,
quasi-convex, quasi-invex), and generic solvers that read those certificates to
warn you when no optimality guarantee applies.
Install
pip install -e . # editable install
pip install -e ".[dev]" # + pytest, numpy for the test suite
pip install -e ".[examples]" # + deps used only by examples/
Quick start
import torch
from invexapi import QuasinormInvexPenalty
from invexapi.optim import FISTA
class DataFidelity:
def __init__(self, y): self.y = y
def value(self, x): return 0.5 * torch.sum((x - self.y) ** 2)
def grad(self, x): return x - self.y
y = torch.randn(100)
smooth = DataFidelity(y)
penalty = QuasinormInvexPenalty(lamb=0.1, q=0.5)
solver = FISTA(smooth, penalty, step=1.0)
x_hat, history = solver.run(y.clone())
Any object exposing the right methods (value, grad, prox) works as a
smooth/penalty/objective - the built-in penalties are just one plug-in
choice.
What's inside
Penalties (invexapi.penalties) - loss/penalty terms plus a certificate of
what's provably known about each one:
| Penalty | Form | Certified as |
|---|---|---|
QuasinormInvexPenalty(lamb, q) |
λ·|x|^q |
invex |
LogInvexPenalty(lamb) |
log(1+|x|) − |x|/(2+2|x|) |
invex |
TikhonovPenalty(lamb) |
λ/2·‖x‖² |
convex, invex, quasi-convex |
L1Penalty(lamb) |
λ·‖x‖₁ |
convex, invex, quasi-convex |
Certificates are attached explicitly and never inferred - convexity composes additively, but invexity does not, so a combined objective only carries a certificate someone has actually proven for it.
Solvers (invexapi.optim) - generic, decoupled from the penalties above:
GradientDescent- with optional Armijo backtracking line searchFISTA- accelerated proximal gradient forsmooth(x) + penalty(x)NonlinearCG- Polak-Ribière+ with automatic restartLinearizedADMM- forsmooth(x) + penalty(D@x)(e.g. total variation)
All four warn (never error) when run on an objective without a convex/invex certificate, since no global-optimum guarantee applies in that case.
Linear operators (invexapi.penalties.operators) - Identity and
FiniteDifference2D (2D total variation), each with a verified adjoint.
Structured documentation (invexapi.metadata) - design provenance,
rejected alternatives, and invariants as introspectable dataclasses rather than
prose, exportable as JSON for downstream tooling:
import invexapi
print(invexapi.metadata.dump_all_json(indent=2))
GPU support
Nothing in invexapi is device-specific - every operation derives its device
from its input tensors. Move your data to CUDA before calling a solver and
everything downstream follows:
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
x_hat, history = solver.run(y.to(device))
Testing
pytest
Penalty math is validated against independent NumPy reference implementations on fixed-seed random inputs, with no CUDA dependency anywhere in this repo.
Examples
See examples/ for denoising and deblurring scripts covering FISTA and
Linearized ADMM with total variation, using both the quasinorm and log invex
penalties. The ADMM/TV examples need a test image, fetched separately:
python examples/data/download.py
License
BSD 3-Clause, see LICENSE.
References
This library reproduces and generalizes results from the following papers:
- Pinilla, S., Sanabria, A., Bi, J., & Egiazarian, K. (2025). What makes neural networks trainable? Invexity as a structural design principle in AI.
- Pinilla, S., & Thiyagalingam, J. (2024). Global optimality for non-linear constrained restoration problems via invexity. International Conference on Learning Representations (ICLR), 2024, pp. 11990–12027.
- Pinilla, S., Mu, T., Bourne, N., & Thiyagalingam, J. (2022). Improved imaging by invex regularizers with global optima guarantees. Advances in Neural Information Processing Systems (NeurIPS), 35, pp. 10780–10794.
- Pinilla, S., Yeung, S.-L., & Thiyagalingam, J. (2024). Global convergence of alternating direction method of multipliers for invex objective losses. IEEE International Conference on Acoustics, Speech and Signal Processing (ICASSP) 2024, pp. 9361–9365.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file invexapi-0.1.3.tar.gz.
File metadata
- Download URL: invexapi-0.1.3.tar.gz
- Upload date:
- Size: 459.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad058ae9280934a6407cafcb638b6e712157934cf7daf9e57f210936e6fc9b55
|
|
| MD5 |
5e5e54dab3e0c756b683439b329b7e1e
|
|
| BLAKE2b-256 |
027c345ba1cef1d01af6673106df5c86191a8f5be8a1fd28b78ef0c58135d4d9
|
File details
Details for the file invexapi-0.1.3-py3-none-any.whl.
File metadata
- Download URL: invexapi-0.1.3-py3-none-any.whl
- Upload date:
- Size: 29.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
087f69b2a90b375a918de36230d0924bdec31d37e044377d99153c6dd0908372
|
|
| MD5 |
43965067b06c01bdfc13cf2dbd53e9fb
|
|
| BLAKE2b-256 |
a5c16b11a76095e33de7c86c98fc466edd43e5882d2a0e158465783f28650e62
|