Skip to content

Commit 13848f7

Browse files
authored
Merge branch 'main' into shrink_nvqpp_python
2 parents 4c60654 + 95134fd commit 13848f7

File tree

18 files changed

+217
-74
lines changed

18 files changed

+217
-74
lines changed

.github/workflows/docker_images.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ jobs:
694694
fi
695695
696696
image_tag=`docker inspect $cudaq_image --format='{{json .Config.Labels}}' | jq -r '."org.opencontainers.image.version"'`
697-
docs_version="CUDA_QUANTUM_VERSION=${image_tag%-base}"
697+
docs_version="CUDA_QUANTUM_VERSION=$(echo $image_tag | sed -re 's/^(cu[0-9]+-)?(.*)-base$/\2/')"
698698
docker image rm $cudaq_image
699699
docker image prune --force
700700

.github/workflows/integration_tests.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ on:
1717
options:
1818
- nightly
1919
- anyon
20+
- infleqtion
2021
- ionq
2122
- iqm
2223
- oqc
@@ -650,6 +651,51 @@ jobs:
650651
fi
651652
shell: bash
652653

654+
- name: Submit to Infleqtion test server
655+
if: (success() || failure()) && (inputs.target == 'infleqtion' || github.event_name == 'schedule' || inputs.target == 'nightly')
656+
run: |
657+
echo "### Submit to Infleqtion server" >> $GITHUB_STEP_SUMMARY
658+
export SUPERSTAQ_API_KEY='${{ secrets.SUPERSTAQ_API_KEY }}'
659+
set +e # Allow script to keep going through errors
660+
test_err_sum=0
661+
cpp_tests="docs/sphinx/targets/cpp/infleqtion.cpp"
662+
for filename in $cpp_tests; do
663+
[ -e "$filename" ] || echo "::error::Couldn't find file ($filename)"
664+
nvq++ --target infleqtion $filename
665+
test_status=$?
666+
if [ $test_status -eq 0 ]; then
667+
./a.out
668+
test_status=$?
669+
if [ $test_status -eq 0 ]; then
670+
echo ":white_check_mark: Successfully ran test: $filename" >> $GITHUB_STEP_SUMMARY
671+
else
672+
echo ":x: Test failed (failed to execute): $filename" >> $GITHUB_STEP_SUMMARY
673+
test_err_sum=$((test_err_sum+1))
674+
fi
675+
else
676+
echo ":x: Test failed (failed to compile): $filename" >> $GITHUB_STEP_SUMMARY
677+
test_err_sum=$((test_err_sum+1))
678+
fi
679+
done
680+
python_tests="docs/sphinx/targets/python/infleqtion.py"
681+
for filename in $python_tests; do
682+
[ -e "$filename" ] || echo "::error::Couldn't find file ($filename)"
683+
python3 $filename 1> /dev/null
684+
test_status=$?
685+
if [ $test_status -eq 0 ]; then
686+
echo ":white_check_mark: Successfully ran test: $filename" >> $GITHUB_STEP_SUMMARY
687+
else
688+
echo ":x: Test failed (failed to execute): $filename" >> $GITHUB_STEP_SUMMARY
689+
test_err_sum=$((test_err_sum+1))
690+
fi
691+
done
692+
set -e # Re-enable exit code error checking
693+
if [ ! $test_err_sum -eq 0 ]; then
694+
echo "::error::${test_err_sum} tests failed. See step summary for a list of failures"
695+
exit 1
696+
fi
697+
shell: bash
698+
653699
- name: Submit to ${{ inputs.target }}
654700
# The full set of tests used by this step is currently only supported on
655701
# Quantinuum. The other supported tests are tested by the step above.

docs/sphinx/api/languages/cpp_api.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ Common
3535
.. doxygenclass:: cudaq::observe_result
3636
:members:
3737

38+
.. doxygenstruct:: cudaq::observe_options
39+
:members:
40+
41+
.. doxygenfunction:: cudaq::observe(const observe_options &options, QuantumKernel &&kernel, spin_op H, Args &&...args)
42+
.. doxygenfunction:: cudaq::observe(std::size_t shots, QuantumKernel &&kernel, spin_op H, Args &&...args)
43+
.. doxygenfunction:: cudaq::observe(QuantumKernel &&kernel, spin_op H, Args &&...args)
44+
.. doxygenfunction:: cudaq::observe(QuantumKernel &&kernel, const SpinOpContainer &termList, Args &&...args)
45+
3846
.. doxygenclass:: cudaq::ExecutionContext
3947
:members:
4048

@@ -53,6 +61,13 @@ Common
5361
.. doxygenclass:: cudaq::sample_result
5462
:members:
5563

