SQD-compatible solver (sbd.sbd_solver)¶
SBD as the eigensolver of a qiskit-addon-sqd loop. Pass
solve_sci_batch(), with its options bound by functools.partial(), as the
sci_solver argument of diagonalize_fermionic_hamiltonian; it runs on every MPI
rank. These solvers use SBD’s TPB method. GDB has no SQD-loop integration; call
sbd.gdb_diag() directly.
- solve_sci_batch(ci_strings, one_body_tensor, two_body_tensor, norb, nelec, *, spin_sq=None, mpi_comm=None, sbd_config=None, temp_dir=None, clean_temp_dir=True, device_config=None, fcidump_path=None)[source]¶
Diagonalize Hamiltonian in multiple subspaces using SBD.
The FCIDUMP file is loaded once and reused across all batches.
- Parameters:
ci_strings (list[tuple[ndarray, ndarray]]) – List of (strings_a, strings_b) pairs.
one_body_tensor (ndarray) – The one-body tensor of the Hamiltonian.
two_body_tensor (ndarray) – The two-body tensor of the Hamiltonian.
norb (int) – The number of spatial orbitals.
nelec (tuple[int, int]) – The numbers of alpha and beta electrons.
spin_sq (float | None) – Target value for total spin squared (unused by SBD).
mpi_comm (Comm | None) – MPI communicator. If None, uses MPI.COMM_WORLD.
sbd_config (dict | None) – Dictionary of SBD configuration parameters.
temp_dir (str | Path | None) – Directory for temporary files.
clean_temp_dir (bool) – Whether to delete intermediate files.
device_config – DeviceConfig object to select CPU/GPU backend.
fcidump_path (str | Path | None) – If set, load the FCIDUMP directly from this path on every rank and skip the tensor->file round-trip. MUST be on a filesystem visible to every rank (shared on multi-node runs). When None (default), rank 0 writes a regenerated FCIDUMP into
temp_dirand every rank opens that file, which requirestemp_dirto be shared for multi-node runs.
- Returns:
List of SCIResult for each batch.
- Return type:
list[SCIResult]
- solve_sci(ci_strings, one_body_tensor, two_body_tensor, norb, nelec, *, spin_sq=None, mpi_comm=None, sbd_config=None, temp_dir=None, clean_temp_dir=True, device_config=None, fcidump_path=None)[source]¶
Diagonalize Hamiltonian in subspace defined by CI strings using SBD.
- Parameters:
ci_strings (tuple[ndarray, ndarray]) – Pair (strings_a, strings_b) of CI string arrays.
one_body_tensor (ndarray) – The one-body tensor of the Hamiltonian.
two_body_tensor (ndarray) – The two-body tensor of the Hamiltonian.
norb (int) – The number of spatial orbitals.
nelec (tuple[int, int]) – The numbers of alpha and beta electrons.
spin_sq (float | None) – Target value for total spin squared (unused by SBD).
mpi_comm (Comm | None) – MPI communicator. If None, uses MPI.COMM_WORLD.
sbd_config (dict | None) – Dictionary of SBD configuration parameters.
temp_dir (str | Path | None) – Directory for temporary files.
clean_temp_dir (bool) – Whether to delete intermediate files.
device_config – DeviceConfig object to select CPU/GPU backend.
fcidump_path (str | Path | None) – If set, load the FCIDUMP directly from this path on every rank and skip the tensor->file round-trip. MUST be on a filesystem visible to every rank (shared on multi-node runs). When None (default), rank 0 writes a regenerated FCIDUMP into
temp_dirand every rank opens that file, which requirestemp_dirto be shared for multi-node runs.
- Returns:
The diagonalization result as SCIResult.
- Return type:
SCIResult
- assemble_rdms(results, norb)[source]¶
Build spin-summed (rdm1, rdm2) from SBD’s raw one_p_rdm/two_p_rdm.
Returns (None, None) when
do_rdmwas 0 (SBD leaves these keys as empty lists in that case – seesbdiag.h’sdo_rdm == 0branch, which only computes the diagonal density, not the correlation functions), matching SCIResult’s ownrdm1/rdm2default.The layout conversion was verified against PySCF’s
make_rdm1andmake_rdm2on all three backends (cpu, gpu, gpu-omp), both element-wise and through the energy identityE = einsum("pr,pr->",rdm1,hcore) + 0.5*einsum("prqs,prqs->",rdm2,eri)with whichqiskit-addon-sqdcontractsSCIResult.rdm1andrdm2.SBD’s layout, as documented in upstream SBD’s
docs/user-guide.md:one_p_rdm[s][i + L*j] = <c+_{i,s} c_{j,s}> two_p_rdm[s+2t][i + L*j + L^2*k + L^3*l] = <c+_{i,s} c+_{j,t} c_{l,t} c_{k,s}>
A Fortran-order reshape implements those flat-index formulas directly. rdm1 needs no further transpose, and the spin-summed rdm2 is transposed with axes
(0, 2, 1, 3)into the “prqs” orderSCIResultexpects.