Skip to content

Commit 5f2e4b1

Browse files
authored
Merge branch 'main' into train_trt_decoder_docs
2 parents f4ea4d1 + 69e651a commit 5f2e4b1

File tree

27 files changed

+388
-45
lines changed

27 files changed

+388
-45
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ apps/
9898
# vim files
9999
*.tmp
100100

101+
# Wheel files
102+
*.whl
103+
101104
# Temporary build files for metapackages
102105
libs/*/python/metapackages/LICENSE
103106
libs/*/python/metapackages/NOTICE

README.md

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,37 @@
11
# Welcome to the CUDA-QX repository
22

3-
This repository contains a set of libraries that build on
4-
NVIDIA CUDA-Q. These libraries enable the rapid development of hybrid quantum-classical
5-
application code leveraging state-of-the-art CPUs, GPUs, and QPUs.
3+
This repository contains a set of libraries that build on
4+
NVIDIA CUDA-Q. These libraries enable the rapid development of hybrid quantum-classical
5+
application code leveraging state-of-the-art CPUs, GPUs, and QPUs.
66

77
## Getting Started
8-
To learn more about how to work with the CUDA-QX libraries, please take a look at the
9-
[CUDA-QX Documentation][cudaqx_docs]. The page contains detailed
10-
[installation instructions][official_install] for officially released packages.
8+
9+
To learn more about how to work with the CUDA-QX libraries, please take a look at the
10+
[CUDA-QX Documentation][cudaqx_docs]. The page contains detailed
11+
[installation instructions][official_install] for officially released packages.
1112

1213
[cudaqx_docs]: https://nvidia.github.io/cudaqx
1314
[official_install]: https://nvidia.github.io/cudaqx/quickstart/installation.html
1415

1516
## Contributing
1617

1718
There are many ways in which you can get involved with CUDA-QX. If you are
18-
interested in developing quantum applications with the CUDA-QX libraries,
19-
this repository is a great place to get started! For more information about
20-
contributing to the CUDA-QX platform, please take a look at
19+
interested in developing quantum applications with the CUDA-QX libraries,
20+
this repository is a great place to get started! For more information about
21+
contributing to the CUDA-QX platform, please take a look at
2122
[Contributing.md](./Contributing.md).
2223

2324
## License
2425

2526
The code in this repository is licensed under [Apache License 2.0](./LICENSE).
2627

28+
When distributed via PyPI, GHCR, or NGC, the binaries generated from this source
29+
code are also distributed under the Apache License 2.0; however, the
30+
`libcudaq-qec-nv-qldpc-decoder.so` library is closed source and is subject to
31+
the [NVIDIA Software License Agreement][github_qec_license]
32+
33+
[github_qec_license]: https://github.com/NVIDIA/cudaqx/blob/main/libs/qec/LICENSE
34+
2735
Contributing a pull request to this repository requires accepting the
2836
Contributor License Agreement (CLA) declaring that you have the right to, and
2937
actually do, grant us the rights to use your contribution. A CLA-bot will

docker/release/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ ARG TARGETARCH
2727

2828
USER root
2929

30+
# Update the copyright notification:
31+
RUN echo -e "This container also includes CUDA-Q QEC and CUDA-Q Solvers.\n"\
32+
"Use of this container implies consent to the NVIDIA Software License agreement at\n"\
33+
"https://github.com/NVIDIA/cudaqx/blob/main/libs/qec/LICENSE\n" >> "$CUDA_QUANTUM_PATH/Copyright.txt"
34+
3035
# Determine the appropriate zip file
3136
COPY installed_files-${TARGETARCH}.zip /tmp/
3237

docs/sphinx/api/qec/cpp_api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ NVIDIA QLDPC Decoder
5151

5252
.. include:: nv_qldpc_decoder_api.rst
5353

54+
Sliding Window Decoder
55+
----------------------
56+
57+
.. include:: sliding_window_api.rst
58+
5459
Parity Check Matrix Utilities
5560
=============================
5661

docs/sphinx/api/qec/nv_qldpc_decoder_api.rst

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,14 @@
8282
(defaults to 1). Ignored unless `use_osd` is true.
8383
- `osd_order` (int): OSD postprocessor order (defaults to 0). Ref:
8484
`Decoding Across the Quantum LDPC Code Landscape <https://arxiv.org/pdf/2005.07016>`_
85-
- For `osd_method=2` (Exhaustive), the number of possible
86-
permutations searched after OSD-0 grows by 2^osd_order.
87-
- For `osd_method=3` (Combination Sweep), this is the λ parameter. All
88-
weight 1 permutations and the first λ bits worth of weight 2
89-
permutations are searched after OSD-0. This is (syndrome_length -
90-
block_size + λ * (λ - 1) / 2) additional permutations.
91-
- For other `osd_method` values, this is ignored.
85+
86+
- For `osd_method=2` (Exhaustive), the number of possible
87+
permutations searched after OSD-0 grows by 2^osd_order.
88+
- For `osd_method=3` (Combination Sweep), this is the λ parameter. All
89+
weight 1 permutations and the first λ bits worth of weight 2
90+
permutations are searched after OSD-0. This is (syndrome_length -
91+
block_size + λ * (λ - 1) / 2) additional permutations.
92+
- For other `osd_method` values, this is ignored.
9293
- `bp_batch_size` (int): Number of syndromes that will be decoded in
9394
parallel for the BP decoder (defaults to 1)
9495
- `osd_batch_size` (int): Number of syndromes that will be decoded in
@@ -113,6 +114,8 @@
113114
- `scale_factor` (float): The scale factor to use for min-sum. Defaults to 1.0.
114115
When set to 0.0, the scale factor is dynamically computed based on the
115116
number of iterations. Introduced in 0.4.0.
117+
- `proc_float` (string): The processing float type to use. Defaults to
118+
"fp64". Valid values are "fp32" and "fp64". Introduced in 0.5.0.
116119
- `gamma0` (float): Memory strength parameter. Required for `bp_method=2`, and for
117120
`composition=1` (sequential relay). Introduced in 0.5.0.
118121
- `gamma_dist` (vector<float>): Gamma distribution interval [min, max] for disordered

