Skip to content

Commit 0e885f2

Browse files
marwafarbmhowe23
andauthored
[Docs] Add uccgsd to doc (#340)
In this PR: We update the doc and add details about uccgsd implemented in #319 --------- Signed-off-by: marwafar <[email protected]> Co-authored-by: Ben Howe <[email protected]>
1 parent 21c4a1f commit 0e885f2

File tree

3 files changed

+82
-3
lines changed

3 files changed

+82
-3
lines changed

docs/sphinx/api/solvers/cpp_api.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ CUDA-Q Solvers C++ API
66

77
.. doxygenclass:: cudaq::solvers::spin_complement_gsd
88
.. doxygenclass:: cudaq::solvers::uccsd
9+
.. doxygenclass:: cudaq::solvers::uccgsd
910
.. doxygenclass:: cudaq::solvers::qaoa_pool
1011

1112
.. doxygenfunction:: cudaq::solvers::get_operator_pool
@@ -67,6 +68,8 @@ CUDA-Q Solvers C++ API
6768
.. doxygenfunction:: cudaq::solvers::stateprep::double_excitation
6869
.. doxygenfunction:: cudaq::solvers::stateprep::uccsd(cudaq::qview<>, const std::vector<double>&, std::size_t, std::size_t)
6970
.. doxygenfunction:: cudaq::solvers::stateprep::uccsd(cudaq::qview<>, const std::vector<double>&, std::size_t)
71+
.. doxygenfunction:: cudaq::solvers::stateprep::get_uccgsd_pauli_lists
72+
.. doxygenfunction:: cudaq::solvers::stateprep::uccgsd(cudaq::qview<>, const std::vector<double>&, const std::vector<std::vector<cudaq::pauli_word>>&, const std::vector<std::vector<double>>&)
7073

7174

7275
.. doxygenstruct:: cudaq::solvers::qaoa_result

docs/sphinx/api/solvers/python_api.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ CUDA-Q Solvers Python API
2727
.. autofunction:: cudaq_solvers.stateprep.double_excitation
2828
.. autofunction:: cudaq_solvers.stateprep.get_num_uccsd_parameters
2929
.. autofunction:: cudaq_solvers.stateprep.get_uccsd_excitations
30+
.. autofunction:: cudaq_solvers.stateprep.get_uccgsd_pauli_lists
31+
.. autofunction:: cudaq_solvers.stateprep.uccgsd
3032

3133
.. autofunction:: cudaq_solvers.get_num_qaoa_parameters
3234

docs/sphinx/components/solvers/introduction.rst

Lines changed: 77 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -495,12 +495,32 @@ Available Operator Pools
495495

496496
CUDA-QX provides several pre-built operator pools for ADAPT-VQE:
497497

498-
* **spin_complement_gsd**: Spin-complemented generalized singles and doubles
499-
* **uccsd**: UCCSD operators
498+
* **spin_complement_gsd**: Spin-complemented generalized singles and doubles.
499+
This operator pool combines generalized excitations with enforced spin symmetry. It is
500+
more powerful than UCCSD because its generalized operators capture more electron correlation,
501+
and it is more reliable than both UCCSD and UCCGSD because its spin-complemented
502+
construction prevents the unphysical "spin-symmetry breaking".
503+
* **uccsd**: UCCSD operators.
504+
The standard, chemically-inspired ansatz. Excitation Space
505+
is Restricted. It only includes single and double excitations
506+
where electrons move from a reference-occupied orbital (i)
507+
to a reference-virtual orbital (a),
508+
relative to the starting Hartree-Fock state. Excellent at capturing dynamic correlation
509+
(short-range, instantaneous electron interactions).
510+
* **uccgsd**: UCC generalized singles and doubles.
511+
More expressive than UCCSD, as it includes all possible
512+
single and double excitations, regardless of their occupied/virtual status in the reference state.
513+
Capable of capturing both dynamic and static (strong) correlation
514+
but at the cost of increased circuit depth and parameter count.
500515
* **qaoa**: QAOA mixer excitation operators
501-
516+
It generates all possible single-qubit X and Y terms, along with all possible
517+
two-qubit interaction terms (XX, YY, XY, YX, XZ, ZX, YZ, ZY) across every pair of qubits.
518+
This pool offers a rich basis for constructing the mixer Hamiltonian for ADAPT-QAOA algorithms.
519+
502520
.. code-block:: python
503521
522+
import cudaq_solvers as solvers
523+
504524
# Generate different operator pools
505525
gsd_ops = solvers.get_operator_pool(
506526
"spin_complement_gsd",
@@ -513,6 +533,60 @@ CUDA-QX provides several pre-built operator pools for ADAPT-VQE:
513533
num_electrons=molecule.n_electrons
514534
)
515535
536+
uccgsd_ops = solvers.get_operator_pool(
537+
"uccgsd",
538+
num_orbitals=molecule.n_orbitals
539+
)
540+
541+
Available Ansatz
542+
^^^^^^^^^^^^^^^^^^
543+
544+
CUDA-QX provides several state preparations ansatz for VQE.
545+
546+
* **uccsd**: UCCSD operators
547+
* **uccgsd**: UCC generalized singles and doubles
548+
549+
.. code-block:: python
550+
551+
import cudaq_solvers as solvers
552+
553+
# Using UCCSD ansatz
554+
geometry = [('H', (0., 0., 0.)), ('H', (0., 0., .7474))]
555+
molecule = solvers.create_molecule(geometry, 'sto-3g', 0, 0, casci=True)
556+
557+
numQubits = molecule.n_orbitals * 2
558+
numElectrons = molecule.n_electrons
559+
spin = 0
560+
561+
@cudaq.kernel
562+
def ansatz(thetas: list[float]):
563+
q = cudaq.qvector(numQubits)
564+
for i in range(numElectrons):
565+
x(q[i])
566+
solvers.stateprep.uccsd(q, thetas, numElectrons, spin)
567+
568+
569+
# Using UCCGSD ansatz
570+
geometry = [('H', (0., 0., 0.)), ('H', (0., 0., .7474))]
571+
molecule = solvers.create_molecule(geometry, 'sto-3g', 0, 0, casci=True)
572+
573+
numQubits = molecule.n_orbitals * 2
574+
numElectrons = molecule.n_electrons
575+
576+
# Get grouped Pauli words and coefficients from UCCGSD pool
577+
pauliWordsList, coefficientsList = solvers.stateprep.get_uccgsd_pauli_lists(
578+
numQubits, only_singles=False, only_doubles=False)
579+
580+
@cudaq.kernel
581+
def ansatz(numQubits: int, numElectrons: int, thetas: list[float],
582+
pauliWordsList: list[list[cudaq.pauli_word]],
583+
coefficientsList: list[list[float]]):
584+
q = cudaq.qvector(numQubits)
585+
for i in range(numElectrons):
586+
x(q[i])
587+
solvers.stateprep.uccgsd(q, thetas, pauliWordsList, coefficientsList)
588+
589+
516590
Algorithm Parameters
517591
^^^^^^^^^^^^^^^^^^^^^^
518592

0 commit comments

Comments
 (0)