Toolkit for Qiskit Examples from Qiskit Tutorials
The following examples from qiskit tutorials illustrate how to use the toolkit for qiskit.
Note
Acquiring the Quantum Rings backend
After saving your account credentials as explained in the link in the above note, use the following code snippet to acquire the backend for qiskit usage.
# Acquiring the backend
import QuantumRingsLib
from QuantumRingsLib import QuantumRingsProvider
from quantumrings.toolkit.qiskit import QrBackendV2
provider = QuantumRingsProvider()
backend = QrBackendV2(provider)
Using Quantum Rings Estimator and Sampler modules
After acquiring the backend, depending upon the application, Quantum Rings Estimator and/or Sampler modules can be used as shown in the following section. You can replace the qiskit provided Estimator and Sampler modules directly using Quantum Rings provided Estimator and Sampler modules. The replacement is usually a single line replacement.
# Using SamplerV2
from quantumrings.toolkit.qiskit import QrSamplerV2 as Sampler
sampler = Sampler(backend=backend)
# Using EstimatorV2
from quantumrings.toolkit.qiskit import QrEstimatorV2 as Estimator
estimator = Estimator(backend=backend)
estimator.options.default_shots = 1000
Choose between V1 or V2 Sampler/Estimator modules, depending upon the usage. The following qiskit tutorials are good examples of these classes:
QrBackendV2
QrEstimatorV2
QrEstimatorV1
QrSamplerV2
QrSamplerV1
QrStatevector
QrStatevectorSampler
Qiskit Finance Package
Qiskit Finance version 0.4.1 is currently supported. For installation of this package and its usage, please refer to: Qiskit Finance. The following notebooks illustrate the changes required for the Qiskit Finance Tutorials to run on the Quantum Rings SDK.
Qiskit Nature Package
The Qiskit Nature package version 0.7.2 is currently supported. For instructions on installing and using this package, please refer to: Qiskit Nature. The following notebooks explain the changes required to execute the Qiskit Nature tutorials on the Quantum Rings SDK.
Qiskit Machine Learning Package
We support Qiskit Machine Learning Package version 0.8.1, currently. For instructions on installing and using this package, please refer to: Qiskit Machine Learning. Quantum Rings toolkit for Qiskit Machine Learning Package provides the following derived classes.
QrEstimatorQNN
QrSamplerQNN
QrFidelityQuantumKernel
QrTrainableFidelityQuantumKernel
These derived classes can be imported to replace the Qiskit provided classes directly.
from quantumrings.toolkit.qiskit.machine_learning import QrEstimatorQNN as EstimatorQNN
from quantumrings.toolkit.qiskit.machine_learning import QrSamplerQNN as SamplerQNN
from quantumrings.toolkit.qiskit.machine_learning import QrFidelityQuantumKernel as FidelityQuantumKernel
from quantumrings.toolkit.qiskit.machine_learning import QrTrainableFidelityQuantumKernel as TrainableFidelityQuantumKernel
Saving, Loading Qiskit Machine Learning Models and Continuous Training |
Qiskit Optimization Package
We support Qiskit Optimization Package version 0.6.1, currently. For instructions on installing and using this package, please refer to: Qiskit Optimization. Quantum Rings toolkit for Qiskit Package provides the following derived classes, which are required for the Optimization Package.
QrEstimatorV1
QrSamplerV1
These derived classes can be imported to replace the Qiskit provided classes directly.. Identify the code sections in the tutorials where the original Sampler and Estimator modules were imported and replace them with Quantum Rings’ as shown below.
# Switch to Quantum Rings's Sampler
#from qiskit.primitives import Sampler
from quantumrings.toolkit.qiskit import QrSamplerV1 as Sampler
# Switch to Quantum Rings's Estimator
#from qiskit.primitives import Estimator
from quantumrings.toolkit.qiskit import QrEstimatorV1 as Estimator
The required changes are made in the following tutorials for your ready reference.