LBFGSState

class torch_sim.optimizers.state.LBFGSState(positions, masses, cell, pbc, atomic_numbers, charge=None, spin=None, system_idx=None, _constraints=<factory>, *, forces, energy, stress, prev_forces, prev_positions, s_history, y_history, step_size, alpha, n_iter, max_atoms)[source]

Bases: OptimState

State for batched L-BFGS minimization (no line search).

Stores the state needed to run a batched Limited-memory BFGS optimizer that uses a fixed step size and the classical two-loop recursion to compute approximate inverse-Hessian-vector products. All tensors are batched across systems via system_idx.

Variables:
  • prev_forces (Tensor) – Previous-step forces [n_atoms, 3]. For cell filter, these are scaled forces (forces @ deform_grad) for ASE compatibility.

  • prev_positions (Tensor) – Previous-step positions [n_atoms, 3]. For cell filter, these are fractional coordinates for ASE compatibility.

  • s_history (Tensor) – Displacement history [n_systems, h, max_atoms, 3] per-system. For cell filter: [n_systems, h, max_atoms + 3, 3] to include cell DOFs. May be padded when systems have different sizes.

  • y_history (Tensor) – Gradient-diff history [n_systems, h, max_atoms, 3] per-system. For cell filter: [n_systems, h, max_atoms + 3, 3] to include cell DOFs. May be padded when systems have different sizes.

  • step_size (Tensor) – Per-system fixed step size [n_systems]

  • alpha (Tensor) – Initial inverse Hessian scale (stiffness) [n_systems]

  • n_iter (Tensor) – Per-system iteration counter [n_systems] (int32)

  • max_atoms (Tensor) – Atoms per system [n_systems] - used for size-binned operations

Parameters: