lbfgs_init

torch_sim.optimizers.lbfgs.lbfgs_init(state, model, *, step_size=0.1, alpha=None, cell_filter=None, **filter_kwargs)[source]

Create an initial LBFGSState from a SimState or state dict.

Initializes forces/energy, clears the (s, y) memory, and broadcasts the fixed step size to all systems.

Shape notation:

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

Parameters:
  • state (SimState | dict[Literal['positions', 'masses', 'cell', 'pbc', 'atomic_numbers', 'system_idx'], ~torch.Tensor]) – Input state as SimState object or state parameter dict

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

  • step_size (float) – Fixed per-system step length (damping factor). If using ASE mode (fixed alpha), set this to 1.0 (or your damping). If using dynamic mode (default), 0.1 is a safe starting point.

  • alpha (float | None) – Initial inverse Hessian stiffness guess (ASE parameter). If provided (e.g. 70.0), fixes H0 = 1/alpha for all steps (ASE-style). If None (default), H0 is updated dynamically (Standard L-BFGS).

  • cell_filter (CellFilter | CellFilterFuncs | None) – Filter for cell optimization (None for position-only optimization)

  • **filter_kwargs (Any) – Additional arguments passed to cell filter initialization

Returns:

LBFGSState with initialized optimization tensors, or CellLBFGSState if cell_filter is provided

Return type:

LBFGSState | CellLBFGSState

Notes

The optimizer supports two modes of operation: 1. Standard L-BFGS (default): Set alpha=None. The inverse Hessian

diagonal $H_0$ is updated dynamically at each step using the scaling $gamma_k = (s^T y) / (y^T y)$. This is the standard behavior described by Nocedal & Wright.

  1. ASE Compatibility Mode: Set alpha (e.g. 70.0) and step_size=1.0. The inverse Hessian diagonal is fixed at $H_0 = 1/alpha$ throughout the optimization, and the step is scaled by step_size (damping). This matches ase.optimize.LBFGS(alpha=70.0, damping=1.0).