208 lines
9.7 KiB
Plaintext
208 lines
9.7 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "08b03705-262b-40bc-a6b2-e70a486d869f",
|
|
"metadata": {},
|
|
"source": [
|
|
"{/* cspell:ignore Eprint */}\n",
|
|
"\n",
|
|
"# Transpile circuits remotely with the Qiskit Transpiler Service"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "5d1591e2-d35d-491a-88a9-827f3a7cfc1d",
|
|
"metadata": {
|
|
"tags": [
|
|
"version-info"
|
|
]
|
|
},
|
|
"source": []
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "2704ef01-ddde-47a0-9a14-a70bbc72b326",
|
|
"metadata": {},
|
|
"source": [
|
|
"The Qiskit Transpiler Service provides transpilation capabilities on the cloud. In addition to the local Qiskit transpiler capabilities, your transpilation tasks can benefit from both IBM Quantum® cloud resources and AI-powered transpiler passes.\n",
|
|
"\n",
|
|
"The Qiskit Transpiler Service offers a Python library to seamlessly integrate this service and its capabilities into your current Qiskit patterns and workflows.\n",
|
|
"\n",
|
|
"<Admonition type=\"note\">\n",
|
|
" This service is only available for IBM Quantum Premium Plan users.\n",
|
|
" The service is a beta release, subject to change.\n",
|
|
" If you have feedback or want to contact the developer team, please use this [Qiskit Slack Workspace channel](https://qiskit.slack.com/archives/C06KF8YHUAU).\n",
|
|
"</Admonition>\n",
|
|
"\n",
|
|
"<span id=\"install-transpiler-service\"></span>\n",
|
|
"## Install the qiskit-ibm-transpiler package\n",
|
|
"\n",
|
|
"To use the Qiskit Transpiler Service, install the `qiskit-ibm-transpiler` package:\n",
|
|
"\n",
|
|
"```sh\n",
|
|
"pip install qiskit-ibm-transpiler\n",
|
|
"```\n",
|
|
"\n",
|
|
"By default, the package tries to authenticate to IBM Quantum services with the defined Qiskit API key, and uses your token from the `QISKIT_IBM_TOKEN` environment variable or from the file `~/.qiskit/qiskit-ibm.json` (under the section `default-ibm-quantum`).\n",
|
|
"\n",
|
|
"*Note*: This package requires Qiskit SDK v1.X.\n",
|
|
"\n",
|
|
"## qiskit-ibm-transpiler transpile options\n",
|
|
"\n",
|
|
"- `backend_name` (optional, str) - A backend name as it would be expected by QiskitRuntimeService (for example, `ibm_torino`). If this is set, the transpile method uses the layout from the specified backend for the transpilation operation. If any other option is set that impacts these settings, such as `coupling_map`, the `backend_name` settings are overridden.\n",
|
|
"- `coupling_map` (optional, List[List[int]]) - A valid coupling map list (for example, [[0,1],[1,2]]). If this is set, the transpile method uses this coupling map for the transpilation operation. If defined, it overrides any value specified for `target`.\n",
|
|
"- `optimization_level` (int) - The potential optimization level to apply during the transpilation process. Valid values are [1,2,3], where 1 is the least optimization (and fastest), and 3 the most optimization (and most time-intensive).\n",
|
|
"- `ai` (\"true\", \"false\", \"auto\") - Whether to use AI-powered capabilities during transpilation. The AI-powered capabilities available can be for `AIRouting` transpiling passes or other AI-powered synthesis methods. If this value is `\"true\"`, the service applies different AI-powered transpiling passes depending on the `optimization_level` requested. If `\"false\"`, it uses the latest Qiskit transpiling features without AI. Finally, if `\"auto\"`, the service decides whether to apply the standard Qiskit heuristic passes or the AI-powered passes based on your circuit.\n",
|
|
"- `qiskit_transpile_options` (dict) - A Python dictionary object that can include any other option that is valid in the [Qiskit `transpile()` method](defaults-and-configuration-options). If the `qiskit_transpile_options` input includes `optimization_level`, it is discarded in favor of the `optimization_level` specified as parameter input. If the `qiskit_transpile_options` includes any option not recognized by the Qiskit `transpile()` method, the library raises an error.\n",
|
|
"\n",
|
|
"For more information about the available `qiskit-ibm-transpiler` methods, see the [qiskit-ibm-transpiler API reference](/docs/api/qiskit-ibm-transpiler). To learn more about the service API, see the [Qiskit Transpiler Service REST API documentation.](/docs/api/qiskit-transpiler-service-rest)\n",
|
|
"\n",
|
|
"## Examples\n",
|
|
"\n",
|
|
"The following examples demonstrate how to transpile circuits using the Qiskit Transpiler Service with different parameters.\n",
|
|
"\n",
|
|
"1. Create a circuit and call the Qiskit Transpiler Service to transpile the circuit with `ibm_torino` as the `backend_name`, 3 as the `optimization_level`, and without using AI during the transpilation."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "47762a14-a24f-47af-8fba-fc32d20d9865",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from qiskit.circuit.library import efficient_su2\n",
|
|
"from qiskit_ibm_transpiler.transpiler_service import TranspilerService\n",
|
|
"\n",
|
|
"circuit = efficient_su2(101, entanglement=\"circular\", reps=1)\n",
|
|
"\n",
|
|
"cloud_transpiler_service = TranspilerService(\n",
|
|
" backend_name=\"ibm_torino\",\n",
|
|
" ai=\"false\",\n",
|
|
" optimization_level=3,\n",
|
|
")\n",
|
|
"transpiled_circuit = cloud_transpiler_service.run(circuit)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "55692fd1-ed2f-4647-8008-d021a8ab0ec5",
|
|
"metadata": {},
|
|
"source": [
|
|
"*Note*: you only can use backend_name devices you have access to with your IBM Quantum account. Apart from the `backend_name`, the `TranspilerService` also allows `coupling_map` as parameter.\n",
|
|
"\n",
|
|
"2. Produce a similar circuit and transpile it, requesting AI transpiling capabilities by setting the flag `ai` to `True`:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "4dd3c6f1-4f97-4262-9f86-27751bbc00e8",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from qiskit.circuit.library import efficient_su2\n",
|
|
"from qiskit_ibm_transpiler.transpiler_service import TranspilerService\n",
|
|
"\n",
|
|
"circuit = efficient_su2(101, entanglement=\"circular\", reps=1)\n",
|
|
"\n",
|
|
"cloud_transpiler_service = TranspilerService(\n",
|
|
" backend_name=\"ibm_torino\",\n",
|
|
" ai=\"true\",\n",
|
|
" optimization_level=1,\n",
|
|
")\n",
|
|
"transpiled_circuit = cloud_transpiler_service.run(circuit)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "3b0dae9a-2140-45bc-bc23-d087295069a9",
|
|
"metadata": {},
|
|
"source": [
|
|
"3. Produce a similar circuit and transpile it while letting the service to decide whether to use the AI-powered transpiling passes."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"id": "10524c72-ae51-48ab-bd8f-bea09fe2e97c",
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"from qiskit.circuit.library import efficient_su2\n",
|
|
"from qiskit_ibm_transpiler.transpiler_service import TranspilerService\n",
|
|
"\n",
|
|
"circuit = efficient_su2(101, entanglement=\"circular\", reps=1)\n",
|
|
"\n",
|
|
"cloud_transpiler_service = TranspilerService(\n",
|
|
" backend_name=\"ibm_torino\",\n",
|
|
" ai=\"auto\",\n",
|
|
" optimization_level=1,\n",
|
|
")\n",
|
|
"transpiled_circuit = cloud_transpiler_service.run(circuit)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"id": "e6656fea-cb9a-450b-8ff7-268662df732a",
|
|
"metadata": {},
|
|
"source": [
|
|
"## Limits of the Qiskit Transpiler Service\n",
|
|
"\n",
|
|
"Following are the most relevant limitations of the service:\n",
|
|
"\n",
|
|
"- The maximum number of two-qubit gates per circuit in a transpilation job in any `ai` mode is 1 million.\n",
|
|
"- The maximum time allowed to run a transpilation process is 30 minutes per job.\n",
|
|
"- You must retrieve the transpilation result from the service within 20 minutes after the transpilation process ends. After 20 minutes, the job result is discarded.\n",
|
|
"- The maximum time a set of circuits can live in the internal queue while waiting to be transpiled is 120 minutes. After that time, if the job has not been transpiled, it is discarded.\n",
|
|
"- The maximum number of qubits has not been determined. The service has been tested on 900+ qubits.\n",
|
|
"\n",
|
|
"## Citation\n",
|
|
"\n",
|
|
"If you use any AI-powered feature from the Qiskit Transpiler Service in your research, use the following recommended citation:\n",
|
|
"\n",
|
|
"```\n",
|
|
"@misc{2405.13196,\n",
|
|
"Author = {David Kremer and Victor Villar and Hanhee Paik and Ivan Duran and Ismael Faro and Juan Cruz-Benito},\n",
|
|
"Title = {Practical and efficient quantum circuit synthesis and transpiling with Reinforcement Learning},\n",
|
|
"Year = {2024},\n",
|
|
"Eprint = {arXiv:2405.13196},\n",
|
|
"}\n",
|
|
"```\n",
|
|
"\n",
|
|
"## Next steps\n",
|
|
"\n",
|
|
"<Admonition type=\"tip\" title=\"Recommendations\">\n",
|
|
" - Learn how to create [AI transpiler passes.](ai-transpiler-passes)\n",
|
|
" - Learn [how to transpile circuits](https://learning.quantum.ibm.com/tutorial/submit-transpiled-circuits) as part of Qiskit Patterns workflows using Qiskit Runtime.\n",
|
|
" - Review the [Qiskit Transpiler Service Python client](/docs/api/qiskit-ibm-transpiler) documentation.\n",
|
|
"</Admonition>"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"description": "What is the Qiskit Transpiler Service and how to use it",
|
|
"kernelspec": {
|
|
"display_name": "Python 3",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3"
|
|
},
|
|
"title": "Transpile circuits remotely with the Qiskit Transpiler Service"
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|