Skip to content

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. Following torch_sci_solver's established mode="gdb" contract, the (strs_a, strs_b) arrays are treated as parallel length-N pair lists — index i defines 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:EnergyCalculatorBase.

required
hamiltonian HamiltonianData | str | PathLike[str] | None

Optional bound Hamiltonian (instance or FCIDUMP path).

None
mode str

"tpb" (alpha-beta product subspace, default) or "gdb" (explicit parallel-pairs determinant list). See the module docstring for the GDB semantics.

'tpb'
device str

Compute device passed to sbd's DeviceConfig — "cpu" (default), "gpu" (Thrust), "gpu-omp", or "auto".

'cpu'
sbd_config dict[str, Any] | None

Optional dict of SBD tunables (e.g. method, eps, max_it) overriding the package defaults.

None
fcidump_path str | Path | None

If set, sbd loads this FCIDUMP directly (its ECORE is subtracted so returned energies stay electronic). Must be visible to every MPI rank on multi-node runs.

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 True set SBD's do_rdm = 1 so each result carries the spin-summed rdm1/rdm2 (assembled by sbd.sbd_solver.assemble_rdms). An explicit do_rdm in sbd_config takes precedence.

False
verbose bool

Print solver-specific progress output.

False
verify_convergence bool

mode="tpb" only. When True the returned wavefunction is re-checked with an independent torch matvec (:meth:_tpb_convergence_state) and the result carries a state of "converged"/"not_converged". That check costs about as much time as the sbd solve itself plus extra GPU memory, so it is off by default; results then carry no state.

False

Raises:

Type Description
ValueError

If mode is neither "tpb" nor "gdb".

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 (strs_a, strs_b) int64-array tuples. In mode="gdb" each pair is interpreted as parallel lists (see the module docstring), so len(strs_a) == len(strs_b) is required per batch.

required
hcore ndarray

One-electron integrals, shape (norb, norb).

required
eri ndarray

Two-electron repulsion integrals (any pyscf-accepted packing).

required
norb int

Number of spatial orbitals.

required
nelec Tuple[int, int] | int

(n_alpha, n_beta). A scalar nelec (the spinless flat spin-orbital path) is rejected with NotImplementedError — this solver does not implement it.

required
spin_sq float | None

Must be None; sbd has no spin-projection mechanism.

None

Returns:

Name Type Description
One List[EigenStates]

class:~sci_solvers.eigen_states.EigenStates per batch, in

List[EigenStates]

input order, each wrapping the single ground-state

List[EigenStates]

class:SCIResult. Energies are electronic only.

Raises:

Type Description
NotImplementedError

If nelec is a scalar (the spinless path).

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 (strs_a, strs_b) int64-array tuples. Provide exactly one of this argument or bitstring_matrix_batches.

None
bitstring_matrix_batches List[ndarray] | None

List of boolean NumPy matrices, one per batch. Provide exactly one of this argument or ci_strs_batches.

None
sort_ci_strs bool

Sort and deduplicate each batch's alpha/beta CI strings with np.unique before solving. Defaults to True so solvers that require strictly ascending strings (the general-algebra family) work out of the box; the bitstring path is already sorted, so this is a no-op there. Pair-mode (mode="gdb") solvers are exempt: their (strs_a, strs_b) are parallel (alpha_i, beta_i) lists, so sorting each one independently would break the pairing (they dedup/sort the pair list themselves). Pass False to forward the strings exactly as given.

True
**solver_call_kwargs Any

Additional kwargs forwarded to sci_solver_callable.

{}

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 (strs_a, strs_b) tuples (spatial), or a list of flat strs arrays (spinless — a scalar nelec; see :meth:sci_solver_callable_eigen_states). Each spatial tuple defines a subspace via the outer product of unique alpha and beta CI strings (int64 arrays where bit i of each integer indicates occupancy of orbital i).

required
hcore ndarray

One-electron integrals, shape (norb, norb).

required
eri ndarray

Two-electron repulsion integrals. Either full 4-D (norb,)*4 or a packed form (4-fold / 8-fold) — what's accepted depends on the concrete solver.

required
norb int

Number of spatial orbitals.

required
nelec 'Tuple[int, int] | int'

(n_alpha, n_beta) (spatial), or a scalar total N (spinless — not every solver implements this; see :meth:sci_solver_callable_eigen_states).

required
**kwargs Any

Solver-specific optional arguments. See each concrete solver for the accepted set.

{}

Returns:

Name Type Description
One List[SCIResult]

class:SCIResult (the ground state) per input batch, in input

List[SCIResult]

order. energy fields are electronic only; callers add e_nuc

List[SCIResult]

themselves to obtain chemical totals.