Skip to content

Commit 63702eb

Browse files
authored
Merge branch 'main' into pr-sliding-window-docs
2 parents f2dba1f + d1cb2d5 commit 63702eb

File tree

28 files changed

+611
-59
lines changed

28 files changed

+611
-59
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/nv_qldpc_decoder_api.rst

Lines changed: 52 additions & 14 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
@@ -99,16 +100,53 @@
99100
- `clip_value` (float): Value to clip the BP messages to. Should be a
100101
non-negative value (defaults to 0.0, which disables clipping). Introduced in
101102
0.4.0.
102-
- `bp_method` (int): The BP method to use. 0 for sum-product, 1 for min-sum.
103-
Defaults to 0. Introduced in 0.4.0.
103+
- `bp_method` (int): Core BP algorithm to use (defaults to 0). Introduced in 0.4.0,
104+
expanded in 0.5.0:
105+
106+
- 0: sum-product
107+
- 1: min-sum (introduced in 0.4.0)
108+
- 2: min-sum+mem (uniform memory strength, introduced in 0.5.0)
109+
- 3: min-sum+dmem (disordered memory strength, introduced in 0.5.0)
110+
- `composition` (int): Iteration strategy (defaults to 0). Introduced in 0.5.0:
111+
112+
- 0: Standard (single run)
113+
- 1: Sequential relay (multiple gamma legs). Requires: `bp_method=3`, `srelay_config`
104114
- `scale_factor` (float): The scale factor to use for min-sum. Defaults to 1.0.
105115
When set to 0.0, the scale factor is dynamically computed based on the
106116
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.
119+
- `gamma0` (float): Memory strength parameter. Required for `bp_method=2`, and for
120+
`composition=1` (sequential relay). Introduced in 0.5.0.
121+
- `gamma_dist` (vector<float>): Gamma distribution interval [min, max] for disordered
122+
memory strength. Required for `bp_method=3` if `explicit_gammas` not provided.
123+
Introduced in 0.5.0.
124+
- `explicit_gammas` (vector<vector<float>>): Explicit gamma values for each variable node.
125+
For `bp_method=3` with `composition=0`, provide a 2D vector where each row has
126+
`block_size` columns. For `composition=1` (Sequential relay), provide `num_sets` rows
127+
(one per relay leg). Overrides `gamma_dist` if provided. Introduced in 0.5.0.
128+
- `srelay_config` (heterogeneous_map): Sequential relay configuration (required for
129+
`composition=1`). Contains the following parameters. Introduced in 0.5.0:
130+
131+
- `pre_iter` (int): Number of pre-iterations to run before relay legs
132+
- `num_sets` (int): Number of relay sets (legs) to run
133+
- `stopping_criterion` (string): When to stop relay legs:
134+
135+
- "All": Run all legs
136+
- "FirstConv": Stop relay after first convergence
137+
- "NConv": Stop after N convergences (requires `stop_nconv` parameter)
138+
- `stop_nconv` (int): Number of convergences to wait for before stopping
139+
(required only when `stopping_criterion="NConv"`)
140+
- `bp_seed` (int): Seed for random number generation used in `bp_method=3` (disordered
141+
memory BP). Optional parameter, defaults to 42 if not provided. Introduced in 0.5.0.
107142
- `opt_results` (heterogeneous_map): Optional results to return. This field can be
108143
left empty if no additional results are desired. Choices are:
109-
- `bp_llr_history` (int): Return the last `bp_llr_history` iterations
110-
of the BP LLR history. Minimum value is 0 and maximum value is
111-
max_iterations. The actual number of returned iterations might be fewer
112-
than `bp_llr_history` if BP converges before the requested number of
113-
iterations. Introduced in 0.4.0.
144+
145+
- `bp_llr_history` (int): Return the last `bp_llr_history` iterations
146+
of the BP LLR history. Minimum value is 0 and maximum value is
147+
max_iterations. The actual number of returned iterations might be fewer
148+
than `bp_llr_history` if BP converges before the requested number of
149+
iterations. Introduced in 0.4.0. Note: Not supported for `composition=1`.
150+
- `num_iter` (bool): If true, return the number of BP iterations run.
151+
Introduced in 0.5.0.
114152

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/qec/introduction.rst

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,13 +640,29 @@ The Quantum Low-Density Parity-Check (QLDPC) decoder leverages GPU-accelerated b
640640
Since belief propagation is an iterative method which may not converge, decoding can be improved with a second-stage post-processing step. The `nv-qldpc-decoder`
641641
API provides various post-processing options, which can be selected through its parameters.
642642

643+
**Belief Propagation Methods:**
644+
645+
The decoder supports multiple BP algorithms (configured via ``bp_method``):
646+
647+
* **Sum-Product BP** (``bp_method=0``, default): Classic belief propagation algorithm that computes exact probabilities.
648+
* **Min-Sum BP** (``bp_method=1``): Approximation to sum-product that uses min operations instead of sum. Optionally accepts ``scale_factor``.
649+
* **Memory-based BP** (``bp_method=2``): Min-sum with uniform memory strength across all variable nodes. **Requires:** ``gamma0``.
650+
* **Disordered Memory BP** (``bp_method=3``): Min-sum with per-variable memory strengths. **Requires:** ``gamma_dist`` [min, max] OR ``explicit_gammas`` (2D vector).
651+
652+
**Sequential Relay Decoding:**
653+
654+
Starting with version 0.5.0, the decoder supports Sequential Relay BP (configured via ``composition=1``), which combines disordered memory BP
655+
with multiple "relay legs" - sequential runs with different gamma configurations. **Requires:** ``bp_method=3``, ``gamma0``, ``srelay_config``, and either ``gamma_dist`` OR ``explicit_gammas``.
656+
643657
The QLDPC decoder `nv-qldpc-decoder` requires a CUDA-Q compatible GPU. See the list below for dependencies and compatibility:
644658
https://nvidia.github.io/cuda-quantum/latest/using/install/local_installation.html#dependencies-and-compatibility
645659

646660
The decoder is based on the following references:
647661

648662
* https://arxiv.org/pdf/2005.07016
649-
* https://github.com/quantumgizmos/ldpc
663+
* https://github.com/quantumgizmos/ldpc
664+
* https://arxiv.org/pdf/2506.01779
665+
* https://github.com/trmue/relay
650666

651667

652668
Usage:

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

0 commit comments

Comments
 (0)