QSCISolver

class QSCISolver(*, backend, optimizer, ansatz=None, max_iterations=10, qsci_options=None, **vqe_kwargs)[source]

Bases: object

PySCF CASCI/CASSCF active-space solver backed by QSCI.

Assign an instance to the fcisolver of a PySCF mcscf.CASCI or mcscf.CASSCF object. Each kernel() call runs a QSCI ensemble on the active-space Hamiltonian whose sampling program is a VQE, trained afresh each call. The VQE’s samples with the active space’s alpha and beta electron counts seed the subspace, which QSCI then grows and diagonalises with an S^2 - S(S+1) penalty toward the lowest spin those counts allow, S = |n_alpha - n_beta| / 2. The final QSCIState takes the place of PySCF’s CI vector, so mc.ci is that state. Requires the chem extra.

Variables:
  • backend – Backend the QSCI ensembles run on.

  • optimizer – Optimizer configuration; each VQE trains with its own copy.

  • ansatz – Ansatz of every VQE, or None for VQE’s default.

  • max_iterations – Optimisation iterations of each VQE.

  • qsci_options – Further QSCI arguments.

  • vqe_kwargs – Further VQE arguments.

  • nroots (int) – States solved for; only 1 is supported.

  • converged – Whether the last VQE run’s optimizer reported success.

Configure the QSCI run of every kernel() call.

Parameters:
  • backend (CircuitRunner) – Backend the QSCI ensembles run on.

  • optimizer (Optimizer) – Optimizer configuration; each VQE trains with its own copy.

  • ansatz (Ansatz | None) – Ansatz of every VQE. Defaults to VQE’s default.

  • max_iterations (int) – Optimisation iterations of each VQE.

  • qsci_options (Mapping[str, Any] | None) – Further QSCI arguments, e.g. n_expansions or lambda_penalty.

  • **vqe_kwargs (Any) – Further VQE arguments, e.g. n_layers.

Raises:

ValueError – If qsci_options sets config_filter or penalty, which the solver derives from the active space’s electron counts.

Attributes Summary

Methods Summary

approx_kernel(h1e, eri, norb, nelec[, ci0, ...])

The last kernel() result, for CASSCF's approximate CI steps.

kernel(h1e, eri, norb, nelec[, ci0, ecore])

Run QSCI on the active space, seeded by a VQE's samples.

make_rdm1(ci, norb, nelec)

Spin-summed 1-RDM of ci.

make_rdm12(ci, norb, nelec)

Spin-summed 1- and 2-RDMs of ci.

make_rdm12s(ci, norb, nelec)

Spin RDMs of ci, in PySCF's make_rdm12s layout.

make_rdm1s(ci, norb, nelec)

Alpha and beta 1-RDMs of ci.

spin_square(ci, norb, nelec)

<S^2> and the multiplicity 2S + 1 of ci.

Attributes Documentation

nroots: int = 1

Methods Documentation

approx_kernel(h1e, eri, norb, nelec, ci0=None, ecore=0.0, **kwargs)[source]

The last kernel() result, for CASSCF’s approximate CI steps.

Runs kernel() when there is no last result.

Return type:

tuple[float, QSCIState]

kernel(h1e, eri, norb, nelec, ci0=None, ecore=0.0, **kwargs)[source]

Run QSCI on the active space, seeded by a VQE’s samples.

Parameters:
  • h1e (ArrayLike) – One-body integrals, (norb, norb).

  • eri (ArrayLike) – Two-body integrals in chemist order, in any PySCF packing.

  • norb (int) – Active orbitals.

  • nelec (int | tuple[int, int]) – Active electrons, as a total or (n_alpha, n_beta).

  • ci0 (Any) – Unused.

  • ecore (float) – Core energy.

  • **kwargs (Any) – Further PySCF solver options, unused.

Return type:

tuple[float, QSCIState]

Returns:

<H> of the final state with ecore included, a variational upper bound, and the QSCIState.

Raises:
  • NotImplementedError – If nroots is not 1, or the integrals are unrestricted.

  • ValueError – If no sample has the active space’s electron counts.

make_rdm1(ci, norb, nelec)[source]

Spin-summed 1-RDM of ci.

Return type:

ndarray

make_rdm12(ci, norb, nelec)[source]

Spin-summed 1- and 2-RDMs of ci.

Return type:

tuple[ndarray, ndarray]

make_rdm12s(ci, norb, nelec)[source]

Spin RDMs of ci, in PySCF’s make_rdm12s layout.

Return type:

tuple[tuple[ndarray, ndarray], tuple[ndarray, ndarray, ndarray]]

make_rdm1s(ci, norb, nelec)[source]

Alpha and beta 1-RDMs of ci.

Return type:

tuple[ndarray, ndarray]

spin_square(ci, norb, nelec)[source]

<S^2> and the multiplicity 2S + 1 of ci.

Return type:

tuple[float, float]