lbfgs_step

torch_sim.optimizers.lbfgs.lbfgs_step(state, model, *, max_history=20, max_step=0.2, curvature_eps=1e-12)[source]

Advance one L-BFGS iteration using the two-loop recursion.

Computes the search direction via the two-loop recursion, applies a fixed step with optional per-system capping, evaluates new forces and energy, and updates the limited-memory history with a curvature check.

When cell_filter is active, forces are transformed using the deformation gradient to work in the same scaled coordinate space as ASE’s cell filters. The prev_positions are stored as fractional coordinates and prev_forces as scaled forces, exactly matching ASE’s pos0/forces0.

Shape notation:

N = total atoms across all systems (n_atoms) S = number of systems (n_systems) M = max atoms per system (history dimension) H = current history length M_ext = M + 3 (extended with cell DOFs per system)

Parameters:
  • state (LBFGSState | CellLBFGSState) – Current L-BFGS optimization state

  • model (ModelInterface) – Model that computes energies, forces, and optionally stress

  • max_history (int) – Number of (s, y) pairs retained for the two-loop recursion.

  • max_step (float) – If set, caps the maximum per-atom displacement per iteration.

  • curvature_eps (float) – Threshold for the curvature ⟨y, s⟩ used to accept new history pairs.

Returns:

Updated LBFGSState after one optimization step

Return type:

LBFGSState | CellLBFGSState

Notes

  • If state.alpha > 0 (ASE mode), the initial inverse Hessian estimate is fixed at $H_0 = 1/alpha$.

  • Otherwise (Standard mode), $H_0$ varies at each step based on the curvature of the most recent history pair.

References

  • Nocedal & Wright, Numerical Optimization (L-BFGS two-loop recursion).