sci_solvers.energy_solvers.sbd_solver¶
SBD sci_solver backed by the in-process sbd-eigensolver package.
Wraps RIKEN's open-source sbd package (import sbd, pybind11 in-process
API — no subprocess) in this package's :class:EnergyCalculatorBase contract.
Two diagonalization modes are exposed through the mode constructor argument:
-
mode="tpb"(Tensor-Product Basis, the default): each batch's subspace is the Cartesian product of its alpha and beta CI-string lists. This delegates directly to the package's :func:sbd.sbd_solver.solve_sci_batch. -
mode="gdb"(General-Determinant Basis): each batch's subspace is an explicit sparse determinant list. Followingtorch_sci_solver's establishedmode="gdb"contract, the(strs_a, strs_b)arrays are treated as parallel length-N pair lists — indexidefines determinant(alpha_i, beta_i)— NOT an outer product. This is deliberately not a drop-in for qiskit-addon-sqd's per-spin recovery loop: feeding it a product-style(strs_a, strs_b)silently diagonalizes a different subspace.
Spin handling¶
The sbd package has NO spin-projection mechanism (spin_sq is accepted but
ignored by both config classes and both diag functions). This wrapper therefore
rejects any non-None spin_sq kwarg.
sbd computes in interleaved-Wick parity, which differs from the spin-block
convention PySCF and SCIState assume by a per-determinant-pair sign. In
mode="tpb", sbd (from sbd-eigensolver 1.7.1) converts the amplitudes of the
SCIState it returns itself, so downstream <S^2> and RDMs are correct without a
further conversion here; converting again would put the signs back and give a singlet a
spuriously large <S^2> even though the energy is exact. mode="gdb" instead
returns a flat :class:~torch_sci_solver.torch_impl.pairs.PairSCIState over the
diagonalized (alpha_i, beta_i) pairs, left in interleaved-Wick parity — the same
contract and convention as the general-algebra solvers' mode="gdb"
(torch_sci_solver's pair RDM builders assume it by default).
Returned energy¶
Each SCIResult.energy is the ELECTRONIC energy only; callers add e_nuc
themselves, matching qiskit-addon-sqd's convention. When integrals are handed in
memory the package writes a regenerated FCIDUMP with ECORE=0; when
fcidump_path is given, the file's ECORE is subtracted so the contract holds.
Installation¶
sbd has no PyPI wheel — it compiles at install against local MPI/BLAS. Prepare
the toolchain with scripts/energy_solvers/build_sbd.sh, then
uv sync --extra sbd. Because it is an optional extra, a plain uv sync
never builds it and the base install cannot break.
Convergence (mode="tpb" only)¶
sbd's native Davidson(...) is a void C++ function: it exits identically
whether it converged (norm_R < eps), exhausted max_it restarts, or hit the
max_time wall-clock cap, and reports none of that back through the pybind
boundary — every exit path returns the same energy/wavefunction shape with no
convergence signal attached. mode="tpb" closes this gap itself (see
:meth:SBDSolver._tpb_convergence_state) by recomputing ‖H*W - E*W‖
independently, via the same :class:~sci_solvers.eigen_problem.EigenProblem
operator the general-algebra solvers already share, and comparing it to
sbd_config["eps"] — mirroring
:class:~sci_solvers.energy_solvers.general_algebra_solvers.lobpcg.LobpcgSolver's
identical self-check for scipy's equally silent lobpcg. mode="gdb" does not
yet have this check.
SBDSolver
[source]
¶
SBDSolver(*, symmetrize_spin: bool, hamiltonian: HamiltonianData | str | PathLike[str] | None = None, mode: str = 'tpb', device: str = 'cpu', sbd_config: dict[str, Any] | None = None, fcidump_path: str | Path | None = None, temp_dir: str | Path | None = None, clean_temp_dir: bool = True, compute_rdm2: bool = False, verbose: bool = False, verify_convergence: bool = False)
Bases: EnergyCalculatorBase
sci_solver wrapping RIKEN's in-process sbd-eigensolver package.
mode="tpb" diagonalizes the alpha-beta product subspace (delegated to the
package's batch helper); mode="gdb" diagonalizes an explicit sparse list
of (alpha_i, beta_i) determinant pairs. See the module docstring for the
GDB parallel-pairs semantics, spin handling, and installation notes.
Initialize the SBDSolver.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symmetrize_spin
|
bool
|
Forwarded to :class: |
required |
hamiltonian
|
HamiltonianData | str | PathLike[str] | None
|
Optional bound Hamiltonian (instance or FCIDUMP path). |
None
|
mode
|
str
|
|
'tpb'
|
device
|
str
|
Compute device passed to |
'cpu'
|
sbd_config
|
dict[str, Any] | None
|
Optional dict of SBD tunables (e.g. |
None
|
fcidump_path
|
str | Path | None
|
If set, |
None
|
temp_dir
|
str | Path | None
|
Directory for the package's intermediate files. |
None
|
clean_temp_dir
|
bool
|
Delete those intermediate files on exit. |
True
|
compute_rdm2
|
bool
|
When |
False
|
verbose
|
bool
|
Print solver-specific progress output. |
False
|
verify_convergence
|
bool
|
|
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
sci_solver_callable_eigen_states
¶
sci_solver_callable_eigen_states(ci_strs_batches: List[Tuple[ndarray, ndarray]] | List[ndarray], hcore: ndarray, eri: ndarray, norb: int, nelec: Tuple[int, int] | int, spin_sq: float | None = None, **kwargs: Any) -> List[EigenStates]
Diagonalize each batch via the sbd package.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ci_strs_batches
|
List[Tuple[ndarray, ndarray]] | List[ndarray]
|
List of |
required |
hcore
|
ndarray
|
One-electron integrals, shape |
required |
eri
|
ndarray
|
Two-electron repulsion integrals (any pyscf-accepted packing). |
required |
norb
|
int
|
Number of spatial orbitals. |
required |
nelec
|
Tuple[int, int] | int
|
|
required |
spin_sq
|
float | None
|
Must be |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
One |
List[EigenStates]
|
class: |
List[EigenStates]
|
input order, each wrapping the single ground-state |
|
List[EigenStates]
|
class: |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If |
compute_energy
¶
compute_energy(ci_strs_batches: List[Tuple[ndarray, ndarray]] | None = None, bitstring_matrix_batches: List[ndarray] | None = None, sort_ci_strs: bool = True, **solver_call_kwargs: Any) -> List[SCIResult]
Compute energies for each batch of CI strs.
Note - to get from bitstrings into ci_strs you can use:
from qiskit_addon_sqd.fermion import bitstring_matrix_to_ci_strs
ci_strs = bitstring_matrix_to_ci_strs(bitstrings_to_use, open_shell=False) #or open_shell==True, depending on your case
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ci_strs_batches
|
List[Tuple[ndarray, ndarray]] | None
|
List of |
None
|
bitstring_matrix_batches
|
List[ndarray] | None
|
List of boolean NumPy matrices, one per batch.
Provide exactly one of this argument or |
None
|
sort_ci_strs
|
bool
|
Sort and deduplicate each batch's alpha/beta CI strings with
|
True
|
**solver_call_kwargs
|
Any
|
Additional kwargs forwarded to |
{}
|
sci_solver_callable
¶
sci_solver_callable(ci_strs_batches: 'List[Tuple[np.ndarray, np.ndarray]] | List[np.ndarray]', hcore: ndarray, eri: ndarray, norb: int, nelec: 'Tuple[int, int] | int', **kwargs: Any) -> List[SCIResult]
Diagonalize each batch's CI-string subspace, returning ground states.
The qiskit-addon-sqd entry point: matches the sci_solver signature
expected by qiskit_addon_sqd.fermion.diagonalize_fermionic_hamiltonian.
Thin wrapper over :meth:sci_solver_callable_eigen_states that keeps
each batch's ground state (root 0) and discards the excited states,
since the SQD recovery loop consumes only the ground state. To access
excited states, call :meth:sci_solver_callable_eigen_states directly.
Note - to get from bitstrings into ci_strs you can use:
from qiskit_addon_sqd.fermion import bitstring_matrix_to_ci_strs
ci_strs = bitstring_matrix_to_ci_strs(bitstrings_to_use, open_shell=False) #or open_shell==True, depending on your case
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ci_strs_batches
|
'List[Tuple[np.ndarray, np.ndarray]] | List[np.ndarray]'
|
List of |
required |
hcore
|
ndarray
|
One-electron integrals, shape |
required |
eri
|
ndarray
|
Two-electron repulsion integrals. Either full 4-D
|
required |
norb
|
int
|
Number of spatial orbitals. |
required |
nelec
|
'Tuple[int, int] | int'
|
|
required |
**kwargs
|
Any
|
Solver-specific optional arguments. See each concrete solver for the accepted set. |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
One |
List[SCIResult]
|
class: |
List[SCIResult]
|
order. |
|
List[SCIResult]
|
themselves to obtain chemical totals. |