Optimization#
Optimization follows a class-style interface:
problem = Minimize(M=M, cost=cost, x0=x0, solver=solver)
solution, final_cost, history = problem.solve()
The cost is a scalar JAX function. Supply a Riemannian grad, an ambient
egrad, or let JAX differentiate the cost and let the geometry convert the
result. The underlying smooth-manifold optimization framework follows
Absil et al. [2008] and Boumal [2023].
JAX transformation boundary#
Geometry methods and numerical derivative products can be used inside
jax.jit, jax.vmap, jax.grad, and jax.jvp with fixed dimensions and
pytree structure. Random methods take explicit PRNG keys, while batch helper
methods vectorize over a leading sample axis.
The solver driver itself is not a single JIT kernel. solve() performs Python
stopping logic, line-search control flow, callbacks, timing, and construction
of the human-readable iteration history. Compile expensive model components
instead:
cost = jax.jit(cost)
egrad = jax.jit(jax.grad(cost))
problem = Minimize(M=M, cost=cost, egrad=egrad, x0=x0, solver=solver)
Do not call jax.jit(problem.solve). This explicit boundary keeps diagnostics
and extension hooks flexible while preserving compiled numerical kernels.
Problem forms#
Minimize represents a general smooth objective
For a residual map \(r:\mathcal M\to\mathbb R^m\), LeastSquares constructs
and provides matrix-free products with the residual Jacobian \(J_x\) and its
adjoint \(J_x^*\). GaussNewton and LevenbergMarquardt consume this richer
contract directly [Levenberg, 1944, Marquardt, 1963, Nocedal and Wright, 2006].
problem = LeastSquares(
M=M,
residual=residual,
x0=x0,
solver=LevenbergMarquardt(),
)
FiniteSum represents \(f(x)=N^{-1}\sum_{i=1}^N f_i(x)\) without requiring
StochasticGradient to evaluate every term at every update. The Riemannian
stochastic-gradient convergence framework is given by
Bonnabel [2013].
problem = FiniteSum(
M=M,
loss=lambda x, i: per_sample_loss(x, data[i]),
num_terms=N,
x0=x0,
solver=StochasticGradient(batch_size=32),
key=0,
)
Choosing a solver#
Solver |
Useful starting point |
|---|---|
|
transparent baseline and debugging |
|
economical default smooth first-order method |
|
smooth problems where a short curvature history helps |
|
low-memory spectral step estimates |
|
matrix-free Newton steps with reliable Hessian products |
|
robust second-order steps and indefinite Hessians |
|
second-order models globalized by a cubic term |
|
well-conditioned nonlinear least squares |
|
nonlinear least squares needing adaptive damping |
|
large finite sums and mini-batch training |
|
block updates on a |
|
derivative-free exploratory search |
|
small derivative-free problems |
Gauss–Newton and Levenberg–Marquardt require LeastSquares.
StochasticGradient requires FiniteSum, and AlternatingGradient requires a
Product geometry. All remaining solvers, including the derivative-free
methods, consume Minimize.
The table spans classical spectral, quasi-Newton, derivative-free, and second-order families [Barzilai and Borwein, 1988, Cartis et al., 2011, Kennedy and Eberhart, 1995, Liu and Nocedal, 1989, Nelder and Mead, 1965].
Line searches#
The gradient solvers accept a reusable strategy through line_search:
from geojax.optimization import ConjugateGradient, StrongWolfe
solver = ConjugateGradient(line_search=StrongWolfe())
Strategy |
Behavior |
|---|---|
|
fixed multiplier, useful when a stable scale is known |
|
monotone sufficient decrease |
|
Armijo search initialized from the previous decrease |
|
sufficient decrease plus a curvature condition |
AdaptiveArmijo is the default for steepest descent, conjugate gradient,
L-BFGS, and alternating gradient. Barzilai–Borwein uses non-normalized
BacktrackingArmijo; stochastic gradient has no line search. Newton-CG and
Gauss–Newton use an unnormalized adaptive Armijo search, so a unit Newton step
is tested first. Every strategy returns common cost/gradient evaluation counts
and its accepted multiplier in InfoEntry.linesearch.
StrongWolfe pairs the trial gradient with the transported initial direction.
That is the exact derivative of the search curve for a geodesic with parallel
transport. With a general retraction and vector transport, it is the standard
transported-derivative proxy, so classical Wolfe guarantees require the usual
compatibility assumptions. The sufficient-decrease and curvature conditions
trace to Armijo [1966] and Wolfe [1969].
Second-order models#
NewtonCG, TrustRegions, and AdaptiveRegularizationCubics use
problem.rhess_vec(x, u) rather than forming a Hessian matrix. The cubic method
approximately minimizes
The regularization parameter \(\sigma\) is adapted from the agreement between
predicted and actual decrease. The iteration history records acceptance,
gain ratio, regularization, inner iterations, and curvature events in
InfoEntry.extra [Cartis et al., 2011].
Automatic ambient-to-Riemannian Hessian conversion is currently exact for:
Exact automatic path |
Geometries |
|---|---|
Ambient |
|
JVP of a supplied Riemannian |
|
Product geometry |
Exact only when every factor supports the selected path |
For every other geometry, supply rhess_vec. GeoJAX raises an error instead of
silently substituting tangent projection, because projection alone omits
connection or embedding-curvature terms. operation_kind("ehess_to_rhess")
and operation_kind("rgrad_jvp") expose these capabilities programmatically.
Gauss–Newton and Levenberg–Marquardt use the LeastSquares normal operator
instead and do not require this generic Hessian conversion.
Product blocks and pytrees#
AlternatingGradient follows JAX’s deterministic leaf order for the geometry
pytree. One outer iteration visits every Product factor, recomputing the full
Riemannian gradient before each block update. The point retains its original
dict/list/tuple nesting throughout.
All other tangent-arithmetic solvers are pytree-safe as well: directions, gradients, transports, and Hessian-vector products have the same structure as the point.
See the complete optimization API and the executable solver comparison.
References#
P.-A. Absil, Robert Mahony, and Rodolphe Sepulchre. Optimization Algorithms on Matrix Manifolds. Princeton University Press, 2008. doi:10.1515/9781400830244.
Larry Armijo. Minimization of functions having lipschitz continuous first partial derivatives. Pacific Journal of Mathematics, 16(1):1–3, 1966. doi:10.2140/pjm.1966.16.1.
Jonathan Barzilai and Jonathan M. Borwein. Two-point step size gradient methods. IMA Journal of Numerical Analysis, 8(1):141–148, 1988. doi:10.1093/imanum/8.1.141.
Silvère Bonnabel. Stochastic gradient descent on Riemannian manifolds. IEEE Transactions on Automatic Control, 58(9):2217–2229, 2013. doi:10.1109/TAC.2013.2254619.
Nicolas Boumal. An Introduction to Optimization on Smooth Manifolds. Cambridge University Press, 2023. doi:10.1017/9781009166164.
Coralia Cartis, Nicholas I. M. Gould, and Philippe L. Toint. Adaptive cubic regularisation methods for unconstrained optimization. part i: motivation, convergence and numerical results. Mathematical Programming, 127:245–295, 2011. doi:10.1007/s10107-009-0286-5.
James Kennedy and Russell Eberhart. Particle swarm optimization. In Proceedings of ICNN'95 - International Conference on Neural Networks, volume 4, 1942–1948. 1995. doi:10.1109/ICNN.1995.488968.
Kenneth Levenberg. A method for the solution of certain non-linear problems in least squares. Quarterly of Applied Mathematics, 2(2):164–168, 1944. doi:10.1090/qam/10666.
Dong C. Liu and Jorge Nocedal. On the limited memory BFGS method for large scale optimization. Mathematical Programming, 45:503–528, 1989. doi:10.1007/BF01589116.
Donald W. Marquardt. An algorithm for least-squares estimation of nonlinear parameters. Journal of the Society for Industrial and Applied Mathematics, 11(2):431–441, 1963. doi:10.1137/0111030.
John A. Nelder and Roger Mead. A simplex method for function minimization. The Computer Journal, 7(4):308–313, 1965. doi:10.1093/comjnl/7.4.308.
Jorge Nocedal and Stephen J. Wright. Numerical Optimization. Springer, 2 edition, 2006. doi:10.1007/978-0-387-40065-5.
Philip Wolfe. Convergence conditions for ascent methods. SIAM Review, 11(2):226–235, 1969. doi:10.1137/1011036.