Qiskit Runtime (qiskit_ibm_runtime
)¶
Modules related to Qiskit Runtime IBM Client.
Qiskit Runtime is a new architecture that streamlines computations requiring many iterations. These experiments will execute significantly faster within its improved hybrid quantum/classical process.
Primitives and sessions¶
Qiskit Runtime has two predefined primitives: Sampler
and Estimator
.
These primitives provide a simplified interface for performing foundational quantum
computing tasks while also accounting for the latest developments in
quantum hardware and software.
Qiskit Runtime also has the concept of a session. Jobs submitted within a session are prioritized by the scheduler. A session allows you to make iterative calls to the quantum computer more efficiently.
Below is an example of using primitives within a session:
from qiskit_ibm_runtime import QiskitRuntimeService, Session, Sampler, Estimator, Options
from qiskit.test.reference_circuits import ReferenceCircuits
from qiskit.circuit.library import RealAmplitudes
from qiskit.quantum_info import SparsePauliOp
# Initialize account.
service = QiskitRuntimeService()
# Set options, which can be overwritten at job level.
options = Options(optimization_level=3)
# Prepare inputs.
bell = ReferenceCircuits.bell()
psi = RealAmplitudes(num_qubits=2, reps=2)
H1 = SparsePauliOp.from_list([("II", 1), ("IZ", 2), ("XI", 3)])
theta = [0, 1, 1, 2, 3, 5]
with Session(service=service, backend="ibmq_qasm_simulator") as session:
# Submit a request to the Sampler primitive within the session.
sampler = Sampler(session=session, options=options)
job = sampler.run(circuits=bell)
print(f"Sampler results: {job.result()}")
# Submit a request to the Estimator primitive within the session.
estimator = Estimator(session=session, options=options)
job = estimator.run(
circuits=[psi], observables=[H1], parameter_values=[theta]
)
print(f"Estimator results: {job.result()}")
# Close the session only if all jobs are finished and you don't need to run more in the session.
session.close()
Backend data¶
QiskitRuntimeService
also has methods, such as backend()
,
backends()
, and least_busy()
, that allow you to query for a target
backend to use. These methods return one or more IBMBackend
instances
that contains methods and attributes describing the backend.
Supplementary Information¶
Classes¶
|
Class for interacting with the Qiskit Runtime service. |
|
Class for interacting with Qiskit Runtime Estimator primitive service. |
|
Class for interacting with Qiskit Runtime Sampler primitive service. |
|
Class for creating a flexible Qiskit Runtime session. |
|
Backend class interfacing with an IBM Quantum backend. |
|
Representation of a runtime program execution. |
|
Class representing program metadata. |
|
A namespace for program parameters with validation. |
|
Class for representing generic runtime execution options. |
|
JSON Encoder used by runtime service. |
|
JSON Decoder used by runtime service. |