What It Is
Peach is a Torch-based toolbox for optimization and linear-solver experiments. It keeps problem definitions small: optimizers ask concrete problem objects for objective hooks, and linear solvers ask for matrix-vector hooks.
It contains:
- Protocol-based optimizer and linear-system interfaces.
- A preconditioned nonlinear conjugate-gradient optimizer with Armijo backtracking, adaptive diagonal Hessian damping, and optional problem hooks for callbacks and step-size limits.
- CuPy-backed conjugate-gradient and MINRES wrappers for torch tensors, with residual diagnostics.
- A SciPy optimizer adapter and a Rosenbrock problem for tests and examples.
Install
uv add liblaf-peach
Example
import torch
from liblaf.peach.optim.pncg import Pncg
class QuadraticProblem:
def __init__(self, target):
self.target = target
def update(self, state, params, /):
state.copy_(params)
def fun(self, state, /):
residual = state - self.target
return 0.5 * torch.dot(residual, residual)
def grad(self, state, /):
return state - self.target
def hess_diag(self, state, /):
return torch.ones_like(state)
def hess_quad(self, state, direction, /):
return torch.dot(direction, direction)
params = torch.tensor([0.0])
model_state = params.clone()
problem = QuadraticProblem(target=torch.tensor([3.0]))
solution = Pncg().minimize(problem, model_state, params)
print(solution.params)
print(model_state)
Local Development
gh repo clone liblaf/peach
cd peach
mise run install
uv run pytest
License
liblaf-peach is licensed under the
MIT License.
Metadata
Release files for liblaf-peach 0.10.1
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 |
|---|---|---|---|---|
| liblaf_peach-0.10.1.tar.gz | 15.2 kB | With provenance | Details for liblaf_peach-0.10.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| liblaf_peach-0.10.1-py3-none-any.whl | Python 3 | none | any | Details for liblaf_peach-0.10.1-py3-none-any.whl |
Total release size: 45.5 kB
Release files / liblaf_peach-0.10.1.tar.gz
| Download URL | liblaf_peach-0.10.1.tar.gz |
|---|---|
| Size | 15.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7e611532b95be59e2a9a0bcd18cab36293556fc1d0632236baedba53dc9aaca1
|
|
BLAKE2b-256 checksum How to use checksums |
b5648579f5820d9ae5050635a7954f66d6d76b83be9ed56d4ecd90b2a6619de3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 May 29, 2026.
Transparency logRelease files / liblaf_peach-0.10.1-py3-none-any.whl
| Download URL | liblaf_peach-0.10.1-py3-none-any.whl |
|---|---|
| Size | 30.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2c52a14e33876969cd915ce7cee445a8725bf573ebbceedd8efd5d1ee3083ddf
|
|
BLAKE2b-256 checksum How to use checksums |
8f6004ed62f0ab9e543d8f3a04606055a80e1260707eb92c024f848c710626ee
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
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 May 29, 2026.
Transparency logSecurity for liblaf-peach 0.10.1
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
All 2 files in this release have been uploaded with provenance metadata.
Attestation for liblaf_peach-0.10.1.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 May 29, 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.