Toolkit for Qiskit Examples from Qiskit Tutorials

The following examples from qiskit tutorials illustrate how to use the toolkit for qiskit.

Note

Before trying these examples, ensure that quantumrings-toolkit-qiskit is installed. See Installing the toolkit for qiskit
Also, ensure that your Quantum Rings Account credentials are locally saved. See Saving the Quantum Rings account locally

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 Tutorials

CHSH Inequality

QAOA Example

VQE Example

Grover’s Example

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 Finance Tutorials

Quantum Amplitude Estimation

Portfolio Optimization

Portfolio Diversification

Pricing European Call Options

Pricing European Put Options

Pricing Bull Spreads

Pricing Basket Options

Pricing Asian Barrier Spreads

Pricing Fixed-Income Assets

Credit Risk Analysis

Option Pricing with qGANs

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 Nature Tutorials

Electronic structure

Vibrational structure

Ground state solvers

Excited states solvers

Transforming Problems

Mapping to the Qubit Space

QCSchema

Properties or OperatorFactories

Lattice models

Quadratic Hamiltonians and Slater determinants

Binding Energy

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
Qiskit Machine Learning Tutorials

Quantum Neural Networks

Neural Network Classifier and Regressor

Training a Quantum Model on a Real Dataset

Quantum Kernel Machine Learning

PyTorch qGAN Implementation

Torch Connector and Hybrid QNNs

Pegasos Quantum Support Vector Classifier

Quantum Kernel Training for Machine Learning Applications

Saving, Loading Qiskit Machine Learning Models and Continuous Training

Effective Dimension of Qiskit Neural Networks

The Quantum Convolution Neural Network

The Quantum Autoencoder

Quantum Bayesian Inference

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.

Qiskit Optimization Tutorials

Quadratic Programs

Converters for Quadratic Programs

Minimum Eigen Optimizer

Quantum Kernel Machine Learning

Grover Optimizer

ADMM Optimizer

Max-Cut and Traveling Salesman Problem

Vehicle Routing

Improving Variational Quantum Optimization using CVaR

Application Classes for Optimization Problems

Warm-starting quantum optimization

Quantum Random Access Optimization