Skip to content

API reference

The public API is what neuralopt exports (neuralopt.__all__). Other modules, such as neuralopt.compiled, neuralopt.task_families and neuralopt.fast_training, are research interfaces that may change between minor versions.

minimize

minimize(problem: Problem, mode: Literal['learned', 'certified'] = 'learned', max_evaluations: int | None = None, seed: int = 0, params: Params | None = None, config: ModelConfig = DEFAULT_CONFIG, absolute_gap: float = 1e-06, record_diagnostics: bool = False, model_kind: Literal['transformer', 'mlp', 'gram'] = 'transformer', candidate_method: Literal['direct', 'hamiltonian', 'langevin', 'underdamped', 'preconditioned'] = 'direct', hamiltonian_config: HamiltonianConfig = DEFAULT_HAMILTONIAN_CONFIG, hamiltonian_metric: Literal['identity', 'fixed', 'learned'] = 'learned', fixed_metric_diag: Any | None = None, learned_metric_structure: Literal['diagonal', 'lowrank', 'full'] = 'full', overdamped_config: OverdampedConfig = DEFAULT_OVERDAMPED_CONFIG, underdamped_config: UnderdampedConfig = DEFAULT_UNDERDAMPED_CONFIG, preconditioned_step: float | None = None, preconditioned_engine: Literal['python', 'compiled'] = 'compiled', loop_rule: Literal['halving', 'armijo', 'wolfe'] = 'halving') -> OptimizationResult

Minimize a bounded objective with learned actions or rigorous certification.

Problem dataclass

Problem(objective: Callable[[Array], Array], bounds: tuple[Array, Array], dimension: int, x0: Array | None = None, gradient: Callable[[Array], Array] | None = None, residual: Callable[[Array], Array] | None = None, constraints: tuple[Callable[[Array], Array], ...] = (), max_evaluations: int = 1000, dtype: Any = jnp.float32, certified_expression: Any | None = None, identifier: str | None = None, metadata: dict[str, Any] = dict())

A bounded scalar minimization problem.

certified_expression must be an :class:neuralopt.Expr; arbitrary JAX programs deliberately cannot enter certified mode.

OptimizationResult dataclass

OptimizationResult(x: Any, fun: float, status: str, evaluations: int, trajectory: tuple[float, ...], lower_bound: float | None = None, upper_bound: float | None = None, certificate: Certificate | None = None, diagnostics: dict[str, Any] | None = None)

ModelConfig dataclass

ModelConfig(width: int = 32, heads: int = 4, rank: int = 2, layers: int = 2, scale_aware: bool = False, geometry_bound: float = 0.0, lowrank_scale: float = 1.0, feature_set: str = 'legacy', history_length: int = 0)

input_features property

input_features: int

Per-coordinate token width implied by the versioned feature set.

init_model

init_model(key: Any, config: ModelConfig = DEFAULT_CONFIG) -> Params

Initialize policy parameters deterministically from a JAX key.

Variable

Factory for indexed expression variables.

Expr dataclass

Expr(op: str, args: tuple[Any, ...])

Serializable expression over a bounded vector variable.

Certificate dataclass

Certificate(problem_id: str, expression: dict[str, Any], domain_lower: list[float], domain_upper: list[float], incumbent_x: list[float], upper_bound: float, lower_bound: float, absolute_gap: float, relative_gap: float | None, active_regions: list[dict[str, Any]], nodes_processed: int, regions_pruned: int, arithmetic: str, precision: str, status: str, software_version: str = '0.3.0', environment: str = platform.platform())

verify_certificate

verify_certificate(cert: Certificate, tolerance: float = 0.0) -> bool

Replay bounds and prove that terminal boxes cover the declared domain.

HamiltonianConfig dataclass

HamiltonianConfig(step_size: float = 0.05, leapfrog_steps: int = 5, inverse_temperature: float = 1.0, transform_epsilon: float = 1e-06, max_energy_error: float = 100.0)

OverdampedConfig dataclass

OverdampedConfig(step_size: float = 0.01, temperature: float = 1.0, steps: int = 1, transform_epsilon: float = 1e-06)

UnderdampedConfig dataclass

UnderdampedConfig(step_size: float = 0.01, temperature: float = 1.0, friction: float = 1.0, steps: int = 1, transform_epsilon: float = 1e-06)

StochasticTrainingConfig dataclass

StochasticTrainingConfig(integrator: Literal['overdamped', 'underdamped'] = 'overdamped', episodes: int = 8, integration_steps: int = 2, horizons: tuple[int, ...] = (2, 4, 8), step_size: float = 0.01, temperature: float = 0.5, friction: float = 1.0, stability_weight: float = 0.001, compute_weight: float = 0.0, fp_weight: float = 0.0, free_energy_weight: float = 0.0, transform_epsilon: float = 1e-06, geometry_structure: Literal['diagonal', 'lowrank', 'full'] = 'full', gradient_samples: int = 1, temperature_range: tuple[float, float] | None = None, friction_range: tuple[float, float] | None = None)

Differentiable learned-geometry trajectory and loss configuration.

Compiled engine

preconditioned_solve

preconditioned_solve(objective: Any, x0: Any, bounds: tuple[Any, Any], budget: int, *, theta: Any = None, params: Params | None = None, config: ModelConfig = DEFAULT_CONFIG, model_kind: str = 'transformer', geometry: str = 'learned', structure: str = 'full', fixed_metric_diag: Any = None, preconditioned_step: float | None = None, loop_rule: str = 'halving') -> dict[str, Any]

Run one compiled solve; returns host arrays (see :class:_State) plus status.

objective must be JAX-traceable: objective(x), or objective(x, theta) when theta is given. It is a static argument: reuse the same function object to reuse the compilation.

preconditioned_solve_batch

preconditioned_solve_batch(objective: Any, thetas: Any, x0: Any, bounds: tuple[Any, Any], budget: int, *, params: Params | None = None, config: ModelConfig = DEFAULT_CONFIG, model_kind: str = 'transformer', geometry: str = 'learned', structure: str = 'full', fixed_metric_diag: Any = None, preconditioned_step: float | None = None, loop_rule: str = 'halving') -> dict[str, Any]

vmap the compiled solve over tasks objective(x, theta_i) of one dimension.

thetas, x0 and both bounds carry a leading task axis. Errors are not raised: inspect status per task (see :data:STATUS_MESSAGES).