Skip to content

Commit de4e4a6

Browse files
committed
Merge remote-tracking branch 'origin/main' into deuley/20260204-automated-cleanup
# Conflicts: # cuda-quantum/main.ipynb
2 parents a556b64 + d75251b commit de4e4a6

File tree

18 files changed

+513
-188
lines changed

18 files changed

+513
-188
lines changed

.github/workflows/test_notebooks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
- name: Set up Python
5151
uses: actions/setup-python@v5
5252
with:
53-
python-version: "3.11"
53+
python-version: "3.13"
5454

5555
- name: Install dependencies with uv
5656
run: |

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
FROM python:3.13-slim
2+
3+
WORKDIR /workspace
4+
5+
# Install build dependencies
6+
RUN apt-get update && apt-get install -y --no-install-recommends \
7+
gcc \
8+
g++ \
9+
&& rm -rf /var/lib/apt/lists/*
10+
11+
# Install uv for fast dependency installation
12+
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv
13+
14+
# Copy project files
15+
COPY . .
16+
17+
# Install dependencies
18+
RUN uv pip install --system -e .
19+
20+
EXPOSE 8888
21+
22+
CMD ["jupyter", "notebook", "--ip=0.0.0.0", "--port=8888", "--no-browser", "--allow-root", "--NotebookApp.token=''"]

README.md

Lines changed: 55 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,86 @@
11
# IonQ Quantum Computing Samples
22

3-
This repository contains Python samples exploring quantum computing on IonQ's platform using various quantum programming libraries. These examples are a great place to start if you're interested in quantum computation, but aren't familiar with any of the libraries out there.
3+
Python samples demonstrating quantum computing on IonQ's platform using popular quantum libraries. A great starting point for exploring quantum computation.
44

5-
If you're looking for advanced and in-depth examples for a given library that implement a specific algorithm, check out some of the other projects in the [ionq-samples](https://github.com/ionq-samples) organization on GitHub.
5+
For advanced examples implementing specific algorithms, check out the [ionq-samples](https://github.com/ionq-samples) organization.
66

77
---
88

9-
## Prerequisites
9+
## Quick Start
1010

11-
There are a wide variety of ways to run these notebooks, but for starters you'll need:
11+
### Prerequisites
1212

13-
1. [Python](https://www.python.org/downloads/) installed, using a version between 3.8 and 3.11.
14-
2. A [virtual environment](https://docs.python.org/3/library/venv.html) to help ensure your dependencies don't conflict with anything else you have installed.
15-
3. An [IonQ API key](https://cloud.ionq.com/settings/keys), which optionally you can store as an environment variable for ease of use. Our notebooks expect to find it stored as `IONQ_API_KEY`.
16-
4. An installation of the library you're wanting to run. You can install all libraries using one of the following methods:
13+
- Python 3.10-3.13
14+
- [IonQ API key](https://cloud.ionq.com/settings/keys) (set as `IONQ_API_KEY` environment variable)
1715

18-
**Option 1: Using uv (Fastest - Recommended)**
16+
### Installation
1917

20-
[uv](https://github.com/astral-sh/uv) is an extremely fast Python package installer and resolver:
18+
**Using pip:**
19+
```bash
20+
pip install -e .
21+
```
2122

22-
```shell
23-
# Install uv (if not already installed)
24-
curl -LsSf https://astral.sh/uv/install.sh | sh
23+
**Using uv (faster):**
24+
```bash
25+
curl -LsSf https://astral.sh/uv/install.sh | sh
26+
uv pip install -e .
27+
```
2528

26-
# Install all dependencies
27-
uv pip install -e .
28-
```
29+
**Using conda:**
30+
```bash
31+
conda env create -f environment.yml
32+
```
2933

30-
**Option 2: Using Conda**
34+
### Running Notebooks
3135

32-
```shell
33-
conda env create -f environment.yml
34-
```
36+
**Jupyter:**
37+
```bash
38+
jupyter notebook
39+
```
3540

36-
**Option 3: Using pip**
41+
**VS Code:**
42+
Open any `.ipynb` file and select a Python kernel.
3743

38-
```shell
39-
pip install -e .
40-
```
44+
**Cloud:**
45+
Click the ![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg) badge in each notebook.
4146

4247
---
4348

44-
## Usage
49+
## Docker
4550

46-
The samples are in the form of Jupyter notebooks, and you can view and run them using a local [Jupyter](http://jupyter.org/) installation, [VS Code](https://code.visualstudio.com/) (using the built-in Jupyter plugin), or [Google Colab](https://colab.research.google.com).
51+
Run in a containerized environment:
4752

48-
If you're unfamiliar with Jupyter but you're used to a traditional IDE or code editor, VS Code is probably the right choice for you.
53+
```bash
54+
# Build
55+
docker build --platform=linux/x86_64 -t ionq-notebooks .
4956

50-
#### Jupyter Notebooks
57+
# Run
58+
docker run -p 8888:8888 -e IONQ_API_KEY="your_api_key" ionq-notebooks
59+
```
5160

52-
1. From your terminal, navigate to this repository and run the following command from within this directory:
61+
Open [http://localhost:8888](http://localhost:8888) in your browser.
5362

54-
```shell
55-
jupyter notebook
56-
```
63+
---
64+
65+
## Development
5766

58-
1. Once the server is started, it should automatically open your browser. In case it doesn't, you can navigate directly to it by pointing your browser at [http://localhost:8888](http://localhost:8888)
59-
1. Navigate to the location of a `.ipynb` file and open it. If you don't have a particular SDK in mind, we recommend starting with `qiskit`, as its the most commonly used library today.
67+
### Running Tests
6068

61-
#### VS Code
69+
```bash
70+
# All tests
71+
pytest tests/
6272

63-
1. Open the folder in VS Code and navigate to a `.ipynb` file and open it.
64-
1. If it's your first time using it, it will suggest a number of plugins that you may need to install before the notebook will be fully functional.
65-
1. At the top-right of the screen, click on `Select Kernel` and choose an appropriate Python runtime to run the notebook in.
73+
# Parallel execution
74+
pytest -n auto tests/
6675

67-
#### Cloud
76+
# Specific notebook
77+
pytest tests/test_notebooks.py::test_notebook_execution[qiskit.ipynb]
78+
79+
# With custom timeout
80+
NBEXEC_TIMEOUT_SECONDS=900 pytest tests/
81+
```
6882

69-
1. Open the notebook by clicking on the ![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg) badge located in each notebook. Or open this repository in [![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ionq-samples/getting-started/HEAD)
83+
GitHub Actions automatically tests all notebooks on every push.
7084

7185
---
7286

@@ -86,4 +100,4 @@ git config core.hooksPath .githooks
86100

87101
## Support
88102

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).
103+
Submit issues or PRs in this repository, or contact [support@ionq.com](mailto:support@ionq.com?subject=SDK%20help).

api.ipynb

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@
1111
"IonQ offers a set of API resources that allow you to submit and manage jobs directly. This notebook offers a few simple examples, but visit [docs.ionq.com](https://docs.ionq.com) for a complete guide with additional resources and functionality."
1212
]
1313
},
14+
{
15+
"cell_type": "code",
16+
"execution_count": null,
17+
"metadata": {},
18+
"outputs": [],
19+
"source": [
20+
"%%capture\n",
21+
"\n",
22+
"# First, we install the essential libraries to our current Python runtime.\n",
23+
"# \"%%capture\" (above) captures and in this case, hides the output of this \n",
24+
"# cell, so you can comment it out if you need help debugging this step.\n",
25+
"\n",
26+
"%pip install requests"
27+
]
28+
},
1429
{
1530
"cell_type": "code",
1631
"execution_count": null,
@@ -29,7 +44,10 @@
2944
"# If your API key is stored as \"IONQ_API_KEY\" in your local environment, this\n",
3045
"# should find it. Otherwise you'll be prompted to enter your API key manually.\n",
3146
"\n",
32-
"api_key = get_ionq_api_key()"
47+
"api_key = get_ionq_api_key()\n",
48+
"\n",
49+
"# Configuration\n",
50+
"SHOTS = 100"
3351
]
3452
},
3553
{
@@ -81,7 +99,7 @@
8199
"\n",
82100
"data = {\n",
83101
" \"name\": \"API Example Circuit\",\n",
84-
" \"shots\": 100,\n",
102+
" \"shots\": SHOTS,\n",
85103
" \"target\": \"simulator\",\n",
86104
" \"input\": {\n",
87105
" \"format\": \"ionq.circuit.v0\",\n",
@@ -163,7 +181,24 @@
163181
]
164182
}
165183
],
166-
"metadata": {},
184+
"metadata": {
185+
"kernelspec": {
186+
"display_name": "getting-started",
187+
"language": "python",
188+
"name": "python3"
189+
},
190+
"language_info": {
191+
"codemirror_mode": {
192+
"name": "ipython",
193+
"version": 3
194+
},
195+
"file_extension": ".py",
196+
"mimetype": "text/x-python",
197+
"name": "python",
198+
"nbconvert_exporter": "python",
199+
"pygments_lexer": "ipython3"
200+
}
201+
},
167202
"nbformat": 4,
168-
"nbformat_minor": 2
203+
"nbformat_minor": 4
169204
}

cirq.ipynb

Lines changed: 38 additions & 6 deletions
Large diffs are not rendered by default.

cuda-quantum/Dockerfile

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

cuda-quantum/README.md

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

cuda-quantum/helpers.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
11
{
22
"cells": [
33
{
4-
"cell_type": "code",
5-
"execution_count": null,
4+
"cell_type": "markdown",
65
"metadata": {},
7-
"outputs": [],
86
"source": [
9-
"%%capture\n",
7+
"# CUDA-Q\n",
108
"\n",
11-
"# First, we install the essential libraries to our current Python runtime.\n",
12-
"# \"%%capture\" (above) captures and in this case, hides the output of this \n",
13-
"# cell, so you can comment it out if you need help debugging this step.\n",
9+
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/cuda-quantum/main.ipynb)\n",
1410
"\n",
15-
"%pip install cudaq"
11+
"[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."
1612
]
1713
},
1814
{
1915
"cell_type": "markdown",
2016
"metadata": {},
2117
"source": [
22-
"# CUDA-Q\n",
18+
"⚠️ **Note:** CUDA is not compatible with Apple computers—given that it relies on Nvidia hardware being available. While the `cudaq` library _will_ install on a Mac, it will fail to run with a `ModuleNotFoundError`. "
19+
]
20+
},
21+
{
22+
"cell_type": "code",
23+
"execution_count": null,
24+
"metadata": {},
25+
"outputs": [],
26+
"source": [
27+
"%%capture\n",
2328
"\n",
24-
"[![Open in Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/ionq-samples/getting-started/blob/main/cuda-quantum/main.ipynb)\n",
29+
"# First, we install the essential libraries to our current Python runtime.\n",
30+
"# \"%%capture\" (above) captures and in this case, hides the output of this \n",
31+
"# cell, so you can comment it out if you need help debugging this step.\n",
2532
"\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."
33+
"%pip install cudaq"
2734
]
2835
},
2936
{
@@ -78,7 +85,25 @@
7885
]
7986
}
8087
],
81-
"metadata": {},
88+
"metadata": {
89+
"kernelspec": {
90+
"display_name": "getting-started",
91+
"language": "python",
92+
"name": "python3"
93+
},
94+
"language_info": {
95+
"codemirror_mode": {
96+
"name": "ipython",
97+
"version": 3
98+
},
99+
"file_extension": ".py",
100+
"mimetype": "text/x-python",
101+
"name": "python",
102+
"nbconvert_exporter": "python",
103+
"pygments_lexer": "ipython3",
104+
"version": "3.13.6"
105+
}
106+
},
82107
"nbformat": 4,
83-
"nbformat_minor": 2
108+
"nbformat_minor": 4
84109
}

environment.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- conda-forge
44
- defaults
55
dependencies:
6-
- python=3.11
6+
- python=3.13
77
- pip
88
- jupyter
99
- pytest

0 commit comments

Comments
 (0)