Skip to content

attempt to implement ZNE error mitigation using qiskit without use of mitiq

License

Notifications You must be signed in to change notification settings

KarimElgammal/Zero-noise-extrapolation-in-quantum-computer

Repository files navigation

Zero-Noise Extrapolation (ZNE) implementation for error mitigation in quantum simulations

This repository contains an attempt for the implementation of Zero-Noise Extrapolation (ZNE) for error mitigation in quantum circuits using Qiskit. It can be good example for learning purposes, but you should consider a dedicated package like mitiq for that. The approach here uses unitary folding to simulate the noise and then extrapolates the results to estimate the outcomes.

The repository files are:

  1. custom ZNE qiskit simulation implementation contains workflow of using unitary folding to simulate the noise and then extrapolates the results to estimate the outcomes

  2. custom ZNE qiskit on IBMQ not successful after, maybe need different way to transile to accomodate the new changes

  • aux_functions.py: This file contains auxiliary functions for generating quantum circuits, creating a noise model, running circuits on a simulator, and plotting the results.

Functions

The functions in aux_functions.py are:

  • depolarizing_noise_model(p_error_1q, p_error_2q): Creates a noise model with depolarizing error.
  • generate_GHZ(n_qubits): Generates a GHZ state with n qubits.
  • generate_layered_circuit(num_layers, num_qubits, rotation_angles): Generates a layered quantum circuit with num_layers and num_qubits.
  • probabilities(counts, dim): Calculates the probabilities of the states by converting the counts to probabilities.
  • unitary_folding(num_folds, num_layers, num_qubits, rotation_angles, simulator, state_vector_dim, print_circuit=False): Applies unitary folding to a quantum circuit and returns the noisy probabilities.
  • fold_circuit(circuit, num_folds, simulator): Folds a quantum circuit by composing it with itself num_folds times.
  • run_circuit(circuit, simulator): Runs a quantum circuit on a simulator and returns the counts.
  • fit_polynomial(x, y, degree): Fits a polynomial of the given degree to the data and returns the polynomial function.
  • fit_exponential(x, y): Fits an exponential function to the data and returns the function.
  • fit_linear(x, y): Fits a linear function to the data and returns the function.
  • plot_probabilities(params): Plots the probabilities of the outcomes of a quantum circuit.

Usage

To use these functions, import them into your Python script:

from aux_functions import generate_GHZ
ghz_circuit = generate_GHZ(3) #generate 3qubit GHZ circuit

packages needed

qiskit, qiskit-aer, numpy, scipy

Installation

To install the required libraries, run the following command:

pip install qiskit qiskit-aer numpy matplotlib scipy ipykernel

Reference:

About

attempt to implement ZNE error mitigation using qiskit without use of mitiq

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published