docs/sphinx/api/qec/python_api.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ NVIDIA QLDPC Decoder
3939

4040
.. include:: nv_qldpc_decoder_api.rst
4141

42+
Sliding Window Decoder
43+
----------------------
44+
45+
.. include:: sliding_window_api.rst
46+
4247
.. _tensor_network_decoder_api_python:
4348

4449
Tensor Network Decoder

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 & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,6 @@ The :code:`molecule_options` structure provides extensive configuration for mole
7575
+---------------------+---------------+------------------+------------------------------------------+
7676
| integrals_casscf | bool | false | Use CASSCF orbitals for integrals |
7777
+---------------------+---------------+------------------+------------------------------------------+
78-
| potfile | optional | nullopt | Path to external potential file |
79-
| | <string> | | |
80-
+---------------------+---------------+------------------+------------------------------------------+
8178
| verbose | bool | false | Enable detailed output logging |
8279
+---------------------+---------------+------------------+------------------------------------------+
8380

@@ -495,12 +492,32 @@ Available Operator Pools
495492

496493
CUDA-QX provides several pre-built operator pools for ADAPT-VQE:
497494

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

docs/sphinx/examples/solvers/python/generate_molecular_hamiltonians.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
# [Begin Documentation]
1010
import cudaq_solvers as solvers
1111

12-
# Generate active space Hamiltonian using HF molecular orbitals
12+
# Generate active space Hamiltonian using RHF molecular orbitals
1313

1414
geometry = [('N', (0.0, 0.0, 0.5600)), ('N', (0.0, 0.0, -0.5600))]
1515
molecule = solvers.create_molecule(geometry,
@@ -20,7 +20,24 @@
2020
norb_cas=3,
2121
verbose=True)
2222

23-
print('N2 HF Hamiltonian')
23+
print('N2 RHF Hamiltonian')
24+
print('Energies : ', molecule.energies)
25+
print('No. of orbitals: ', molecule.n_orbitals)
26+
print('No. of electrons: ', molecule.n_electrons)
27+
28+
# Generate active space Hamiltonian using UHF molecular orbitals
29+
30+
geometry = [('N', (0.0, 0.0, 0.5600)), ('N', (0.0, 0.0, -0.5600))]
31+
molecule = solvers.create_molecule(geometry,
32+
'sto-3g',
33+
0,
34+
0,
35+
nele_cas=2,
36+
norb_cas=3,
37+
UR=True,
38+
verbose=True)
39+
40+
print('N2 UHF Hamiltonian')
2441
print('Energies : ', molecule.energies)
2542
print('No. of orbitals: ', molecule.n_orbitals)
2643
print('No. of electrons: ', molecule.n_electrons)
@@ -83,3 +100,36 @@
83100
print('Energies: ', molecule.energies)
84101
print('No. of orbitals: ', molecule.n_orbitals)
85102
print('No. of electrons: ', molecule.n_electrons)
103+
104+
# For open-shell systems: Generate active space Hamiltonian using ROHF molecular orbitals
105+
geometry = [('N', (0.0, 0.0, 0.5600)), ('N', (0.0, 0.0, -0.5600))]
106+
molecule = solvers.create_molecule(geometry,
107+
'sto-3g',
108+
1,
109+
1,
110+
nele_cas=3,
111+
norb_cas=3,
112+
ccsd=True,
113+
verbose=True)
114+
115+
print('N2+ ROHF Hamiltonian')
116+
print('Energies : ', molecule.energies)
117+
print('No. of orbitals: ', molecule.n_orbitals)
118+
print('No. of electrons: ', molecule.n_electrons)
119+
120+
# For open-shell systems: Generate active space Hamiltonian using UHF molecular orbitals
121+
geometry = [('N', (0.0, 0.0, 0.5600)), ('N', (0.0, 0.0, -0.5600))]
122+
molecule = solvers.create_molecule(geometry,
123+
'sto-3g',
124+
1,
125+
1,
126+
nele_cas=3,
127+
norb_cas=3,
128+
ccsd=True,
129+
UR=True,
130+
verbose=True)
131+
132+
print('N2+ UHF Hamiltonian')
133+
print('Energies : ', molecule.energies)
134+
print('No. of orbitals: ', molecule.n_orbitals)
135+
print('No. of electrons: ', molecule.n_electrons)

0 commit comments

Comments
 (0)