You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+14Lines changed: 14 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,20 @@ If you're unfamiliar with Jupyter but you're used to a traditional IDE or code e
70
70
71
71
---
72
72
73
+
## Git Hooks
74
+
75
+
This repository includes a _`pre-commit` Git hook_ to automatically clean Jupyter notebook metadata using `nb-clean` before committing. This helps reduce unnecessary noise in commits and avoid merge conflicts.
76
+
77
+
To enable this, run the following command in your terminal from the root of this repository:
78
+
79
+
```shell
80
+
git config core.hooksPath .githooks
81
+
```
82
+
83
+
**Note:** If `uv` is not installed, the hook will issue a warning and skip the cleaning process.
84
+
85
+
---
86
+
73
87
## Support
74
88
75
89
For support, you can submit issues or PRs in this repository. Alternatively, you can contact us at [support@ionq.com](mailto:support@ionq.com?subject=SDK%20help).
Copy file name to clipboardExpand all lines: cirq.ipynb
+35-38Lines changed: 35 additions & 38 deletions
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@
13
13
},
14
14
{
15
15
"cell_type": "code",
16
-
"execution_count": 1,
16
+
"execution_count": null,
17
17
"metadata": {},
18
18
"outputs": [],
19
19
"source": [
@@ -31,11 +31,26 @@
31
31
"execution_count": null,
32
32
"metadata": {},
33
33
"outputs": [],
34
-
"source": "import cirq\nimport cirq_ionq\nimport matplotlib.pyplot as plt\n\nfrom helpers import get_ionq_api_key\n\n# Before you begin, get your API key from https://cloud.ionq.com/settings/keys\n\n# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n# should find it. Otherwise you'll be prompted to enter your API key manually.\n\napi_key = get_ionq_api_key()\n\nservice = cirq_ionq.Service(api_key=api_key, default_target='simulator')"
34
+
"source": [
35
+
"import cirq\n",
36
+
"import cirq_ionq\n",
37
+
"import matplotlib.pyplot as plt\n",
38
+
"\n",
39
+
"from helpers import get_ionq_api_key\n",
40
+
"\n",
41
+
"# Before you begin, get your API key from https://cloud.ionq.com/settings/keys\n",
42
+
"\n",
43
+
"# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n",
44
+
"# should find it. Otherwise you'll be prompted to enter your API key manually.\n",
"# Before submitting the job, we can visualize the circuit using print().\n",
70
75
"\n",
@@ -76,33 +81,25 @@
76
81
"execution_count": null,
77
82
"metadata": {},
78
83
"outputs": [],
79
-
"source": "# Now we'll send the job to our backend for processing and plot the results.\n\nresult = service.run(circuit, name=\"Cirq example\", repetitions=100)\n_ = cirq.plot_state_histogram(result, plt.subplot())\nplt.show()"
84
+
"source": [
85
+
"# Now we'll send the job to our backend for processing and plot the results.\n",
Copy file name to clipboardExpand all lines: cuda-quantum/main.ipynb
+46-27Lines changed: 46 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -17,49 +17,68 @@
17
17
},
18
18
{
19
19
"cell_type": "markdown",
20
-
"source": "# CUDA-Q\n\n[](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/cuda-quantum/main.ipynb)\n\n[CUDA-Q](https://nvidia.github.io/cuda-quantum/latest/) is NVIDIA's platform for hybrid quantum-classical computing. It provides a unified programming model for quantum algorithm development and seamlessly integrates with classical computing workflows.",
21
-
"metadata": {}
20
+
"metadata": {},
21
+
"source": [
22
+
"# CUDA-Q\n",
23
+
"\n",
24
+
"[](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/cuda-quantum/main.ipynb)\n",
25
+
"\n",
26
+
"[CUDA-Q](https://nvidia.github.io/cuda-quantum/latest/) is NVIDIA's platform for hybrid quantum-classical computing. It provides a unified programming model for quantum algorithm development and seamlessly integrates with classical computing workflows."
"os.environ[\"IONQ_API_KEY\"] = api_key # Remove when set_target takes api_key\n",
43
+
"cudaq.set_target(\"ionq\", qpu=\"simulator\")"
44
+
]
29
45
},
30
46
{
31
47
"cell_type": "code",
32
48
"execution_count": null,
33
49
"metadata": {},
34
50
"outputs": [],
35
-
"source": "# Now we set up our circuit. In this case, we're creating a Bell state with two\n# qubits, applying an H gate to qubit-0, a controlled-X gate to both qubits.\n\nSHOTS = 100\n\n\n@cudaq.kernel\ndef bell_state():\n qubits = cudaq.qvector(2)\n h(qubits[0])\n x.ctrl(qubits[0], qubits[1])\n\n\n# Execute the kernel on IonQ's simulator and display the results.\n\nresult = cudaq.sample(bell_state, shots_count=SHOTS)\nprint(result)"
51
+
"source": [
52
+
"# Now we set up our circuit. In this case, we're creating a Bell state with two\n",
53
+
"# qubits, applying an H gate to qubit-0, a controlled-X gate to both qubits.\n",
54
+
"\n",
55
+
"SHOTS = 100\n",
56
+
"\n",
57
+
"\n",
58
+
"@cudaq.kernel\n",
59
+
"def bell_state():\n",
60
+
" qubits = cudaq.qvector(2)\n",
61
+
" h(qubits[0])\n",
62
+
" x.ctrl(qubits[0], qubits[1])\n",
63
+
"\n",
64
+
"\n",
65
+
"# Execute the kernel on IonQ's simulator and display the results.\n",
"source": "## And that's a wrap!\n\nTo explore more about CUDA-Q and quantum computing with NVIDIA, check out the official documentation at https://nvidia.github.io/cuda-quantum/",
40
-
"metadata": {}
73
+
"metadata": {},
74
+
"source": [
75
+
"## And that's a wrap!\n",
76
+
"\n",
77
+
"To explore more about CUDA-Q and quantum computing with NVIDIA, check out the official documentation at https://nvidia.github.io/cuda-quantum/"
Copy file name to clipboardExpand all lines: pennylane.ipynb
+69-27Lines changed: 69 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -13,7 +13,7 @@
13
13
},
14
14
{
15
15
"cell_type": "code",
16
-
"execution_count": 1,
16
+
"execution_count": null,
17
17
"metadata": {},
18
18
"outputs": [],
19
19
"source": [
@@ -31,54 +31,96 @@
31
31
"execution_count": null,
32
32
"metadata": {},
33
33
"outputs": [],
34
-
"source": "from functools import partial\n\nimport matplotlib.pyplot as plt\nimport pennylane as qml\n\nfrom helpers import get_ionq_api_key\n\n# Before you begin, get your API key from https://cloud.ionq.com/settings/keys\n\n# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n# should find it. Otherwise you'll be prompted to enter your API key manually.\n\napi_key = get_ionq_api_key()\n\n# We need to specify the device where the circuit will be executed. In\n# this case we're using the `ionq.simulator`, but if you have QPU access you\n# can specify it here to run the job on a QPU directly.\n\ndev = qml.device(\n 'ionq.simulator',\n api_key=api_key,\n wires=2,\n)"
34
+
"source": [
35
+
"from functools import partial\n",
36
+
"\n",
37
+
"import matplotlib.pyplot as plt\n",
38
+
"import pennylane as qml\n",
39
+
"\n",
40
+
"from helpers import get_ionq_api_key\n",
41
+
"\n",
42
+
"# Before you begin, get your API key from https://cloud.ionq.com/settings/keys\n",
43
+
"\n",
44
+
"# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n",
45
+
"# should find it. Otherwise you'll be prompted to enter your API key manually.\n",
46
+
"\n",
47
+
"api_key = get_ionq_api_key()\n",
48
+
"\n",
49
+
"# We need to specify the device where the circuit will be executed. In\n",
50
+
"# this case we're using the `ionq.simulator`, but if you have QPU access you\n",
51
+
"# can specify it here to run the job on a QPU directly.\n",
52
+
"\n",
53
+
"dev = qml.device(\n",
54
+
" 'ionq.simulator',\n",
55
+
" api_key=api_key,\n",
56
+
" wires=2,\n",
57
+
")"
58
+
]
35
59
},
36
60
{
37
61
"cell_type": "code",
38
62
"execution_count": null,
39
63
"metadata": {},
40
64
"outputs": [],
41
-
"source": "# Now we set up our circuit. In this case, we're creating a circuit with two\n# qubits, applying an H gate to qubit-0, a CNOT gate to both qubits.\n\n@partial(qml.set_shots, shots=100)\n@qml.qnode(dev)\ndef circuit():\n qml.Hadamard(wires=0)\n qml.CNOT(wires=[0, 1])\n return qml.counts()"
65
+
"source": [
66
+
"# Now we set up our circuit. In this case, we're creating a circuit with two\n",
67
+
"# qubits, applying an H gate to qubit-0, a CNOT gate to both qubits.\n",
68
+
"\n",
69
+
"@partial(qml.set_shots, shots=100)\n",
70
+
"@qml.qnode(dev)\n",
71
+
"def circuit():\n",
72
+
" qml.Hadamard(wires=0)\n",
73
+
" qml.CNOT(wires=[0, 1])\n",
74
+
" return qml.counts()"
75
+
]
42
76
},
43
77
{
44
78
"cell_type": "code",
45
79
"execution_count": null,
46
80
"metadata": {},
47
81
"outputs": [],
48
-
"source": "# Before submitting the job, we can visualize the circuit using draw_mpl().\n\nfig, ax = qml.draw_mpl(circuit, style='sketch')()"
82
+
"source": [
83
+
"# Before submitting the job, we can visualize the circuit using draw_mpl().\n",
"source": "# Now we'll send the job to our backend for processing and plot the results.\n\ncounts = circuit()\n\n# Robust scalar conversion (works whether values are Python ints, numpy scalars, torch scalars, etc.)\ncounts = {k: int(v) for k, v in counts.items()}\n\n# Optional: If you want missing outcomes shown as 0, define the QNode with counts(all_outcomes=True).\n\nlabels = sorted(counts.keys())\nvalues = [counts[k] for k in labels]\n\nplt.bar(labels, values)\nplt.xlabel(\"bitstring\")\nplt.ylabel(\"counts\")\nplt.title(\"Measurement counts\")\nplt.show()"
93
+
"source": [
94
+
"# Now we'll send the job to our backend for processing and plot the results.\n",
0 commit comments