64+
.. doxygenstruct:: cudaq::sample_options
65+
:members:
66+
67+
.. doxygenfunction:: cudaq::sample(const sample_options &options, QuantumKernel &&kernel, Args &&...args)
68+
.. doxygenfunction:: cudaq::sample(std::size_t shots, QuantumKernel &&kernel, Args &&...args)
69+
.. doxygenfunction:: cudaq::sample(QuantumKernel &&kernel, Args&&... args)
70+
5671
.. doxygenclass:: cudaq::SimulationState
5772

5873
.. doxygenstruct:: cudaq::SimulationState::Tensor
@@ -89,6 +104,8 @@ Common
89104

90105
.. doxygenfunction:: cudaq::draw(QuantumKernel &&kernel, Args&&... args)
91106

107+
.. doxygenfunction:: cudaq::get_state(QuantumKernel &&kernel, Args&&... args)
108+
92109
.. doxygenclass:: cudaq::Resources
93110

94111
.. doxygentypedef:: cudaq::complex_matrix::value_type

docs/sphinx/applications/python/digitized_counterdiabatic_qaoa.ipynb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"\n",
99
"Drugs often work by binding to an active site of a protein, inhibiting or activating its function for some therapeutic purpose. Finding new candidate drugs is extremely difficult. The study of molecular docking helps guide this search and involves the prediction of how strongly a certain ligand (drug) will bind to its target (usually a protein). \n",
1010
"\n",
11-
"One of the primary challenges to molecular docking arises from the many geometric degrees of freedom present in proteins and ligands, making it difficult to predict the optimal orientation and assess if the drug is a good candidate or not. One solution is to formulate the problem as a mathematical optimization problem where the optimal solution corresponds to the most likely ligand-protein configuration. This optimization problem can be solved on a quantum computer using methods like the Quantum Approximate Optimization Algorithm (QAOA). This tutorial demonstrates how this [paper](https://arxiv.org/pdf/2308.04098) used digitized-counteradiabatic (DC) QAOA to study molecular docking. This tutorial assumes you have an understanding of QAOA, if not, please see the CUDA-Q MaxCut tutorial found [here](https://nvidia.github.io/cuda-quantum/latest/examples/python/tutorials/qaoa.html)\n",
11+
"One of the primary challenges to molecular docking arises from the many geometric degrees of freedom present in proteins and ligands, making it difficult to predict the optimal orientation and assess if the drug is a good candidate or not. One solution is to formulate the problem as a mathematical optimization problem where the optimal solution corresponds to the most likely ligand-protein configuration. This optimization problem can be solved on a quantum computer using methods like the Quantum Approximate Optimization Algorithm (QAOA). This tutorial demonstrates how this [paper](https://arxiv.org/pdf/2308.04098) used digitized-counteradiabatic (DC) QAOA to study molecular docking. This tutorial assumes you have an understanding of QAOA, if not, please see the CUDA-Q MaxCut tutorial found [here](https://nvidia.github.io/cuda-quantum/latest/applications/python/qaoa.html).\n",
1212
"\n",
1313
"The next section provides more detail on the problem setup followed by CUDA-Q implementations below."
1414
]
@@ -25,10 +25,10 @@
2525
"\n",
2626
"\n",
2727
"There are 6 key steps:\n",
28-
"1. The experimental protein and ligand structures are determined and used to select pharmacores, or an important chemical group that will govern the chemical interactions,\n",
29-
"2. T wo labeled distance graphs (LAGs) of size $N$ and $M$ represent the protein and the ligand, respectively. Each node corresponds to a pharmacore and each edge weight corresponds to the distance between pharmacores.\n",
28+
"1. The experimental protein and ligand structures are determined and used to select pharmacores, or an important chemical group that will govern the chemical interactions.\n",
29+
"2. Two labeled distance graphs (LAGs) of size $N$ and $M$ represent the protein and the ligand, respectively. Each node corresponds to a pharmacore and each edge weight corresponds to the distance between pharmacores.\n",
3030
"3. A $M*N$ node binding interaction graph (BIG) is created from the LAGs. Each node in the BIG graph corresponds to a pair of pharmacores, one from the ligand and the other from the protein. The existence of edges between nodes in the BIG graph are determined from the LAGs and correspond to interactions that can feesibly coexist. Therefore, cliques in the graph correspond to mutually possible interactions. \n",
31-
"4. The problem is mapped to a QAOA circuit and corresponding Hamiltonian, and the ground state solution is determined.\n",
31+
"4. The problem is mapped to a QAOA circuit and corresponding Hamiltonian. From there, the ground state solution is determined.\n",
3232
"5. The ground state will produce the maximum weighted clique which corresponds to the best (most strongly bound) orientation of the ligand and protein.\n",
3333
"6. The predicted docking structure is interpreted from the QAOA result and is used for further analysis.\n"
3434
]
@@ -50,16 +50,14 @@
5050
"source": [
5151
"import cudaq\n",
5252
"from cudaq import spin\n",
53-
"import numpy as np\n",
54-
"\n",
55-
"# cudaq.set_target('nvidia')"
53+
"import numpy as np\n"
5654
]
5755
},
5856
{
5957
"cell_type": "markdown",
6058
"metadata": {},
6159
"source": [
62-
"The block below defines two of the BIG data sets from the paper. The first is a smaller example, but it can be swapped with the commented out example below at your discretion. The weights are specified for each node based on the nature of the ligand and protein pharmacores represented by the node"
60+
"The block below defines two of the BIG data sets from the paper. The first is a smaller example, but it can be swapped with the commented out example below at your discretion. The weights are specified for each node based on the nature of the ligand and protein pharmacores represented by the node."
6361
]
6462
},
6563
{
@@ -77,7 +75,7 @@
7775
}
7876
],
7977
"source": [
80-
"# The two graphs input from the paper\n",
78+
"# The two graph inputs from the paper\n",
8179
"\n",
8280
"# BIG 1\n",
8381
"\n",
@@ -113,12 +111,12 @@
113111
"cell_type": "markdown",
114112
"metadata": {},
115113
"source": [
116-
"Next, the Hamiltonian is constructed. \n",
114+
"Next, the Hamiltonian is constructed: \n",
117115
"\n",
118116
"$$H = \\frac{1}{2}\\sum_{i \\in V}w_i(\\sigma^z_i - 1) + \\frac{P}{4} \\sum_{(i,j) \\notin E, i \\neq j} (\\sigma^z_i -1)(\\sigma^z_j - 1) $$\n",
119117
"\n",
120118
"\n",
121-
"The first term concerns the vertices and the weights of the given pharmacores. The second term is a penalty term that penalizes edges of the graph with no interactions. The penalty $P$ is set by the user and is defined as 6 in the cell above. The function below returns the Hamiltonina as a CUDA-Q `spin_op` object.\n",
119+
"The first term concerns the vertices and the weights of the given pharmacores. The second term is a penalty term that penalizes edges of the graph with no interactions. The penalty $P$ is set by the user and is defined as 6 in the cell above. The function below returns the Hamiltonian as a CUDA-Q `spin_op` object.\n",
122120
"\n"
123121
]
124122
},
@@ -208,7 +206,7 @@
208206
"cell_type": "markdown",
209207
"metadata": {},
210208
"source": [
211-
"The kernel below defines a DC-QAOA circuit. What makes the approach \"DC\" is the inclusion of additional counteradiabatic terms to better drive the optimization to the ground state. These terms are digitized and applied as additional operations following each QAOA layer. The increase in parameters is hopefully offset by requiring fewer layers. In this example, the DC terms are additional parameterized $Y$ operations applied to each qubit. These can be commented out to run conventional QAOA."
209+
"The kernel below defines a DC-QAOA circuit. What makes the approach \"DC\" is the inclusion of additional counteradiabatic terms to better drive the optimization to the ground state. These terms are digitized and applied as additional operations following each QAOA layer. The increase in parameters is hopefully offset by requiring fewer layers. In this example, the DC terms are the additional parameterized $Y$ operations applied to each qubit. These can be commented out to run conventional QAOA."
212210
]
213211
},
214212
{
@@ -246,7 +244,7 @@
246244
"cell_type": "markdown",
247245
"metadata": {},
248246
"source": [
249-
"The classical optimizer for the QAOA procedure can be specified as one of the build in CUDA-Q optimizers, in this case Nelder Mead. The parameter count is defined for DC-QAOA, but can be swapped with the commented line below for conventional QAOA."
247+
"The classical optimizer for the QAOA procedure can be specified as one of the built-in CUDA-Q optimizers, in this case Nelder Mead. The parameter count is defined for DC-QAOA, but can be swapped with the commented line below for conventional QAOA."
250248
]
251249
},
252250
{

docs/sphinx/applications/python/divisive_clustering_src/main_divisive_clustering.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
type=str,
2828
choices=["qpp-cpu", "nvidia", "nvidia-mgpu"],
2929
help=
30-
"Quantum simulator backend. Default is qpp-cpu. See https://nvidia.github.io/cuda-quantum/0.6.0/using/simulators.html for more options.",
30+
"Quantum simulator backend. Default is qpp-cpu. See https://nvidia.github.io/cuda-quantum for more options.",
3131
)
3232
argparser.add_argument(
3333
"-d",

0 commit comments

Comments
 (0)