Skip to content

Commit

Permalink
Remove use of qasm simulator (#589) (#592)
Browse files Browse the repository at this point in the history
* Remove use of qasm simulator

Closes #502.

* Replace default configuration change with a warning

* Add `stacklevel` to warning

(cherry picked from commit e3db27b)

Co-authored-by: Jim Garrison <garrison@ibm.com>
  • Loading branch information
mergify[bot] and garrison committed May 15, 2024
1 parent 7e1a3ab commit 2af845e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 58 deletions.
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

0 comments on commit 2af845e

Please sign in to comment.