Torch-first optimization protocols and CuPy linear-solver helpers for numerical experiments.
Project description
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.
Project details
Release history Release notifications | RSS feed
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 liblaf_peach-0.10.0.tar.gz.
File metadata
- Download URL: liblaf_peach-0.10.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7372c2818d4b10f4dc1a1b7858bc2c9acb2597a7588e589dbafe921da347cf54
|
|
| MD5 |
91721cdc5da0189d788419577be3477e
|
|
| BLAKE2b-256 |
c09bb35a88053bb79a594319bee3e4ca020ead48252904adeef16b7ec2c3673d
|
Provenance
The following attestation bundles were made for liblaf_peach-0.10.0.tar.gz:
Publisher:
python-release.yaml on liblaf/peach
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
liblaf_peach-0.10.0.tar.gz -
Subject digest:
7372c2818d4b10f4dc1a1b7858bc2c9acb2597a7588e589dbafe921da347cf54 - Sigstore transparency entry: 1573116778
- Sigstore integration time:
-
Permalink:
liblaf/peach@1e1866fe49346627ae687cb0cff7233185b74f1d -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/liblaf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yaml@1e1866fe49346627ae687cb0cff7233185b74f1d -
Trigger Event:
release
-
Statement type:
File details
Details for the file liblaf_peach-0.10.0-py3-none-any.whl.
File metadata
- Download URL: liblaf_peach-0.10.0-py3-none-any.whl
- Upload date:
- Size: 30.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d384d011c80675b9dd09f184da7c75167af94d9d70c1f595b6948d6b57a196d
|
|
| MD5 |
c2a2ff9022af7173f65c7aad260a6c04
|
|
| BLAKE2b-256 |
7e89b05d40d0061a62d7fb1c4eedc0bc9eb7dd598ad6418b5daf7ca2691c90f7
|
Provenance
The following attestation bundles were made for liblaf_peach-0.10.0-py3-none-any.whl:
Publisher:
python-release.yaml on liblaf/peach
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
liblaf_peach-0.10.0-py3-none-any.whl -
Subject digest:
6d384d011c80675b9dd09f184da7c75167af94d9d70c1f595b6948d6b57a196d - Sigstore transparency entry: 1573116808
- Sigstore integration time:
-
Permalink:
liblaf/peach@1e1866fe49346627ae687cb0cff7233185b74f1d -
Branch / Tag:
refs/tags/v0.10.0 - Owner: https://github.com/liblaf
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-release.yaml@1e1866fe49346627ae687cb0cff7233185b74f1d -
Trigger Event:
release
-
Statement type: