Skip to content

Commit 6476e8b

Browse files
authored
Merge branch 'main' into main
2 parents 74fae23 + 0876ddb commit 6476e8b

34 files changed

+2055
-2011
lines changed

.github/workflows/config/spelling_allowlist.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,13 @@ POSIX
8484
PSIRT
8585
Pauli
8686
Paulis
87+
Photonic
8788
Photonics
8889
PyPI
8990
Pygments
9091
QAOA
9192
QCaaS
93+
QEC
9294
QIR
9395
QIS
9496
QPP
@@ -109,6 +111,7 @@ SLED
109111
SLES
110112
SLURM
111113
SVD
114+
Sqale
112115
Stim
113116
Superpositions
114117
Superstaq
@@ -260,6 +263,7 @@ parallelizing
260263
parameterization
261264
performant
262265
photonic
266+
photonics
263267
precompute
264268
precomputed
265269
prepend

docs/sphinx/applications/python/vqe_advanced.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@
480480
"cell_type": "markdown",
481481
"metadata": {},
482482
"source": [
483-
"Now, run the code again (the three previous cells) and specify `num_qpus` to be more than one if you have access to multiple GPUs and notice resulting speedup. Thanks to CUDA-Q, this code could be used without modification in a setting where multiple physical QPUs were availible."
483+
"Now, run the code again (the three previous cells) and specify `num_qpus` to be more than one if you have access to multiple GPUs and notice resulting speedup. Thanks to CUDA-Q, this code could be used without modification in a setting where multiple physical QPUs were available."
484484
]
485485
},
486486
{

docs/sphinx/examples/python/executing_photonic_kernels.ipynb

Lines changed: 0 additions & 171 deletions
This file was deleted.

docs/sphinx/examples/python/measuring_kernels.ipynb

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,32 +69,59 @@
6969
"id": "fb5dd767-5db7-4847-b04e-ae5695066800",
7070
"metadata": {},
7171
"source": [
72-
"### Midcircuit Measurement and Conditional Logic\n",
72+
"### Mid-circuit Measurement and Conditional Logic\n",
7373
"\n",
74-
"In certain cases, it it is helpful for some operations in a quantum kernel to depend on measurement results following previous operations. This is accomplished in the following example by performing a Hadamard on qubit 0, then measuring qubit 0 and savig the result as `b0`. Then, an if statement performs a Hadamard on qubit 1 only if `b0` is 1. Measuring this qubit 1 verifies this process as a 1 is the result 25% of the time."
74+
"In certain cases, it it is helpful for some operations in a quantum kernel to depend on measurement results following previous operations. This is accomplished in the following example by performing a Hadamard on qubit 0, then measuring qubit 0 and saving the result as `b0`. Then, qubit 0 can be reset and used later in the computation. In this case it is flipped ot a 1. Finally, an if statement performs a Hadamard on qubit 1 if `b0` is 1. \n",
75+
"\n",
76+
"The results show qubit 0 is one, indicating the reset worked, and qubit 1 has a 75/25 distribution, demonstrating the mid-circuit measurement worked as expexted."
7577
]
7678
},
7779
{
7880
"cell_type": "code",
79-
"execution_count": 4,
81+
"execution_count": 6,
8082
"id": "44001a51-3733-472c-8bc1-ee694e957708",
8183
"metadata": {},
82-
"outputs": [],
84+
"outputs": [
85+
{
86+
"name": "stdout",
87+
"output_type": "stream",
88+
"text": [
89+
"{ \n",
90+
" __global__ : { 10:728 11:272 }\n",
91+
" b0 : { 0:505 1:495 }\n",
92+
"}\n",
93+
"\n"
94+
]
95+
}
96+
],
8397
"source": [
8498
"@cudaq.kernel\n",
8599
"def kernel():\n",
86100
" q = cudaq.qvector(2)\n",
101+
" \n",
87102
" h(q[0])\n",
88103
" b0 = mz(q[0])\n",
104+
" reset(q[0])\n",
105+
" x(q[0])\n",
106+
" \n",
89107
" if b0:\n",
90-
" h(q[1])\n",
91-
" mz(q[1])"
108+
" h(q[1]) \n",
109+
"\n",
110+
"print(cudaq.sample(kernel))"
92111
]
112+
},
113+
{
114+
"cell_type": "code",
115+
"execution_count": null,
116+
"id": "d525be71-a745-43a5-a7ca-a2720c536f8c",
117+
"metadata": {},
118+
"outputs": [],
119+
"source": []
93120
}
94121
],
95122
"metadata": {
96123
"kernelspec": {
97-
"display_name": "Python 3",
124+
"display_name": "Python 3 (ipykernel)",
98125
"language": "python",
99126
"name": "python3"
100127
},

docs/sphinx/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ You are browsing the documentation for |version| version of CUDA-Q. You can find
3131
Other Versions <versions.rst>
3232

3333
.. |---| unicode:: U+2014 .. EM DASH
34-
:trim:
34+
:trim:

docs/sphinx/releases.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ The full change log can be found `here <https://github.com/NVIDIA/cuda-quantum/r
8787

8888
**0.7.0**
8989

90-
The 0.7.0 release adds support for using :doc:`NVIDIA Quantum Cloud <using/backends/nvqc>`,
90+
The 0.7.0 release adds support for using :doc:`NVIDIA Quantum Cloud <using/backends/cloud/nvqc>`,
9191
giving you access to our most powerful GPU-accelerated simulators even if you don't have an NVIDIA GPU.
9292
With 0.7.0, we have furthermore greatly increased expressiveness of the Python and C++ language frontends.
9393
Check out our `documentation <https://nvidia.github.io/cuda-quantum/0.7.0/using/quick_start.html>`__

docs/sphinx/snippets/python/using/examples/multi_gpu_workflows/circuit_batching.py

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,59 +16,67 @@
1616
exit(0)
1717

1818
np.random.seed(1)
19-
cudaq.set_target("nvidia", option="mqpu")
19+
cudaq.set_target("nvidia")
2020

2121
qubit_count = 5
2222
sample_count = 10000
2323
h = spin.z(0)
2424
parameter_count = qubit_count
2525

26-
# Below we run a circuit for 10000 different input parameters.
26+
# prepare 10000 different input parameter sets.
2727
parameters = np.random.default_rng(13).uniform(low=0,
2828
high=1,
2929
size=(sample_count,
3030
parameter_count))
3131

32-
kernel, params = cudaq.make_kernel(list)
3332

34-
qubits = kernel.qalloc(qubit_count)
35-
qubits_list = list(range(qubit_count))
33+
@cudaq.kernel
34+
def kernel(params: list[float]):
35+
36+
qubits = cudaq.qvector(5)
37+
38+
for i in range(5):
39+
rx(params[i], qubits[i])
40+
3641

37-
for i in range(qubit_count):
38-
kernel.rx(params[i], qubits[i])
3942
# [End prepare]
4043

4144
# [Begin single]
42-
import timeit
45+
import time
46+
47+
start_time = time.time()
48+
cudaq.observe(kernel, h, parameters)
49+
end_time = time.time()
50+
print(end_time - start_time)
4351

44-
timeit.timeit(lambda: cudaq.observe(kernel, h, parameters),
45-
number=1) # Single GPU result.
4652
# [End single]
4753

4854
# [Begin split]
49-
print('We have', parameters.shape[0],
50-
'parameters which we would like to execute')
55+
print('There are', parameters.shape[0], 'parameter sets to execute')
5156

5257
xi = np.split(
5358
parameters,
54-
4) # We split our parameters into 4 arrays since we have 4 GPUs available.
59+
4) # Split the parameters into 4 arrays since 4 GPUs are available.
5560

56-
print('We split this into', len(xi), 'batches of', xi[0].shape[0], ',',
61+
print('Split parameters into', len(xi), 'batches of', xi[0].shape[0], ',',
5762
xi[1].shape[0], ',', xi[2].shape[0], ',', xi[3].shape[0])
5863
# [End split]
5964

6065
# [Begin multiple]
6166
# Timing the execution on a single GPU vs 4 GPUs,
62-
# one will see a 4x performance improvement if 4 GPUs are available.
67+
# one will see a nearly 4x performance improvement if 4 GPUs are available.
6368

69+
cudaq.set_target("nvidia", option="mqpu")
6470
asyncresults = []
6571
num_gpus = cudaq.num_available_gpus()
6672

73+
start_time = time.time()
6774
for i in range(len(xi)):
6875
for j in range(xi[i].shape[0]):
6976
qpu_id = i * num_gpus // len(xi)
7077
asyncresults.append(
7178
cudaq.observe_async(kernel, h, xi[i][j, :], qpu_id=qpu_id))
72-
7379
result = [res.get() for res in asyncresults]
80+
end_time = time.time()
81+
print(end_time - start_time)
7482
# [End multiple]

0 commit comments

Comments
 (0)