QQN Optimization
Key Features
The QQN Method
A quadratic interpolation between the steepest-descent and L-BFGS directions, turning a discrete either/or decision into a one-dimensional search along a smooth curve.
- d(t) = t(1-t)(-∇f) + t² d_LBFGS — a single, compact update rule
- Guaranteed descent: the path is tangent to -∇f at t = 0
- Graceful degradation toward gradient descent when curvature info is unreliable
- No new hyperparameters — reuses existing L-BFGS and line-search settings
- Drop-in replacement wherever L-BFGS is already used
- Convergence analysis and derivation in the published paper
Multi-Framework Implementations
One method, four ecosystems: a Rust reference implementation plus first-class ports for the mainstream Python ML stacks.
- Rust (qqn-optimizer) — reference implementation and benchmark harness
- JAX / Optax (qqn-jax) — composable GradientTransformation
- PyTorch (qqn-torch) — torch.optim.Optimizer-compatible
- TensorFlow (qqn-tf) — Keras-compatible optimizer
- Java (MindsEye) — the original research prototype
- Also surfaced interactively in the Optimization Mechanics Visualizer and the geometric attractor labs
Comprehensive Benchmark Suite
62 carefully curated optimization problems and 25 optimizer variants, spanning convex, non-convex, multimodal, and machine learning landscapes — over 31,000 recorded runs.
- Convex functions: Sphere, Matyas, Zakharov across multiple dimensions
- Non-convex unimodal: Rosenbrock, Beale, Himmelblau with ill-conditioning
- Highly multimodal: Rastrigin, Ackley, Schwefel testing global optimization
- Machine learning: Neural networks, SVM, regression problems
- Scalability testing: 2D, 5D, and 10D variants for dimension analysis
- Problem-specific convergence thresholds based on calibration runs
- 25 competing optimizers: QQN variants, L-BFGS, Trust Region, GD, and Adam
Statistical Analysis Engine
Rigorous statistical testing framework ensuring meaningful algorithm comparisons with automated hypothesis testing.
- 50 independent runs per problem-optimizer pairing
- Welch's t-test for unequal variances with automatic application
- Cohen's d effect size calculation for practical significance
- Bonferroni correction for multiple comparison validity
- Win/loss/tie matrices with statistical significance thresholds
- Friedman test for overall performance ranking validation
- Automated generation of publication-ready statistical tables
Multi-Format Reporting
Automated generation of comprehensive reports in multiple formats for different audiences and use cases.
- Markdown reports with embedded visualizations for web viewing
- LaTeX documents ready for academic publication
- CSV exports for custom statistical analysis
- Detailed per-run logs for debugging and deep analysis
- Convergence plots and performance profiles
- Problem-family vs optimizer-family comparison matrices
Reproducible Research Infrastructure
Built to risk disproving the method: fixed seeds, deterministic algorithms, and an extensible harness so results can be independently verified, extended, or refuted.
- Fixed random seeds for deterministic results
- Version-controlled benchmark definitions
- Automated result archiving and comparison
- Docker support for environment consistency
- Extensible architecture for adding new optimizers
- Standardized optimizer interface for fair comparison
- Honest reporting: QQN wins 36/62 problems; Adam and L-BFGS still lead elsewhere
Getting Started
Pick the implementation that matches your stack.
Python (PyTorch)
pip install qqn-torch
# or from source
pip install git+https://github.com/SimiaCryptus/qqn-torch.git
Python (JAX / Optax)
pip install qqn-jax
# or from source
pip install git+https://github.com/SimiaCryptus/qqn-jax.git
Rust (reference implementation + benchmark harness)
# Clone the repository
git clone https://github.com/SimiaCryptus/qqn-optimizer.git
cd qqn-optimizer
# Build the library and benchmarking framework
cargo build --release
Docker (benchmarks only)
# Build Docker image
docker build -t qqn-benchmark .
# Run benchmarks in container
docker run -v $(pwd)/results:/results qqn-benchmark
Quick Example
Using QQN as an optimizer
PyTorch — qqn-torch on GitHub
from qqn_torch import QQN
model = MyModel()
optimizer = QQN(model.parameters()) # no extra hyperparameters to tune
def closure():
optimizer.zero_grad()
loss = loss_fn(model(x), y)
loss.backward()
return loss
for step in range(num_steps):
loss = optimizer.step(closure) # line search needs a closure
JAX / Optax — qqn-jax on GitHub
import optax
from qqn_jax import qqn
solver = qqn() # drop-in GradientTransformation
opt_state = solver.init(params)
value, grad = jax.value_and_grad(loss_fn)(params)
updates, opt_state = solver.update(grad, opt_state, params, value=value,
value_fn=loss_fn)
params = optax.apply_updates(params, updates)
Running the benchmark tournament (Rust)
# Quick benchmark (subset of problems)
cargo run --release -- --quick
# Full suite: 62 problems x 25 optimizers x 50 runs
cargo run --release -- --full
# Generate reports in a specific format
cargo run --release -- --format latex
cargo run --release -- --format markdown
Read the theory
- Plain-language essay + interactive tutorial → — start here
- Paper (DOI: 10.13140/RG.2.2.15200.19206) — derivation, proofs, full results
- Optimization Mechanics Visualizer — see QQN race GD, Adam, and L-BFGS in your browser
👉 Read the essay · Install for PyTorch · Install for JAX · Reproduce the benchmarks
Technical Details
Technologies
Requirements
- Python 3.9+ with PyTorch, JAX/Optax, or TensorFlow (for the ports)
- A loss closure or value function — QQN line-searches along its curve
- Rust 1.70+ and Cargo (for the reference implementation and benchmarks)
- Optional: LaTeX for PDF report generation
- 4GB RAM minimum (8GB recommended for the full benchmark suite)
Contribute to the Project
This is an open-source project. Contributions, bug reports, and feature requests are welcome from the community.