gaussianzeroorder
Two-point Gaussian zeroth-order stochastic optimization with high-probability last-iterate certificates.
gaussianzeroorder implements the same-sample, two-point Gaussian
zeroth-order stochastic gradient descent method of Ye (2026). It provides
rigorous, finite-sample, high-confidence certificates for the last iterate
under conditional sub-Gaussian noise — not just expectation bounds or guarantees
on averaged iterates.
Features
- High-probability last-iterate guarantee. With probability at least
1 - delta, the final iteratex_Tis within a controlled distance of the optimum. The confidence cost depends only logarithmically / double-logarithmically ondelta, avoiding the polynomial1/deltablow-up of nave union-bound analyses. - Same-sample variance reduction. Both function evaluations within a single finite-difference step use the same stochastic sample (common random numbers), canceling the independent differencing noise that would otherwise dominate.
- Theoretically principled step size. A dimension- and problem-aware schedule
eta_t = 4d / (mu * (t + T0) * ||u_t||^2)withT0 = 32 d L / muis used directly — no learning-rate tuning required. - Explicit dimension & confidence scaling. The theoretical parameters
(
d,T,delta,mu,L,sigma^2) are first-class inputs, so you can compute a priori how many oracle calls are needed for a target precision at a target confidence. - Certification & diagnostics layer. Compute the stitched confidence factor
Gamma_T(delta), estimate complexity, and derive a post-hoc numerical bound onf(x_T) - f(x*)that holds with probability>= 1 - delta. Per-iteration diagnostics (logger, product-weight tracker, weighted scan monitor) are included. - Reproducible & production-friendly. Reproducibility manager, callback hooks, and an async oracle wrapper for batched / concurrent evaluations.
Module overview
| Module | Key components |
|---|---|
optimizer |
TwoPointGaussianOptimizer, StepSizeSchedule, GaussianDirectionSampler |
oracle |
StochasticOracle (protocol), ProblemConfig, NoiseModel |
certification |
ConfidenceFactor, ComplexityEstimator, PostHocBound, DimensionCheck |
diagnostics |
OptimizationLogger, ProductWeightTracker, WeightedScanMonitor |
utils |
SphereGaussianProjection, ReproducibilityManager, CallbackSystem, AsyncOracleWrapper |
Installation
From PyPI:
pip install gaussianzeroorder
From source (editable, with test dependencies):
git clone https://github.com/USER/REPO.git
cd REPO
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -e .[test]
Runtime requirement: Python >=3.10 and NumPy >=1.24.
Usage
The optimizer drives a user-supplied StochasticOracle, whose evaluate(x, seed)
method must return a scalar and use seed to enforce common random numbers.
import numpy as np
from gaussianzeroorder.oracle.base import StochasticOracle
from gaussianzeroorder.oracle.config import ProblemConfig
from gaussianzeroorder.optimizer.core import TwoPointGaussianOptimizer
from gaussianzeroorder.optimizer.step_size import StepSizeSchedule
from gaussianzeroorder.optimizer.direction import GaussianDirectionSampler
class QuadraticStochasticOracle(StochasticOracle):
"""Strongly convex quadratic f(x) = (mu/2)||x||^2 with additive linear noise."""
def __init__(self, d: int, mu: float, sigma: float) -> None:
self.d, self.mu, self.sigma = d, mu, sigma
def evaluate(self, x: np.ndarray, seed: int) -> float:
rng = np.random.default_rng(seed)
xi = rng.normal(0.0, self.sigma, size=self.d)
return float(0.5 * self.mu * np.sum(x**2) + np.dot(xi, x))
# Problem parameters
d, mu, L, sigma = 50, 2.0, 2.0, 0.5
T = 2000
delta = 0.05
# Configuration (positional: d, L, mu, sigma^2, Delta_0, delta)
config = ProblemConfig(d, L, mu, (sigma**2) * d, 0.0, delta)
# Components
schedule = StepSizeSchedule(d, L, mu)
sampler = GaussianDirectionSampler(d, seed=42)
oracle = QuadraticStochasticOracle(d, mu, sigma)
optimizer = TwoPointGaussianOptimizer(oracle, config, schedule, sampler)
x0 = np.random.default_rng(0).standard_normal(d)
x_final = optimizer.optimize(x0, total_iteration_horizon_T=T)
print(f"Final iterate norm: {np.linalg.norm(x_final):.6e}")
Certification
After optimization, compute a rigorous bound on suboptimality that holds with
probability at least 1 - delta:
from gaussianzeroorder.certification.confidence import ConfidenceFactor
from gaussianzeroorder.certification.bounds import PostHocBound
T0 = 32.0 * d * L / mu
gamma_T = ConfidenceFactor().compute_gamma_T(T, T0, delta)
trajectory = [None] * (T + 1) # replace with the real recorded trajectory
cert_bound = PostHocBound().compute_bound(trajectory, gamma_T, config)
print(f"Theoretical 1-delta certificate bound: {cert_bound:.6e}")
Theory
The method targets smooth, strongly convex objectives f with sub-Gaussian
stochastic oracle noise. Under the high-dimensional compatibility condition
d >= 16 log(6T/delta) it attains the convergence rate O~(d/T) for the last
iterate with probability >= 1 - delta. The analysis is based on the paper "High-Probability Last-Iterate Guarantees for Two-Point Gaussian Zeroth-Order Stochastic Gradient Descent" by Haishan Ye (arXiv:2606.20446). See that paper for the full analysis and
the definition of the stitched confidence factor Gamma_T(delta).
Development
pip install -e .[test]
pytest
License
Released under the MIT License.
Metadata
Release files for gaussianzeroorder 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| gaussianzeroorder-0.1.0.tar.gz | 23.1 kB | With provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| gaussianzeroorder-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 45.7 kB
Release files / gaussianzeroorder-0.1.0.tar.gz
| Download URL | gaussianzeroorder-0.1.0.tar.gz |
|---|---|
| Size | 23.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e23a39139993a9ca10ecca955e6c3c20c7a88becc5a8c938635554e42fd63fa4
|
|
BLAKE2b-256 checksum How to use checksums |
f011b7cc4de1f1ed7708292e094d8aa47b0c7d81b925b6735e1257d123b219e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency logRelease files / gaussianzeroorder-0.1.0-py3-none-any.whl
| Download URL | gaussianzeroorder-0.1.0-py3-none-any.whl |
|---|---|
| Size | 22.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fe95eef9201d7fcd0ad23239d0b4877a87f57f4c615df26c3b2fc7063a8a6140
|
|
BLAKE2b-256 checksum How to use checksums |
e8d7b5c25d249c3e1117f2eb7e6ac7e364a568e57a1df15db6dc71195bd5cb85
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency logSecurity for gaussianzeroorder 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for gaussianzeroorder-0.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.