Curvature-aware optimization with exact Hessians via hcderiv
Project description
CAO — Curvature-Aware Optimization
CAO provides practical second-order optimization using exact Hessians
computed via hcderiv.
Make trust-region and Newton-style optimization as easy to use as Adam or SGD.
No finite differences. No approximations. No step-size tuning.
Install
pip install curvopt # NumPy backend
pip install "cao[jax]" # + JAX/XLA backend (recommended)
Quick start
from cao import TrustRegionOptimizer
import numpy as np
def f(X):
return (X[1] - X[0]**2)**2 * 100.0 + (X[0]*0.0 + 1.0 - X[0])**2
opt = TrustRegionOptimizer(f, backend="jax-xla")
result = opt.minimize([-1.2, 1.0])
print(result)
# OptimizeResult(f=1.5e-15, ‖g‖∞=3.4e-08, nit=23, converged)
print(result.x)
# [1. 1.]
How it works
At each iteration CAO calls hcderiv.grad_and_hessian(f, x, backend=...) to
compute the exact gradient and full Hessian in a single forward pass. It then
solves the trust-region subproblem:
min g·p + ½ p·H·p s.t. ‖p‖ ≤ Δ
using the Cauchy point as a safe fallback and the regularised Newton step when it lies inside the trust region. The radius Δ is adapted each iteration based on the ratio of actual to predicted reduction.
Why exact Hessians?
Quasi-Newton methods (L-BFGS) and diagonal approximations miss off-diagonal
curvature. hcderiv's XLA backend computes the full d×d Hessian in one
forward pass with NumPy-class speed, making exact second-order steps practical
for the first time at this scale.
Architecture
hcderiv (exact curvature engine)
↓ grad_and_hessian(f, x, backend="jax-xla")
cao (trust-region solver)
↓ TrustRegionOptimizer.minimize(x0)
x*
Performance
Rosenbrock from (-1.2, 1.0) — convergence to f < 1e-14:
| Method | Iterations | Hessian evals |
|---|---|---|
| CAO trust-region (exact H) | 23 | 23 |
| scipy L-BFGS-B | ~120 | 0 (approx) |
| scipy Newton-CG | ~35 | 35 (FD) |
CAO converges in fewer iterations because it uses the exact curvature at every step.
API
from cao import TrustRegionOptimizer, TrustRegionConfig, OptimizeResult
# Configure
config = TrustRegionConfig(
max_iters=200,
initial_radius=1.0,
tol_grad=1e-6,
verbose=True, # print iteration log
)
# Run
opt = TrustRegionOptimizer(f, config=config, backend="jax-xla")
result = opt.minimize(x0)
# Result fields
result.x # final iterate
result.f # function value
result.grad_norm # ‖∇f‖∞ at x*
result.nit # iterations
result.nfev # Hessian evaluations
result.converged # bool
result.f_history # f at each accepted step
Ecosystem
hcderiv → exact Hessians (NumPy + JAX-XLA)
↓
cao → curvature-aware optimizer
↓
constitutional-os + governed-research-lab-v2 → curvature-governed agents
Roadmap
- v0.2.0 — cubic regularization (ARC)
- v0.3.0 — PyTorch backend
- v0.4.0 — curvature-aware learning rate schedules for ML models
Citation
A JOSS paper will accompany CAO after the 6-month public availability window. Until then, please cite the hcderiv engine:
@misc{byte2026d,
author = {Byte, Zetta},
title = {hcderiv v0.4.0 — JAX-XLA backend for exact one-pass Hessians},
year = {2026},
doi = {10.5281/zenodo.19433812},
url = {https://doi.org/10.5281/zenodo.19433812}
}
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 curvopt-0.1.0.tar.gz.
File metadata
- Download URL: curvopt-0.1.0.tar.gz
- Upload date:
- Size: 9.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
802ba37cbbd9acc0ad853cde80a4311a47b6dadf901a61ee680e044a60c9c161
|
|
| MD5 |
0abb0c5f1212146a38c7208498a0fa09
|
|
| BLAKE2b-256 |
7a1efaf60676c8959d31a7620cbd9280b16e73b7750135a423c1d5991c242437
|
File details
Details for the file curvopt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: curvopt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0553a804f6ae511c1ca41ac0e28648617a2062df9e315aa5c24d26fe94b808bf
|
|
| MD5 |
a45a6c1e377db1461d89818ce2926284
|
|
| BLAKE2b-256 |
6f58c0e9508a8029905be03151a5b86ba275f319f7c8d4981242a5384adf3ae9
|