Skip to content

Commit 3d4f305

Browse files
Docs preview for PR #3771.
1 parent 721ab6d commit 3d4f305

File tree

80 files changed

+3287
-3450
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+3287
-3450
lines changed
-80 Bytes
Loading
-2.52 KB
Loading

pr-3771/_sources/applications/python/adapt_qaoa.ipynb.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@
252252
},
253253
{
254254
"cell_type": "code",
255-
"execution_count": 21,
255+
"execution_count": null,
256256
"metadata": {},
257257
"outputs": [],
258258
"source": [
@@ -264,7 +264,7 @@
264264
" qubits = cudaq.qvector(qubits_num)\n",
265265
" h(qubits)\n",
266266
"\n",
267-
"state = cudaq.get_state(initial_state, qubits_num)\n",
267+
"state = cudaq.StateMemoryView(cudaq.get_state(initial_state, qubits_num))\n",
268268
"\n",
269269
"#print(state)\n",
270270
"###############################################\n",
@@ -309,7 +309,7 @@
309309
},
310310
{
311311
"cell_type": "code",
312-
"execution_count": 22,
312+
"execution_count": null,
313313
"metadata": {},
314314
"outputs": [
315315
{
@@ -483,7 +483,7 @@
483483
" else:\n",
484484
"\n",
485485
" # Compute the state of this current step for the gradient\n",
486-
" state = cudaq.get_state(kernel_qaoa, qubits_num, ham_word, ham_coef,mixer_pool, gamma, beta, num_layer)\n",
486+
" state = cudaq.StateMemoryView(cudaq.get_state(kernel_qaoa, qubits_num, ham_word, ham_coef,mixer_pool, gamma, beta, num_layer))\n",
487487
" #print('State at step ', istep)\n",
488488
" #print(state)\n",
489489
" istep+=1\n",
@@ -537,7 +537,7 @@
537537
],
538538
"metadata": {
539539
"kernelspec": {
540-
"display_name": "Python 3 (ipykernel)",
540+
"display_name": "Python 3",
541541
"language": "python",
542542
"name": "python3"
543543
},
@@ -551,7 +551,7 @@
551551
"name": "python",
552552
"nbconvert_exporter": "python",
553553
"pygments_lexer": "ipython3",
554-
"version": "3.10.12"
554+
"version": "3.12.3"
555555
}
556556
},
557557
"nbformat": 4,

pr-3771/_sources/applications/python/adapt_vqe.ipynb.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
},
263263
{
264264
"cell_type": "code",
265-
"execution_count": 14,
265+
"execution_count": null,
266266
"metadata": {},
267267
"outputs": [
268268
{
@@ -285,7 +285,7 @@
285285
" for i in range(nelectrons):\n",
286286
" x(qubits[i])\n",
287287
"\n",
288-
"state = cudaq.get_state(initial_state, n_qubits, nelectrons)\n",
288+
"state = cudaq.StateMemoryView(cudaq.get_state(initial_state, n_qubits, nelectrons))\n",
289289
"print(state)"
290290
]
291291
},
@@ -345,7 +345,7 @@
345345
},
346346
{
347347
"cell_type": "code",
348-
"execution_count": 16,
348+
"execution_count": null,
349349
"metadata": {},
350350
"outputs": [
351351
{
@@ -557,8 +557,8 @@
557557
" E_prev=result_vqe.fun\n",
558558
" \n",
559559
" # Prepare a trial state with the current ansatz.\n",
560-
" state=cudaq.get_state(kernel, theta, n_qubits, nelectrons, pool_single, \n",
561-
" coef_single, pool_double, coef_double)\n",
560+
" state=cudaq.StateMemoryView(cudaq.get_state(kernel, theta, n_qubits, nelectrons, pool_single, \n",
561+
" coef_single, pool_double, coef_double))\n",
562562
" \n",
563563
"# When using mpi\n",
564564
"#cudaq.mpi.finalize()"
@@ -574,9 +574,13 @@
574574
],
575575
"metadata": {
576576
"kernelspec": {
577-
"display_name": "Python 3 (ipykernel)",
577+
"display_name": "Python 3",
578578
"language": "python",
579579
"name": "python3"
580+
},
581+
"language_info": {
582+
"name": "python",
583+
"version": "3.12.3"
580584
}
581585
},
582586
"nbformat": 4,

pr-3771/_sources/applications/python/entanglement_acc_hamiltonian_simulation.ipynb.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@
382382
},
383383
{
384384
"cell_type": "code",
385-
"execution_count": 10,
385+
"execution_count": null,
386386
"id": "7421e3e9-00fb-412a-9b01-4c9b60103e55",
387387
"metadata": {
388388
"id": "7421e3e9-00fb-412a-9b01-4c9b60103e55"
@@ -415,7 +415,7 @@
415415
" \n",
416416
" for step in range(1, r + 1):\n",
417417
" psi_ideal = ideal_next_state(U, psi_ideal)\n",
418-
" t_state = cudaq.get_state(trotter_step_pf1, t_state, dt, c_a, c_b, words_a, words_b)\n",
418+
" t_state = cudaq.StateMemoryView(cudaq.get_state(trotter_step_pf1, t_state, dt, c_a, c_b, words_a, words_b))\n",
419419
" \n",
420420
" psi_t = cp.asarray(t_state, dtype=cp.complex128) \n",
421421
"\n",
@@ -444,7 +444,7 @@
444444
},
445445
{
446446
"cell_type": "code",
447-
"execution_count": 11,
447+
"execution_count": null,
448448
"id": "00b574ce-9cd2-413c-a285-552d04305183",
449449
"metadata": {},
450450
"outputs": [
@@ -464,7 +464,7 @@
464464
"r = 100 # number of PF1 Trotter steps\n",
465465
"\n",
466466
"# initial state \n",
467-
"initial_state = cudaq.get_state(get_initial_state, n)\n",
467+
"initial_state = cudaq.StateMemoryView(cudaq.get_state(get_initial_state, n))\n",
468468
"\n",
469469
"# field strength and coupling strength \n",
470470
"h_x_val, h_y_val, J_val = 0.8090, 0.9045, 1\n",

pr-3771/_sources/applications/python/hadamard_test.ipynb.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@
9292
},
9393
{
9494
"cell_type": "code",
95-
"execution_count": 2,
95+
"execution_count": null,
9696
"metadata": {},
9797
"outputs": [
9898
{
@@ -107,10 +107,10 @@
107107
}
108108
],
109109
"source": [
110-
"psi_state = cudaq.get_state(psi, qubit_num)\n",
110+
"psi_state = cudaq.StateMemoryView(cudaq.get_state(psi, qubit_num))\n",
111111
"print('Psi state: ', psi_state)\n",
112112
"\n",
113-
"phi_state = cudaq.get_state(phi, qubit_num)\n",
113+
"phi_state = cudaq.StateMemoryView(cudaq.get_state(phi, qubit_num))\n",
114114
"print('Phi state: ', phi_state)"
115115
]
116116
},

pr-3771/_sources/applications/python/hamiltonian_simulation.ipynb.txt

Lines changed: 28 additions & 18 deletions
Large diffs are not rendered by default.

pr-3771/_sources/applications/python/mps_encoding.ipynb.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@
403403
},
404404
{
405405
"cell_type": "code",
406-
"execution_count": 13,
406+
"execution_count": null,
407407
"id": "d753b977",
408408
"metadata": {},
409409
"outputs": [
@@ -424,13 +424,13 @@
424424
"\n",
425425
"# Sanity check\n",
426426
"print(np.dot(\n",
427-
" np.array(cudaq.get_state(qc)).conj().T, statevector\n",
427+
" np.array(cudaq.StateMemoryView(cudaq.get_state(qc))).conj().T, statevector\n",
428428
"))"
429429
]
430430
},
431431
{
432432
"cell_type": "code",
433-
"execution_count": 14,
433+
"execution_count": null,
434434
"id": "3a4e4472",
435435
"metadata": {},
436436
"outputs": [
@@ -451,7 +451,7 @@
451451
"\n",
452452
"# Sanity check\n",
453453
"print(np.dot(\n",
454-
" np.array(cudaq.get_state(qc)).conj().T, statevector\n",
454+
" np.array(cudaq.StateMemoryView(cudaq.get_state(qc))).conj().T, statevector\n",
455455
"))"
456456
]
457457
}

pr-3771/_sources/applications/python/quantum_fourier_transform.ipynb.txt

Lines changed: 11 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
},
145145
{
146146
"cell_type": "code",
147-
"execution_count": 1,
147+
"execution_count": null,
148148
"metadata": {},
149149
"outputs": [],
150150
"source": [
@@ -178,26 +178,9 @@
178178
},
179179
{
180180
"cell_type": "code",
181-
"execution_count": 2,
181+
"execution_count": null,
182182
"metadata": {},
183-
"outputs": [
184-
{
185-
"name": "stdout",
186-
"output_type": "stream",
187-
"text": [
188-
" ╭───╮╭───╮╭───────────╮╭────────────╮ \n",
189-
"q0 : ┤ x ├┤ h ├┤ r1(1.571) ├┤ r1(0.7854) ├───────────────────────\n",
190-
" ╰───╯╰───╯╰─────┬─────╯╰─────┬──────╯╭───╮╭───────────╮ \n",
191-
"q1 : ────────────────●────────────┼───────┤ h ├┤ r1(1.571) ├─────\n",
192-
" ╭───╮ │ ╰───╯╰─────┬─────╯╭───╮\n",
193-
"q2 : ┤ x ├────────────────────────●──────────────────●──────┤ h ├\n",
194-
" ╰───╯ ╰───╯\n",
195-
"\n",
196-
"[ 0.35+0.j -0.25-0.25j 0. +0.35j 0.25-0.25j -0.35+0.j 0.25+0.25j\n",
197-
" -0. -0.35j -0.25+0.25j]\n"
198-
]
199-
}
200-
],
183+
"outputs": [],
201184
"source": [
202185
"#Can be changed to 'nvidia' for single gpu, 'nvidia-mgpu' for multi-GPU or quantum hardware.\n",
203186
"cudaq.set_target(\"qpp-cpu\")\n",
@@ -212,7 +195,7 @@
212195
"print(cudaq.draw(quantum_fourier_transform, input_state))\n",
213196
"\n",
214197
"# Print the statevector to the specified precision\n",
215-
"statevector = np.array(cudaq.get_state(quantum_fourier_transform, input_state))\n",
198+
"statevector = np.array(cudaq.StateMemoryView(cudaq.get_state(quantum_fourier_transform, input_state)))\n",
216199
"print(np.round(statevector, precision))"
217200
]
218201
},
@@ -268,7 +251,7 @@
268251
},
269252
{
270253
"cell_type": "code",
271-
"execution_count": 2,
254+
"execution_count": null,
272255
"metadata": {},
273256
"outputs": [],
274257
"source": [
@@ -302,35 +285,9 @@
302285
},
303286
{
304287
"cell_type": "code",
305-
"execution_count": 3,
288+
"execution_count": null,
306289
"metadata": {},
307-
"outputs": [
308-
{
309-
"name": "stdout",
310-
"output_type": "stream",
311-
"text": [
312-
" ╭───╮╭───╮╭─────────╮╭──────────╮ »\n",
313-
"q0 : ┤ x ├┤ h ├┤ r1(1.5) ├┤ r1(0.75) ├──────────────────────────────────────»\n",
314-
" ╰───╯╰───╯╰────┬────╯╰────┬─────╯╭───╮╭─────────╮ ╭──────────╮»\n",
315-
"q1 : ───────────────●──────────┼──────┤ h ├┤ r1(1.5) ├──────────┤ r1(-1.5) ├»\n",
316-
" ╭───╮ │ ╰───╯╰────┬────╯╭───╮╭───╮╰────┬─────╯»\n",
317-
"q2 : ┤ x ├─────────────────────●────────────────●─────┤ h ├┤ h ├─────●──────»\n",
318-
" ╰───╯ ╰───╯╰───╯ »\n",
319-
"\n",
320-
"################################################################################\n",
321-
"\n",
322-
" ╭───────────╮╭──────────╮╭───╮\n",
323-
"─────┤ r1(-0.75) ├┤ r1(-1.5) ├┤ h ├\n",
324-
"╭───╮╰─────┬─────╯╰────┬─────╯╰───╯\n",
325-
"┤ h ├──────┼───────────●───────────\n",
326-
"╰───╯ │ \n",
327-
"───────────●───────────────────────\n",
328-
" \n",
329-
"\n",
330-
"[0.+0.j 0.+0.j 0.+0.j 0.+0.j 0.+0.j 1.-0.j 0.-0.j 0.+0.j]\n"
331-
]
332-
}
333-
],
290+
"outputs": [],
334291
"source": [
335292
"@cudaq.kernel\n",
336293
"def verification_example(input_state: List[int]):\n",
@@ -361,23 +318,15 @@
361318
"print(cudaq.draw(verification_example, input_state))\n",
362319
"\n",
363320
"# Print the statevector to the specified precision\n",
364-
"statevector = np.array(cudaq.get_state(verification_example, input_state))\n",
321+
"statevector = np.array(cudaq.StateMemoryView(cudaq.get_state(verification_example, input_state)))\n",
365322
"print(np.round(statevector, precision)) # The result should be the input state"
366323
]
367324
},
368325
{
369326
"cell_type": "code",
370-
"execution_count": 3,
327+
"execution_count": null,
371328
"metadata": {},
372-
"outputs": [
373-
{
374-
"name": "stdout",
375-
"output_type": "stream",
376-
"text": [
377-
"CUDA-Q Version latest (https://github.com/NVIDIA/cuda-quantum a726804916fd397408cbf595ce6fe5f33dcd8b4c)\n"
378-
]
379-
}
380-
],
329+
"outputs": [],
381330
"source": [
382331
"print(cudaq.__version__)"
383332
]
@@ -399,7 +348,7 @@
399348
"name": "python",
400349
"nbconvert_exporter": "python",
401350
"pygments_lexer": "ipython3",
402-
"version": "3.10.12"
351+
"version": "3.12.3"
403352
},
404353
"orig_nbformat": 4,
405354
"vscode": {

0 commit comments

Comments
 (0)