This release is a pre-release and may not be stable for production use.
torch-piazzi
piazzi provides deterministic PyTorch solvers for nonlinear fitting problems, such as pose or camera registration, curve fitting and bundle adjustment. It is built for problems where every objective evaluation is expensive (rendering, for example) and you want each evaluation to count. torch.optim targets stochastic training instead; piazzi targets full-batch, curvature-aware fitting.
Named after Giuseppe Piazzi, who discovered the dwarf planet Ceres in 1801. Gauss recovered Ceres from Piazzi's observations by inventing least squares.
Status: pre-alpha, and the API may change. The package is not on PyPI yet.
Documentation: https://cai4cai.github.io/torch-piazzi/
Installation
pip install "piazzi @ git+https://github.com/cai4cai/torch-piazzi"
pip install "piazzi[scipy,pypose,torchmin,sparse] @ git+https://github.com/cai4cai/torch-piazzi" # optional backends and sparse CG
Example
import torch
import piazzi
t = torch.linspace(0, 4, 40)
y = 2.5 * torch.exp(-1.3 * t)
y[::10] += 2.0 # outliers
res = piazzi.least_squares(
lambda th: th[0] * torch.exp(-th[1] * t) - y, torch.tensor([1.0, 0.5]), loss="cauchy", f_scale=0.1
)
print(res.x, res.message) # tensor([2.5026, 1.3005]) step below step_tol; loss="linear" gives [3.1053, 1.2741]
Features
- Solvers: L-BFGS with an Armijo line search that counts every evaluation, Gauss-Newton and Levenberg-Marquardt, and SciPy-style
least_squaresandminimize. - Robust losses: SciPy's losses or any PyTorch
rho(z), with IRLS or SciPy curvature. - Black-box objectives:
finite_differencemakes a function that autograd cannot see through usable by every solver. - Manifolds: keep rotations and poses on SO(3) and SE(3), as Ceres's
Manifolddoes, with batched exp/log maps. - Large sparse problems: sparse normal equations, conjugate gradients and custom linear solvers such as a Schur complement.
- Devices and precision: run the objective in float32 on CUDA or Apple MPS, and solve the normal equations in float64 on the CPU or on the GPU.
torch.optimoptimisers and SciPy, PyPose and pytorch-minimize backends behind the same interface, to compare methods on the same problem.
Notebooks
The notebooks in notebooks/ run in Google Colab, or locally after uv sync --group notebooks. They are also rendered in the documentation.
| Notebook | |
|---|---|
Robust nonlinear regression: robust losses, checked against scipy.optimize.least_squares |
|
| The Rosenbrock function: L-BFGS variants versus Gauss-Newton and Levenberg-Marquardt, and SciPy's methods | |
| Bundle adjustment: 49 cameras on SE(3), sparse normal equations, CG and Schur solvers, on the CPU and a GPU |
Related work
Ceres Solver, Theseus, PyPose, torch.optim.LBFGS, nlesc-dirac/pytorch, pytorch-minimize and scipy.optimize solve related problems; the related work page compares them.
Development
uv sync --group dev
uv run pytest
uv run ruff check .
See the contributing page and AGENTS.md for the full checks and conventions. Planned work is tracked in the issues.
Licence
Apache-2.0
Metadata
Release files for piazzi 0.1.0a1
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 |
|---|---|---|---|---|
| piazzi-0.1.0a1.tar.gz | 101.2 kB | With provenance | Details for piazzi-0.1.0a1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| piazzi-0.1.0a1-py3-none-any.whl | Python 3 | none | any | Details for piazzi-0.1.0a1-py3-none-any.whl |
Total release size: 175.4 kB
Release files / piazzi-0.1.0a1.tar.gz
| Download URL | piazzi-0.1.0a1.tar.gz |
|---|---|
| Size | 101.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87ba51e8bf74d7120b0d3cd28f1e56fb86b15303ae5d2d80197e8a3b13fb57c8
|
|
BLAKE2b-256 checksum How to use checksums |
667223c22ac6d84ec58c552847d41d296f59bc3e33a38b7fbc4640bb906acb1f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / piazzi-0.1.0a1-py3-none-any.whl
| Download URL | piazzi-0.1.0a1-py3-none-any.whl |
|---|---|
| Size | 74.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
01881d8bdcba9bddc137c0304139ecf43becabcc5726741522274412c9afeec2
|
|
BLAKE2b-256 checksum How to use checksums |
d2caa2a932a66b49fa069156b5a2fe5f3607c471518170bb02c6ef841a447437
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for piazzi 0.1.0a1
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.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for piazzi-0.1.0a1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA 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.