accelmo.optimisers.lbfgs¶
Limited-memory BFGS optimiser (no line search).
- class accelmo.optimisers.lbfgs.LBFGSOptimiser(history_size=20, eps=1e-12, weight_decay=0.0, max_step_norm=1.0, powell_damping=0.2)[source]¶
Bases:
BaseOptimiserLimited-memory BFGS without line search: x_{k+1} = x_k - lr * H_k g_k.
Notes
Two-loop recursion computes d_k = -H_k g_k with H_0 = gamma I, gamma = (s^T y)/(y^T y) from the newest pair, so lr = 1 is the quasi-Newton step.
Gradients are divided by the first gradient’s norm, so the steps (and every threshold and clip below) do not depend on the scale of the loss.
- Parameters:
history_size (int)
eps (float)
weight_decay (float)
max_step_norm (float | None)
powell_damping (float)
- OPTIMISER_NAME = 'lbfgs'¶
- KNOB_VECTORS = ('prev_params', 'prev_grads')¶
State entries that are one vector over the knobs (
Noneallowed).
- KNOB_VECTOR_LISTS = ('S', 'Y')¶
State entries that are a list of such vectors.
- classmethod config_kwargs(config, n_params)[source]¶
Constructor arguments from
config.- Return type:
dict[str,Any]- Parameters:
config (OptimiserConfig)
n_params (int)
- step(params, grads, lr)[source]¶
Perform one L-BFGS step.
- Parameters:
params (np.ndarray) – Current parameter vector x_k.
grads (np.ndarray) – Current gradient g_k = ∇f(x_k).
lr (float) – Base learning rate (e.g. from your cosine scheduler).
- Return type:
ndarray- Parameters:
params (numpy.ndarray)
grads (numpy.ndarray)
lr (float)