FOMTools: A Python Toolbox for Analysis of First-Order Methods
Development, analysis, and code generation for first-order methods.
FOMTools is an open-source Python package for developing, analyzing, and deploying first-order methods for parametric linear and convex quadratic optimization. You write the iteration in Python, with syntax close to its mathematical description, and FOMTools records it as a computation graph of affine and piecewise affine steps. From that single description you can:
The following code verifies FISTA on a family of Lasso problems
minimize 0.5 ||D s - x||_2^2 + lambda ||s||_1 where s in R^n is the optimization variable and the data vector x ranges over the box [0, 1]^m. After each iteration it computes the worst-case fixed-point residual ||s^{k+1} - s^k||_inf over all such x.
import numpy as np import fomtools as ft # Problem data m, n, lambd, K = 10, 15, 0.1, 10 D = np.random.normal(size=(m, n)) eta = 1 / np.linalg.norm(D, 2) ** 2 VP = ft.Verifier() # MIP verification with HiGHS; use solver="gurobi" for Gurobi # Parameter set and initial iterate x = VP.add_param(m, lb=0, ub=1) s = [VP.add_iterate(n, lb=0, ub=0)] w, beta = s[0], 1.0 results = [] for k in range(K): # FISTA iteration s.append(VP.step.soft_threshold(w - eta * D.T @ (D @ w - x), lambd=lambd * eta)) beta_old, beta = beta, 0.5 * (1 + np.sqrt(1 + 4 * beta**2)) w = s[k + 1] + (beta_old - 1) / beta * (s[k + 1] - s[k]) # Worst-case residual after k + 1 iterations VP.set_objective_norm(s[k + 1] - s[k], np.inf) results.append(VP.solve()) Steps can also be written with proximal operators and projections, e.g., VP.prox(NormL1(lambd), v, eta) or VP.project(Box(l, u), v). See the documentation for the full list of proxable functions and sets.
Simulation. Write the same loop with ft.Verifier(method="simulator"), and give parameters sample arrays of shape (N, d) (or let them be sampled from their bounds). The simulator runs all samples as batched operations, on a GPU through CuPy when one is available. It then reports summary statistics and a KL-inverse bound on the probability that the residual exceeds a tolerance epsilon:
VP.solve(epsilon=1e-3) VP["quantiles"][0.95], VP["risk_bound"], VP["throughput"] Code generation. Pass the recorded iterates, unchanged, to codegen. It produces a specialized solver together with a Python wrapper:
result = VP.codegen("out/fista", iterates=s, code_optimization=True) Targets include embedded C, multicore CPUs (OpenMP), and GPUs (CUDA). The package works with any coding agent.
CVXPYgen. You can model a parametric problem in CVXPY and generate both its canonicalization code and a first-order solver for it:
import fomtools.cvxpygen as fcpg fcpg.generate_solver(problem, "out/qp", fom="admm", param_bounds={q: (q_lb, q_ub)}) Installation FOMTools requires Python 3.12 or later. Install it from PyPI:
pip install fomtools To install from source instead:
git clone https://github.com/stellatogrp/fomtools.git cd fomtools pip install -e . Optional extras:
For example, pip install "fomtools[gurobi,codegen]", or pip install -e ".[gurobi,codegen]" from source.
FOMTools is not a solver. It relies on mathematical programming solvers such as HiGHS (the default) and Gurobi to solve the verification problems it builds.
The tutorials cover sparse coding (Lasso), nonnegative least squares, network optimization, optimal control, and portfolio rebalancing. Code to reproduce the experiments in our paper is available at stellatogrp/fomtools_experiments.
If you'd like to add a new example to our library, or implement a new feature, please get in touch with us first to make sure that your priorities align with ours.
FOMTools is developed by Vinit Ranjan, Daniel Deza, Anushka Acharya, Jisun Park, and Bartolomeo Stellato.
If you use FOMTools for published work, we encourage you to cite our paper:
@article{ranjan2026fomtools, title = {{FOMTools}: Development and {AI}-Assisted Code Generation for First-Order Methods}, author = {Ranjan, Vinit and Deza, Daniel and Acharya, Anushka and Park, Jisun and Stellato, Bartolomeo}, journal = {arXiv preprint arXiv:2610.26743}, year = {2026}, } Key dates PyPI data Data sourced directly from PyPI's database. Released: Oct 20, 2026 Latest release 1 maintainer PyPI data Data sourced directly from PyPI's database. vinitranjan1 Credits Author: Vinit Ranjan
All 2 files in this release have provenance metadata.
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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.
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.
All 2 files in this release have been uploaded with provenance metadata.
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.




