Skip to content

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YAND-JAX: Yau's Affine Normal Descent in JAX

Python 3.10+ JAX License: MIT

The first open-source implementation of Yau's Affine Normal Descent (YAND), a geometric optimization algorithm that derives search directions from the equi-affine normal of level-set hypersurfaces.

Paper: Yi-Shuai Niu, Artan Sheshmani, and Shing-Tung Yau. "Yau's Affine Normal Descent." arXiv:2603.28448v2, 2026.

What is YAND?

Instead of following the gradient (steepest descent) or using a local quadratic model (Newton's method), YAND uses the affine normal — a direction from classical differential geometry that encodes the intrinsic shape of the objective's level sets.

Key properties:

  • 🎯 Exact on quadratics: Converges in one step with exact line search on any strictly convex quadratic (any dimension)
  • 🛡️ Affine invariant: Completely immune to ill-conditioning from affine transformations — a problem with condition number 10⁸ converges in the same steps as one with condition number 1
  • 🔄 Curvature-aware: Uses third-order derivative information to go beyond what Newton's method captures
  • 📐 Geometrically principled: Directions come from the intrinsic geometry of level sets, not from coordinate-dependent Taylor expansions

Quick Start

Installation

git clone https://github.com/yourusername/yand-jax.git
cd yand-jax
pip install -r requirements.txt

Basic Usage

import jax
import jax.numpy as jnp
jax.config.update("jax_enable_x64", True)

from yand import YANDOptimizer

# Define your objective
def rosenbrock(x):
    return 100 * (x[1] - x[0]**2)**2 + (1 - x[0])**2

# Optimize
opt = YANDOptimizer(rosenbrock, line_search='armijo')
result = opt.optimize(jnp.array([-1.0, 1.0]))

print(f"Converged in {result.n_iter} iterations")
print(f"Minimum at: {result.x_opt}")
print(f"f(x*) = {result.f_opt:.2e}")

Run Experiments

# Reproduce paper results (2D quadratic — should converge in 1 step)
python experiments/exp01_quadratic_2d.py

# Test affine-scaling invariance (the killer feature)
python experiments/exp02_ill_conditioned.py

# Rosenbrock valley (nonconvex)
python experiments/exp04_rosenbrock.py

# 3D experiments (novel extension beyond the paper)
python experiments/exp07_3d_quadratic.py

Results

One-Step Convergence on Quadratics (Corollary 3.2)

Method Iterations (2D) Iterations (3D)
YAND (Exact LS) 1 1
Newton (Exact LS) 1 1
Gradient Descent (Exact LS) 1 100+

Affine-Scaling Invariance

Condition Number κ YAND-Exact YAND-Armijo GD-Exact Newton
1 1 13 1 1
10⁴ 1 23 200+ 1
10⁸ * 30 200+ *

* At extreme conditioning, exact line search itself becomes numerically challenging.

Rosenbrock Function (Nonconvex)

Method Iterations Final f(x)
YAND-Armijo 23 2.0e-14
YAND-Wolfe 22 2.1e-16
Newton-Armijo 28 8.6e-16
GD-Exact 200+ 6.7 (not converged)

Where YAND Beats Newton

On problems with saddle geometry or rotated coordinates, Newton's local quadratic model breaks down while YAND's intrinsic level-set geometry remains robust:

Problem YAND-Armijo Newton-Armijo GD-Exact Winner
Saddle Polynomial 12 300 ❌ 300 ❌ YAND (25×)
Rotated Rosenbrock 20 300 ❌ 300 ❌ YAND (15×)
Inverse Barrier 14 14 1 Tie
Anisotropic 6th-Degree 15 14 3 Newton

❌ = did not converge within iteration budget

Why? Newton's direction depends on the Hessian, which is coordinate-dependent. YAND's affine normal is invariant under all volume-preserving affine transformations (rotations, shears, scalings). Near saddle points with indefinite Hessians, Newton oscillates; YAND's ellipticity check detects the geometry and navigates cleanly.

Repository Structure

yand-jax/
├── yand/                      # Core library
│   ├── core.py                # Affine normal direction computation
│   ├── optimizer.py           # YAND, GD, Newton optimizers
│   └── line_search.py         # Exact, Armijo, Strong Wolfe
├── experiments/               # Reproducible experiments
│   ├── exp01_quadratic_2d.py  # Paper Fig 4: well-conditioned quadratic
│   ├── exp02_ill_conditioned.py # Paper Fig 5-6: scaling invariance
│   ├── exp04_rosenbrock.py    # Paper Fig 10: nonconvex valley
│   └── exp07_3d_quadratic.py  # Novel: 3D extension
├── figures/                   # Generated plots
├── tests/                     # Unit tests
└── requirements.txt

How It Works

At each iteration, YAND:

  1. Computes the gradient ∇f(x) and Hessian ∇²f(x)
  2. Builds a tangent frame for the level set {x : f(x) = f(xₖ)}
  3. Projects the Hessian into the tangent space → tangent-tangent block B
  4. Checks ellipticity: if det(B) > 0, the level set is locally convex
  5. Computes third derivatives for beyond-quadratic curvature correction
  6. Constructs the affine normal direction from the level-set geometry
  7. Line search determines the step size

If the level set is not locally convex (non-elliptic point), YAND gracefully falls back to steepest descent.

Finance Applications

We include real-world finance experiments to demonstrate YAND on practical optimization problems:

Experiment Problem Data Assets
exp11_portfolio_real.py Mean-Variance & Risk Parity Real ETF data (Yahoo Finance, 2020–2025) SPY, QQQ, IWM, EFA, EEM, TLT, GLD, VNQ
exp12_garch_mle.py GARCH(1,1) MLE Simulated returns 3 parameters

Portfolio optimization problems are naturally anisotropic (asset volatilities differ by orders of magnitude), making them a good test for YAND's affine invariance.

Full Experiment List

# Name Type Key Finding
01 Well-conditioned quadratic Paper reproduction 1-step convergence ✓
02 Ill-conditioned scaling Paper reproduction Affine invariance ✓
04 Rosenbrock Paper reproduction 23 iters (GD: 200+)
05 YAND vs Newton head-to-head Novel YAND wins on saddles & rotations
06 Extended benchmarks (6 functions) Novel Beale, Levy, Camel, Styblinski-Tang
07 3D quadratic Novel 1-step convergence in 3D ✓
11 Portfolio optimization (real data) Finance Mean-Variance & Risk Parity
12 GARCH(1,1) MLE Finance Volatility model fitting

Limitations and Known Issues

We believe in honest benchmarking. Here are the current limitations:

Computational Cost

  • Third-order derivatives are expensive. YAND requires computing D³f, which scales as O(n³) in memory and compute. For high-dimensional problems (n > 50), this becomes prohibitive.
  • Per-iteration cost is ~3–8× higher than Newton (which only needs second derivatives) and ~10–20× higher than gradient descent.
  • The jax.jacfwd(jax.hessian(f)) call is the bottleneck; future work could use the slice-centroid approximation to avoid explicit third derivatives.

When Newton Wins

  • On well-conditioned smooth problems (Beale, Six-Hump Camel), Newton-Armijo is faster.
  • On sequential/recursive objectives (GARCH MLE with jax.lax.scan), the third-derivative computation through the scan is noisy and expensive.
  • When the Hessian is well-conditioned and positive definite everywhere, Newton's local quadratic model is already excellent.

When YAND Wins

  • Near saddle points with indefinite Hessians (Newton oscillates, YAND navigates)
  • Under coordinate rotations/shears (YAND is invariant, Newton is not)
  • On ill-conditioned problems where the anisotropy is geometric, not just from poor scaling

Scalability

  • Currently tested on problems up to 8 dimensions (portfolio optimization). The paper's theory is dimension-agnostic, but practical scalability depends on efficient third-derivative computation.
  • The slice-centroid approximation (Section 2.1.2 of the paper) could enable scalability without explicit derivatives — this is not yet implemented.

Line Search Sensitivity

  • At extreme condition numbers (κ > 10⁶), the exact line search itself becomes numerically challenging, degrading YAND-Exact performance even though the direction is correct.
  • YAND-Armijo is generally more robust than YAND-Exact in practice.

Citation

If you use this implementation in your research, please cite both the original paper and this implementation:

@article{niu2026yand,
  title={Yau's Affine Normal Descent},
  author={Niu, Yi-Shuai and Sheshmani, Artan and Yau, Shing-Tung},
  journal={arXiv preprint arXiv:2603.28448v2},
  year={2026}
}

License

MIT License. See LICENSE for details.

Contributing

Contributions are welcome! Some particularly impactful directions:

  • Slice-centroid approximation (avoiding third derivatives for scalability)
  • Constrained optimization extension (projected affine normal)
  • Stochastic/mini-batch variants for machine learning applications
  • Additional finance benchmarks (Heston calibration, Black-Litterman)

This is an independent open-source implementation, not affiliated with the original authors.

About

First open-source JAX implementation of Yau's Affine Normal Descent (Niu, Sheshmani & Yau, 2026) — a geometric optimization algorithm using equi-affine normals of level sets

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages