docs/examples/02_qaoa doesn't work with "USE_RUNTIME_SERVICE = True"
Steps to reproduce the problem
Execute docs/examples/02_qaoa with QiskitRuntimeService for an account and USE_RUNTIME_SERVICE = True
What is the current behavior?
cloud simulators and Lab are now retired
So I tried to run the examples/02_qaoa with backend = "ibm_sherbrooke"
I got
IBMInputValueError(\nqiskit_ibm_runtime.exceptions.IBMInputValueError: 'The instruction u3 on qubits (0,) is not supported by the target system. Circuits that do not match the target hardware definition are no longer supported after March 4, 2024.
and
See the transpilation documentation (https://docs.quantum.ibm.com/transpile) for instructions to transform circuits and the primitive examples (https://docs.quantum.ibm.com/run/primitives-examples) to see this coupled with operator transformations.
What is the expected behavior?
Job is executed successfully on the quantum system.
I added the transpiler step like this in qaoa.py:
if service is not None:
# if we have service we need to open a session and create sampler
service = arguments.get("service")
backend = service.least_busy(operational=True, simulator=False, min_num_qubits=127)
session = Session(service=service, backend=backend)
options = Options()
options.optimization_level = 3
pm = generate_preset_pass_manager(optimization_level=1, backend=backend)
ansatz = pm.run(ansatz)
then it's getting:
/tmp/ray/session_2024-05-17_12-34-33_233332_8/runtime_resources/working_dir_files/ray_pkg_6854cd4610ddcb3f/qaoa.py:79: DeprecationWarning: The Sampler and Estimator V1 primitives have been deprecated as of qiskit-ibm-runtime 0.23.0 and will be removed no sooner than 3 months after the release date. Please use the V2 Primitives. See the V2 migration guide <[https://docs.quantum.ibm.com/api/migration-guides/v2-primitives>](https://docs.quantum.ibm.com/api/migration-guides/v2-primitives%3E%60_). for more details\n estimator = Estimator(session=session, options=options)\ncapi_return is NULL\nCall-back cb_calcfc_in__cobyla__user__routines failed.\nTraceback (most recent call last):\n File "/tmp/ray/session_2024-05-17_12-34-33_233332_8/runtime_resources/working_dir_files/_ray_pkg_6854cd4610ddcb3f/qaoa.py", line 84, in
Here is summary of circuit creation code.
import numpy as np
from qiskit.circuit.library import QAOAAnsatz
from qiskit.circuit.library import IQP
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
from qiskit_ibm_runtime import QiskitRuntimeService
from qiskit.quantum_info import SparsePauliOp
from qiskit.circuit.library import IQP
from qiskit.transpiler.preset_passmanagers import generate_preset_pass_manager
operator = SparsePauliOp.from_list([("IIIZZ", 1), ("IIZIZ", 1), ("IZIIZ", 1), ("ZIIIZ", 1)])
ansatz = QAOAAnsatz(operator, reps=2)
ansatz = ansatz.decompose(reps=3)
ansatz.draw(fold=-1)
service = QiskitRuntimeService(
channel='ibm_quantum',
instance='ibm-q/open/main',
token='<my token>'
)
backend = service.least_busy(operational=True, simulator=False, min_num_qubits=127)
pm = generate_preset_pass_manager(optimization_level=1, backend=backend)
ansatz_t = pm.run(ansatz)
ansatz_t.draw(fold=-1)
I'll update the sample by following this https://learning.quantum.ibm.com/tutorial/quantum-approximate-optimization-algorithm