Skip to content

Commit

Permalink
Update explanation in migration guide (#981)
Browse files Browse the repository at this point in the history
  • Loading branch information
caleb-johnson authored Sep 29, 2023
1 parent 05842c2 commit 1f5141a
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions docs/migration/migration_from_qiskit_runtime_programs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
"source": [
"# Converting from Qiskit Runtime Programs\n",
"\n",
"This tutorial will be demonstation of converting your custom Qiskit Runtime Program into Quantum Serverless `Program`.\n",
"This tutorial will be a demonstation of converting your custom Qiskit Runtime Program into a Quantum Serverless `Program`.\n",
"\n",
"If you were using Qiskit Runtime Programs before, you probably have code similar to following one\n",
"If you were using Qiskit Runtime Programs before, your code probably looks similar to the following example:\n",
"\n",
"```python\n",
"\"\"\"A sample runtime program that submits random circuits for user-specified iterations.\"\"\"\n",
Expand Down Expand Up @@ -45,16 +45,15 @@
"```\n",
"\n",
"\n",
"You probably notices that all Qiskit Runtime Programs has `main` method which accepts `backend`, `user_messenger` and `**kwargs`. \n",
"For Quantum Serverless Programs you do not need this method. Although, you might use standart Python `if __name__ == \"__main__\"` cause, but it is not necessary.\n",
"All Qiskit Runtime Programs have a `main` method which accepts `backend`, `user_messenger` and `**kwargs`. This method is not required for Quantum Serverless programs.\n",
"\n",
"We also need to take care of couple of other things:\n",
"- `backend`. For Quantum Serverless programs you are not limited to single backend for a program. You can actually call any number of backends from single program. And since `Backend.run` is deprecated, we will be using Qiskit Primites to do our calculation.\n",
"- `user_messenger` were used in Qiskit Runtime Programs to communicate logs. Now, you do not need it and all standart Python `print` statements will be logged and can be accessed from job handler.\n",
"- `**kwargs` for argument parsing is now switched to `get_arguments` function, which is giving you a list of arguments passed to a Program.\n",
"- if you want you program to save some result of execution we have a function `save_result` which accepts python dictionary and can be accessible later via job handler.\n",
"Quantum Serverless handles backends, logging, and input arguments a bit differently than Qiskit Runtime:\n",
"- `backend`. For Quantum Serverless programs you are not limited to single backend for a program. You can call any number of backends from single program. Since `Backend.run` is deprecated, we will be using Qiskit Primitives to do our calculation.\n",
"- `user_messenger` were used in Qiskit Runtime Programs to facilitate retrieving logs from the program. Quantum Serverless does not require passing such an object. Instead, all contents of `stdout` (e.g. print statements, logging messages) will be provided to the user via the Quantum Serverless job handler.\n",
"- `**kwargs` was a variable used to capture program inputs from the user. Users should now input their arguments to the `Program` constructor, and the arguments should be retrieved within the program using the `get_arguments` function from Quantum Serverless.\n",
"- To save the results of a program, the `save_result` function should be used. It accepts a python dictionary and can be accessed via the job handler.\n",
"\n",
"Having above mentioned point in mind let's edit our Qiskit Runtime Program and turn it into Quantum Serverless Program\n",
"Let's use the guidelines above to transform the above Qiskit Runtime Program into a Quantum Serverless Program.\n",
"\n",
"```python\n",
"# migrated_program.py\n",
Expand Down Expand Up @@ -221,7 +220,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.8.16"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 1f5141a

Please sign in to comment.