Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove use of qasm simulator #589

Merged
merged 3 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions circuit_knitting/cutting/cutqc/wire_cutting_evaluation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import copy
from typing import Sequence, Any
from multiprocessing.pool import ThreadPool
from warnings import warn

import numpy as np

Expand Down Expand Up @@ -81,6 +82,14 @@ def run_subcircuit_instances(
options[i % len(options)] for i, _ in enumerate(subcircuits)
]
else:
warn(
"Please provide a list of `backend_names` alongside the `service`. "
"With no backend specified, CutQC defaults to using "
"ibmq_qasm_simulator, but cloud simulators are not expected to be "
"operational past May 15, 2024. For more details, see: "
"https://docs.quantum.ibm.com/announcements/product-updates/2024-03-22-announcement-cloud-simulators-and-lab",
stacklevel=2,
)
backend_names_repeated = ["ibmq_qasm_simulator"] * len(subcircuits)
if options:
options_repeated = [options[0]] * len(subcircuits)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,10 @@
"# Set the Sampler and runtime options\n",
"options = Options(execution={\"shots\": 4000})\n",
"\n",
"# Run 2 parallel qasm simulator threads\n",
"backend_names = [\"ibmq_qasm_simulator\"] * 2"
"# Use the least busy backend for both threads\n",
"backend_names = None\n",
"if service is not None:\n",
" backend_names = [service.least_busy().name] * 2"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,60 +75,6 @@
"circuit.draw(\"mpl\", fold=-1, scale=0.75)"
]
},
{
"cell_type": "markdown",
"id": "461e57e3",
"metadata": {},
"source": [
"## Set up the Qiskit Runtime Service\n",
"\n",
"The Qiskit Runtime Service provides access to IBM Runtime Primitives and quantum backends.\n",
"Alternatively, a local statevector simulator can be used with the Qiskit primitives."
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "5d1fb2ca",
"metadata": {},
"outputs": [],
"source": [
"from qiskit_ibm_runtime import (\n",
" QiskitRuntimeService, # noqa: F401\n",
" Options,\n",
")\n",
"\n",
"# Use local versions of the primitives by default.\n",
"service = None\n",
"\n",
"# Uncomment the following line to instead use Qiskit Runtime.\n",
"# service = QiskitRuntimeService()"
]
},
{
"cell_type": "markdown",
"id": "5fb383d2",
"metadata": {},
"source": [
"The wire cutter tool uses a `Sampler` primitive to evaluate the probabilities of each subcircuit. Here, we configure the options for the Runtime Sampler and specify the backend(s) to be used to evaluate the subcircuits.\n",
"\n",
"If no service was set up, the `backend_names` argument will be ignored, and Qiskit primitives will be used with statevector simulator."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "d409553d",
"metadata": {},
"outputs": [],
"source": [
"# Set the Sampler and runtime options\n",
"options = Options(execution={\"shots\": 4000})\n",
"\n",
"# Run 2 parallel qasm simulator threads\n",
"backend_names = [\"ibmq_qasm_simulator\"] * 2"
]
},
{
"attachments": {
"how-to-manual-cut.png": {
Expand Down Expand Up @@ -244,6 +190,11 @@
"metadata": {},
"outputs": [],
"source": [
"from qiskit_ibm_runtime import (\n",
" QiskitRuntimeService, # noqa: F401\n",
" Options,\n",
")\n",
"\n",
"# Use local versions of the primitives by default.\n",
"service = None\n",
"\n",
Expand Down Expand Up @@ -273,8 +224,10 @@
"# Set the Sampler and runtime options\n",
"options = Options(execution={\"shots\": 4000})\n",
"\n",
"# Run 2 parallel qasm simulator threads\n",
"backend_names = [\"ibmq_qasm_simulator\"] * 2"
"# Use the least busy backend for both threads\n",
"backend_names = None\n",
"if service is not None:\n",
" backend_names = [service.least_busy().name] * 2"
]
},
{
Expand Down