sci_solvers.energy_solvers.dice_solver¶
DICE-based sci_solver implementation.
DICESolver
[source]
¶
DICESolver(*, symmetrize_spin: bool, hamiltonian: HamiltonianData | str | PathLike[str] | None = None, verbose: bool = False, mpirun_options: str | list[str] | None = None, temp_dir: str | None = None, clean_temp_dir: bool = True, select_cutoff: float = 2147483647, tol: float = 1e-10, davidson_tolerance: float = 1e-05, davidson_tolerance_loose: float | None = None, max_hci_iters: int = 1, fci: bool = False, nroots: int = 1, **kwargs: Any)
Bases: EnergyCalculatorBase
sci_solver wrapping the DICE (Dice is Cheap Eigensolver) C++ binary
via qiskit-addon-dice-solver's :func:solve_hci.
Performs a single Davidson diagonalization on the projected Hamiltonian of the input bitstrings (no HCI expansion). The defaults are set to enforce this fixed-space mode:
select_cutoff=2147483647(INT_MAX) prevents Dice from selecting any additional determinants beyond the supplied CI strings.max_hci_iters=1means only one HCI macro-iteration is performed — a single Davidson solve on the projected subspace.tol(HCI energy convergence, Dice'sdE) has no practical effect withmax_hci_iters=1since convergence is never checked across iterations. Diagonalization quality is governed bydavidson_tolerance(Dice'sdavidsonTol, default1e-5) anddavidson_tolerance_loose, both exposed by the wrapper.
Multi-root: that single Davidson solve returns the lowest self.nroots
eigenpairs (solve_hci's n_roots argument), so setting nroots > 1
yields the ground state plus excited states — the multi-root capability the
eigensolver adapters previously exposed. spin_sq projection is still
restricted to 0.0/None (see below).
Concurrent same-node mpirun invocations have been observed to crash
Dice in this environment, so batches are processed sequentially. Use
mpirun_options for intra-call MPI parallelism.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
verbose
|
bool
|
Print per-batch progress / debug output. |
False
|
mpirun_options
|
str | list[str] | None
|
Options for MPI execution (e.g. |
None
|
temp_dir
|
str | None
|
Directory for temporary DICE files. Each batch gets its own subdirectory under this path. |
None
|
clean_temp_dir
|
bool
|
Whether to clean up temporary files on success. The
cleanup is performed by this class rather than by |
True
|
select_cutoff
|
float
|
Coefficient cutoff for HCI determinant selection. The default (INT_MAX) suppresses all selection so Dice diagonalizes exactly the supplied subspace without adding new configurations. |
2147483647
|
tol
|
float
|
HCI energy convergence tolerance, forwarded to |
1e-10
|
davidson_tolerance
|
float
|
Residual tolerance for Dice's final (tight)
Davidson solve, forwarded as |
1e-05
|
davidson_tolerance_loose
|
float | None
|
Residual tolerance for the preliminary
Davidson that runs on each HCI macro-iteration, forwarded as
|
None
|
max_hci_iters
|
int
|
Maximum HCI macro-iterations, forwarded to
|
1
|
fci
|
bool
|
If |
False
|
nroots
|
int
|
Number of lowest roots (states) to solve for per batch,
forwarded to |
1
|
Initialize the DICE HCI solver.
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 = 0.0, **kwargs: Any) -> List[EigenStates]
Matches :func:qiskit_addon_sqd.fermion.solve_sci_batch signature.
Run HCI on each batch via DICE.
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, shape |
required |
norb
|
int
|
Number of spatial orbitals. |
required |
nelec
|
Tuple[int, int] | int
|
|
required |
spin_sq
|
float | None
|
Target value for total spin squared (S²). MUST be
|
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
One |
List[EigenStates]
|
class: |
List[EigenStates]
|
input order, each holding the |
|
List[EigenStates]
|
class: |
|
List[EigenStates]
|
energy). Energies are electronic only. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
TypeError
|
If |
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. |