Skip to content
Draft
3 changes: 1 addition & 2 deletions docs/guides/save-credentials.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ If you are working in a trusted Python environment (such as on a personal laptop

## Before you begin

1. Ensure that you have an [IBM Cloud account.](https://quantum.cloud.ibm.com/registration)
1. Ensure you are working in an active Python environment with the [Qiskit SDK and Qiskit Runtime installed](/docs/guides/install-qiskit#local).
1. Activate the Python virtual environment and run Python in your virtual environment.
1. Log in to [IBM Quantum Platform](https://quantum.cloud.ibm.com) with an IBMid or Google account.
1. Log in to [IBM Quantum Platform](https://quantum.cloud.ibm.com).

<span id="find-credentials"></span>
## Find your access credentials
Expand Down
148 changes: 80 additions & 68 deletions docs/guides/serverless-first-program.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "markdown",
"id": "e17b430a-ec17-4a88-9a71-9ce365059bea",
"id": "cdc8dc1e-0cff-46c1-94d0-97456d278e27",
"metadata": {},
"source": [
"---\n",
Expand All @@ -16,7 +16,7 @@
},
{
"cell_type": "markdown",
"id": "90e824fb-dcf6-4a8b-9808-d66aa9bfb3b5",
"id": "b6d632cb-d884-4963-9c8d-8f3a3acd8a7d",
"metadata": {
"tags": [
"version-info"
Expand Down Expand Up @@ -48,28 +48,16 @@
},
{
"cell_type": "markdown",
"id": "b32bff85-1760-4296-8f5b-ea6e5c942bbe",
"id": "1cc46aeb-aff6-4fab-9d78-69f2bfe98d98",
"metadata": {},
"source": [
"This example demonstrates how to use `qiskit-serverless` tools to create a parallel transpilation program, and then implement `qiskit-ibm-catalog` to deploy your program to IBM Quantum Platform to use as a reusable remote service."
]
},
{
"cell_type": "markdown",
"id": "e3603a5c-78f4-40ec-9568-7a45664acfc7",
"metadata": {},
"source": [
"## Example: remote transpilation with Qiskit Serverless\n",
"\n",
"Start with the following example that transpiles a `circuit` against a given `backend` and target `optimization_level`, and gradually add more elements to deploy your workload to Qiskit Serverless.\n",
"\n",
"Put the following code cell in the file `./source_files/transpile_remote.py`. This file is the program to upload to Qiskit Serverless."
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "21ea3269-1946-40b4-9c0f-9431003c2d0b",
"execution_count": 2,
"id": "b186515d-7686-43c3-94a6-187eba0808b9",
"metadata": {
"editable": true,
"slideshow": {
Expand All @@ -87,10 +75,36 @@
"Path(\"./source_files\").mkdir(exist_ok=True)"
]
},
{
"cell_type": "markdown",
"id": "cad16f43-8548-4849-a4b8-09059a8b747c",
"metadata": {},
"source": [
"## Example: remote transpilation with Qiskit Serverless\n",
"\n",
"Start with the following example that transpiles a `circuit` against a given `backend` and target `optimization_level`, and gradually add more elements to deploy your workload to Qiskit Serverless.\n",
"\n",
"Serverless uploads the contents of a specific directory (in this example, the `source_files` directory) to run remotely. Once these are set up, you can adjust `transpile_remote.py` to fetch inputs and return outputs.\n",
"\n",
"<Admonition type=\"tip\">\n",
"Qiskit Serverless requires setting up your workload’s `.py` files into a dedicated directory. The following structure is an example of good practice:\n",
"\n",
"```text\n",
"serverless_program\n",
"├── program_uploader.ipynb\n",
"└── source_files\n",
" ├── transpile_remote.py\n",
" └── *.py\n",
"```\n",
"</Admonition>\n",
"\n",
"First, run the following code cell to create a program file, `./source_files/transpile_remote.py`, which you will upload to Qiskit Serverless."
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "4b550093-1d73-4c15-905a-0caa12f7dcbe",
"execution_count": 3,
"id": "64722041-22ed-42bd-8d83-d8e9f5e5b55b",
"metadata": {
"editable": true,
"slideshow": {
Expand Down Expand Up @@ -124,32 +138,20 @@
},
{
"cell_type": "markdown",
"id": "ea182474-7566-4a13-96d8-cfcc8f16dd8f",
"id": "7e80b5bb-0f76-43d1-a68c-97b4b22cc88a",
"metadata": {},
"source": [
"## Set up your files\n",
"\n",
"Qiskit Serverless requires setting up your workload’s `.py` files into a dedicated directory. The following structure is an example of good practice:\n",
"\n",
"```text\n",
"serverless_program\n",
"├── program_uploader.ipynb\n",
"└── source_files\n",
" ├── transpile_remote.py\n",
" └── *.py\n",
"```\n",
"\n",
"Serverless uploads the contents of `source_files` to run remotely. Once these are set up, you can adjust `transpile_remote.py` to fetch inputs and return outputs.\n",
"\n",
"### Get program arguments\n",
"\n",
"Your initial `transpile_remote.py` has three inputs: `circuits`, `backend_name`, and `optimization_level`. Serverless is currently limited to only accept serializable inputs and outputs. For this reason, you cannot pass in `backend` directly, so use `backend_name` as a string instead."
"Your initial `transpile_remote.py` has three inputs: `circuits`, `backend_name`, and `optimization_level`. Serverless is currently limited to only accept serializable inputs and outputs. For this reason, you cannot pass in `backend` directly, so use `backend_name` as a string instead.\n",
"\n",
"The following cell appends code to your `transpile_remote.py` file."
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "54a8d2c6-a3f4-4169-9210-dd213e2273d2",
"execution_count": 4,
"id": "6819379b-d7b2-4fda-9e6b-459eec748a79",
"metadata": {},
"outputs": [
{
Expand All @@ -174,16 +176,18 @@
},
{
"cell_type": "markdown",
"id": "bf57e8a8-4f64-4933-978d-c16bda4e0c0c",
"id": "5ae9fb12-f06f-4f7d-8f37-1d872285deab",
"metadata": {},
"source": [
"At this point, you can get your backend with `QiskitRuntimeService` and add your existing program with the following code. The following code requires that you have already [saved your credentials](/docs/guides/cloud-setup)."
"At this point, you can get your backend with `QiskitRuntimeService` and add your existing program with the following code.\n",
"\n",
"The following code assumes that you have already followed the process to save your credentials by using `QiskitRuntimeService.save_account`, and will load your default saved account unless you specify otherwise. See [Save your login credentials](/docs/guides/save-credentials) and [Initialize your Qiskit Runtime service account](/docs/guides/initialize-account) for more information."
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "7077ba00-1571-4f99-8c53-b1a9ac280987",
"execution_count": 5,
"id": "4b0c7d24-9b87-4e00-bb1d-f82aa967cb1d",
"metadata": {},
"outputs": [
{
Expand All @@ -205,16 +209,16 @@
},
{
"cell_type": "markdown",
"id": "8bd63bfc-0da5-46de-ace5-8463b5ad92f3",
"id": "61e7cb3b-6d62-4b68-817a-39c0c1d95a9b",
"metadata": {},
"source": [
"Finally, you can run `transpile_remote()` across all `circuits` passed in, and return the `transpiled_circuits` as a result:"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "afdb6896-93b8-4006-b27b-49ebb16e7c1c",
"execution_count": 6,
"id": "041e7f85-e9e8-424d-8694-d54316225cc4",
"metadata": {},
"outputs": [
{
Expand All @@ -240,22 +244,20 @@
},
{
"cell_type": "markdown",
"id": "a05fa201-aabb-43a5-8a6a-f53c5c664fc4",
"id": "dac118ab-e447-4ddd-a5f8-d13e3953db76",
"metadata": {},
"source": [
"## Deploy to IBM Quantum Platform\n",
"\n",
"The previous section created a program to be run remotely. The code cells in this section upload that program to Qiskit Serverless.\n",
"\n",
"Use `qiskit-ibm-catalog` to authenticate to `QiskitServerless` with your API key, which you can find on the [IBM Quantum dashboard](https://quantum.cloud.ibm.com), and upload the program.\n",
"The previous section created a program to be run remotely. The following code cells upload that program to Qiskit Serverless, before running the workload (which is demonstrated in the [Run your first Qiskit Serverless workload remotely](/docs/guides/serverless-run-first-workload) guide).\n",
"\n",
"You can use `save_account()` to save your credentials (See the [Set up to use IBM Cloud](/docs/guides/cloud-setup#cloud-save) section). Note that this writes your credentials to the same file as [`QiskitRuntimeService.save_account()`](/docs/api/qiskit-ibm-runtime/qiskit-runtime-service#save_account)."
"Use `qiskit-ibm-catalog` to authenticate to `QiskitServerless` with your API key, which you can find on the [IBM Quantum dashboard](https://quantum.cloud.ibm.com), and upload the program."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "cc9d5267-8019-4543-ab6a-679583d26340",
"execution_count": 13,
"id": "8d1385c3-09a5-42c6-a5bc-53f686d8410e",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -267,16 +269,16 @@
},
{
"cell_type": "markdown",
"id": "7e8327dc-9105-4fb0-9cf0-c6e13ca32674",
"id": "a0f64820-5fb1-41b9-9cb4-5095d0b5db43",
"metadata": {},
"source": [
"Qiskit Serverless compresses the contents of `working_dir` (in this case, `source_files`) into a `tar`, which is uploaded and cleaned up after. The `entrypoint` identifies the main program executable for Qiskit Serverless to run. Additionally, if your program has custom `pip` dependencies, you can add them to a `dependencies` array:"
"Qiskit Serverless compresses the contents of `working_dir` (in this case, `source_files`) into a `tar`, which is uploaded and cleaned up after. The `entrypoint` identifies the main program executable for Qiskit Serverless to run."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "62738969-b19c-484e-8591-4f89c99990ed",
"execution_count": 8,
"id": "c1cdd46d-71e9-4711-a09b-6eca569ede6a",
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -289,8 +291,8 @@
},
{
"cell_type": "code",
"execution_count": 8,
"id": "ed72ee48-a643-4d2e-b245-6e9ab3673ddb",
"execution_count": 9,
"id": "8b675d04-bde8-4b3d-b9e5-99982ef742e1",
"metadata": {},
"outputs": [
{
Expand All @@ -299,7 +301,7 @@
"QiskitFunction(transpile_remote_serverless)"
]
},
"execution_count": 8,
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -310,16 +312,16 @@
},
{
"cell_type": "markdown",
"id": "9a22d507-2489-4f2f-af78-c9249ed3fc3d",
"id": "3a840c18-3010-4d05-91cb-592e2692c1d7",
"metadata": {},
"source": [
"To check if it successfully uploaded, use `serverless.list()`:"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "ff7d8283-ee72-4167-8a8a-1f07367ba6ef",
"execution_count": 10,
"id": "afaa3935-adf7-4b28-a8f0-583a82bbe3f1",
"metadata": {},
"outputs": [
{
Expand All @@ -328,7 +330,7 @@
"QiskitFunction(transpile_remote_serverless)"
]
},
"execution_count": 9,
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
Expand All @@ -344,8 +346,8 @@
},
{
"cell_type": "code",
"execution_count": 10,
"id": "7fee3152-025d-4df6-8299-591fe0482dac",
"execution_count": 11,
"id": "484713e3-b6ac-4a7a-9425-e9ac34b1bb6e",
"metadata": {
"tags": [
"remove-cell"
Expand All @@ -359,8 +361,8 @@
},
{
"cell_type": "code",
"execution_count": 11,
"id": "f0730886-1d67-4d1b-9ab2-133cbcfc7e49",
"execution_count": 12,
"id": "413e5d94-00f6-4c47-80d0-b5c4441934fc",
"metadata": {
"tags": [
"remove-cell"
Expand Down Expand Up @@ -394,7 +396,17 @@
},
{
"cell_type": "markdown",
"id": "f8940b98-33f7-4029-ac77-60058c4aee78",
"id": "6ff556c1-64bb-41ae-9c6c-9019a3cab9ca",
"metadata": {},
"source": [
"<Admonition type=\"tip\">\n",
"Currently, the [Workloads table](https://quantum.cloud.ibm.com/workloads) on IBM Quantum Platform only reflects Qiskit Runtime workloads. To see the status of your Qiskit Serverless workloads, use `job.status()`. Find an example in the [Run your first Qiskit Serverless workload remotely](/docs/guides/serverless-run-first-workload#serverless-job-status) guide.\n",
"</Admonition>"
]
},
{
"cell_type": "markdown",
"id": "a416b143-6f70-49dc-ab2f-ad66f042cab1",
"metadata": {},
"source": [
"## Next steps\n",
Expand Down Expand Up @@ -427,5 +439,5 @@
}
},
"nbformat": 4,
"nbformat_minor": 2
"nbformat_minor": 4
}
1 change: 1 addition & 0 deletions docs/guides/serverless-run-first-workload.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@
"id": "87dbb375-cd24-4d0f-a2fc-c653db8345e3",
"metadata": {},
"source": [
"<span id=\"serverless-job-status\"></span>\n",
"## Check job status\n",
"\n",
"With your Qiskit Serverless `job_id`, you can check the status of running jobs. This includes the following statuses:\n",
Expand Down
10 changes: 7 additions & 3 deletions docs/guides/serverless.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ Qiskit Serverless provides a simple interface to run workloads across quantum-cl

Premium users can build, deploy, and run their workloads remotely on classical compute made available through IBM Quantum Platform.

<Admonition type="tip">
**Qiskit Serverless is getting an upgrade, and its features are changing fast.** During this development phase, find release notes and the most recent documentation at the [Qiskit Serverless GitHub](https://qiskit.github.io/qiskit-serverless/index.html) page.
</Admonition>

<Admonition type="note">
This is an experimental feature available only for IBM Quantum Premium Plan, Flex Plan, and On-Prem (via IBM Quantum Platform API) Plan users.
</Admonition>

## When should I use Qiskit Serverless?

Qiskit Serverless helps manage classical and quantum resources across the entire [Qiskit patterns](./intro-to-patterns) workflow. This includes some of the following examples:
Qiskit Serverless helps manage classical and quantum resources across the entire [Qiskit patterns](/docs/guides/intro-to-patterns) workflow. This includes some of the following examples:

- Parallelizing classical tasks, such as pre-processing and post-processing
- Persisting long-running workloads in the cloud, even if your laptop is turned off
Expand All @@ -40,14 +44,14 @@ pip install qiskit-ibm-catalog qiskit_serverless
`qiskit_ibm_catalog` provides the client-side tools to upload and run remote programs, while `qiskit_serverless` provides server-side tools to distribute compute and manage data. These packages require `python` 3.11+. For users and organizations who want to run Qiskit Serverless on custom infrastructure, follow the [Cloud infrastructure setup](https://qiskit.github.io/qiskit-serverless/) guide.

<Admonition type="tip">
Currently, the IBM Quantum workloads table only reflects Qiskit Runtime workloads. Use `job.status()` to see your Qiskit Serverless workload's current status.
Currently, the IBM Quantum workloads table only reflects Qiskit Runtime workloads. Use `job.status()` to see your Qiskit Serverless workload's current status. Find an example in the [Run your first Qiskit Serverless workload remotely](/docs/guides/serverless-run-first-workload#serverless-job-status) guide.
</Admonition>

## Next steps

<Admonition type="info" title="Recommendations">

- Explore how to [write your first Qiskit Serverless program](./serverless-first-program).
- Explore how to [write your first Qiskit Serverless program](/docs/guides/serverless-first-program).
- Try out some [tutorials](/docs/tutorials).

</Admonition>
Loading