GithubHelp home page GithubHelp logo

deyh2020 / ibm2021-open-science-prize Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 0.0 291 KB

Simulating the XXX Heisenberg Model Hamiltonian for a System of Three Interacting Spin-1/2 Particles on IBM Quantum’s 7-qubit Jakarta Processor.

License: Apache License 2.0

Python 4.25% Jupyter Notebook 95.75%

ibm2021-open-science-prize's Introduction

Donate Open In Colab License Contributions Maintenance Release

2021 IBM Open Science Prize

Simulating the XXX Heisenberg Model Hamiltonian for a System of Three Interacting Spin-1/2 Particles on IBM Quantum’s 7-qubit Jakarta Processor


This is a clean slate. The original project can be accessed on ibmquantumawards.bemyapp.com.

Developer: ¹Lucas Camponogara Viera
¹National Taiwan Normal University - NTNU, Taipei, Taiwan.

Dependencies

Shows Qiskit logo for light color mode and dark color mode.

For specific versions, see the requirements.txt file.

Preliminary Results

View source code here. To know about the step-by-step simulation, one can resort to the simulation.ipynb Jupyter notebook file and the corresponding supplementary.ipynb material for a skill reaffirming theoretical background.

Classical simulation shows that state fidelity does not increase with increasing number of Trotter steps given that $F_4(t=\pi)<F_3(t=\pi)<F_2(t=\pi)$. Classical simulation without noise also suggests a minimum number of $N_{\text{min}}=6$ Trotter steps ($F_6\approx 58$%) to comply with the competition judging criteria where the state fidelity is lower bounded at 30% for $N \geq 4$. A baseline number of $N=8$ Trotter steps is recommended according to simulations using the fake Jakarta backend. Since the simulation shown in the graph below considers a noise-free environment, the state fidelity is between two pure states (a.k.a state vectors). This contrasts with a noisy system that requires the evolved state to be represented by a mixed density operator (noise creates mixed states) and the state fidelity to be given in terms of the trace function. Recall that, although a mixed state (See Ref. [1]) consist of an ensemble (statistical mixture) of N pure states denoted $|\psi\rangle$ in the state vector formalism, a mixed state cannot be represented by a linear combination of the aforementioned normalized state vectors (pure states) that are defined on a separable Hilbert Space.

  • $F_1=0.9997172927505018$
  • $F_2=0.9997173027412785$
  • $F_3=0.07441607773249213$
  • $F_4=0.00015902844790257657$
  • $F_5=0.25775363032243465$
  • $F_6=0.5765991261868874$
  • $F_7=0.7625355067869187$
  • $F_8=0.8611366833624895$
  • $F_9=0.91466455372391$

First Steps

Note: Windows users should replace "python3" with "python".

  1. Clone this repository and switch to cloned directory:
git clone https://github.com/QuCAI-Lab/ibm2021-open-science-prize.git && cd ibm2021-open-science-prize
  1. Create a conda environment named "heisenberg-model" and activate it:
conda create -yn heisenberg-model python==3.7.13 && conda activate heisenberg-model
  1. Install pip version 22.0.4 (latest version) in the current environment and check for updates:
conda install -yc conda-forge pip==22.0.4 && python3 -m pip install --user --upgrade pip
  1. Install the heisenberg-model package with the required dependencies via the requirements.txt file:
python3 -m pip install -v -e .
  1. Check the package info:
conda list heisenberg-model

The python3 -m pip install . command is equivalent to the python3 -m setup.py install command.

  • Flags:
    • The -m flag in python3 -m pip enforce the pip version tied to the active environment, i.e, instructs python to run pip as the main module (script).
    • The --no-deps flag ensures that setup.py will not overwrite the conda dependencies that you have already installed using the environment.yml file. In this case, the pip-equivalent packages specified in the requirements.txt file will not be used.
    • The -e flag stands for editable mode (recommended for developers). It installs the package without copying any files to the interpreter directory allowing for source code changes to be instantly propagated to the code library without the need of rebuild and reinstall, however, the python process/kernel will need to be restarted. It sets the pacakge info: Build dev_0 and Channel <develop>. It also creates the heisenberg-model.egg-info file that enables the user to access the package information by: conda list heisenberg-model. For more information, see the setuptools development mode.
    • The -v flag enables progress display (verbose).

Quick test-drive:

python3 heisenberg_model/main/classical_simulation.py
>>> plot
python3 heisenberg_model/main/quantum_simulation.py
>>> State tomography fidelity on fake Jakarta backend = 0.3473 ± 0.0027
>>> State tomography fidelity on real Jakarta backend: Job in the queue...

Alternatively, run the package:

python3
>>> import heisenberg_model as hm
>>> from qiskit.opflow import Zero, One
>>> import math
>>> hm.about()
>>> init_state=(One^One^Zero).to_matrix() # One can pass a numpy.ndarray as well.
>>> evolved=init_state
>>> csim=hm.ClassicalSimulation(trotter_steps=9, time=math.pi, measured_state=evolved, prepared_state=init_state)
>>> csim.run_classical()
>>> qsim=QuantumSimulation(trotter_steps=8, target_time=math.pi, reps=8, nshots=8192)
>>> qsim.fake_fidelity()
>>> qsim.real_fidelity()

Project Description

This repository features a quantum simulation proposed in the 2021 IBM Quantum Awards. The current simulation presented here does not solve the challenge, however, the reader can resort to this project as a guide. The conundrum is to improve the state fidelity of the evolved quantum state starting from the initial state $|110\rangle$ to time t=π using Suzuki-Trotterization decomposition of the unitary time evolution operator under the XXX Heisenberg model Hamiltonian for a system of three interacting spin-1/2 particles ordered along a line (1D chain). The system of particles is to be represented by qubits 5, 3, and 1 in the IBM Quantum's 7-qubit Jakarta processor.

In the noisy intermediate-scale quantum (NISQ) era, there are three main strategies for noise reduction. The first requires an understanding of material science, fabrication, and microwave engineering. The second focus on developing new circuits that are insensitive to noise, and the third strategy revolves around quantum error correction and quantum error mitigation. In the context of error correction, the remaining qubits (0, 2, 4 and 6) of the IBM Jakarta processor can be used as ancillary qubits for realization of syndrome measurements that can reveal information about the noise in the system without collapsing the quantum state of the logical qubits that one wants to encode and protect against noise. Said measurements are tailored to the particular quantum error-correcting code of interest, for example, a parity measurement in a repetition code scheme. In a realistic scenario, however, syndrome measurements can also be noise prone. One of the drawbacks with the repetition code is its limitation in detecting only bit flip (X) errors in the Z-basis, as well as the requirement for qubits to be effectively ordered along a line. A workaround is the surface code to detect both bit-flip (X) errors using plaquete syndrome and phase-flip (Y) errors using a vertex syndrome.

An alternative to error correction is error mitigation. One example is the statistical method known as Clifford Data Regression (CDR) [2], a machine learning-based quantum error mitigation technique provided out-of-the-box in the open-source mitiq library. In the CDR workflow, several near-Clifford approximations of the target quantum circuit are rendered to both a classical simulator and a real quantum hardware. The expectation values obtained from the classical simulation (without noise) and real simulation (with noise) are then used as ground truth and prediction data (hypothesis), respectively, for the training dataset. One caveat: the CDR is conditioned by the fact that quantum circuits must be composed only by gates that can be efficiently simulated in a classical computer (see Gottesman–Knill theorem) in order to train the model in a noise-free environment. A workaround is to decompose the evolution operator with the Hamiltonian of interest into near-Clifford gates using operators (H, CNOT, S) that generate the SU(2) Clifford group plus the Pauli matrices (X, Y, Z) with the corresponding su(2) Lie algebra. Or even to use magic state distillation to implement non-Clifford gates protected from noise. Another approach to avoid magic state distillation might be to combine both error correction and error mitigation.

It is also possible to take advantage of rotational symmetry using local operations (rotation gates). Recall that local operations are represented by single-qubit gates and non-local operations are represented by multi-qubit gates (gates acting on multiple qubits, such as the CNOT gate). Believing that certain rotation paths in the Bloch sphere can be used to avoid noise, a gate $G$ can be given by the following similarity transformation: $RGR^{-1}=G$ iff $R$ and $G$ commute, where $R$ is the Unitary operator (another gate) performing an overall $2\pi$ rotation. Furthermore, if the two commuting matrices are Hermitian, they can be simultaneously diagonalized. Also, recall that Hermitian matrices remain Hermitian under unitary similarity transformations. Moreover, the operator $R$ can be used to find the eigenvectors and eigenvalues of the matrix $G$. With $R^{n}=\mathbb{I}$ (identity), linear algebra states that the eigenvalues of $R$ are n-th roots of unity given by: $\lambda_k = e^{2πki/n}$, for $k=1,\cdots,n$ where $i$ is the imaginary unit.

For the future, this project proposes to investigate two approaches. The first is to design a feedforward neural network architecture to learn a denoising mapping function of the quantum system (hardware). The second approach is to frame the problem as an adaptive circuit, leveraging either a gradient-based (parameter shift rule) or a gradient-free (rotoselect algorithm) optimization for tuning the Euler angles of the parametric quantum gates.

Baseline approach

The baseline approach take into consideration the following features and rule-of-thumbs to mitigate both gate errors and measurement errors during unitary decomposition into quantum gates and transpilation:

  1. Choose the minimum number of Trotter steps that provide the desired state fidelity.
  2. Choose a decomposition where the evolution operator is decomposed into the least amount of native gates to minimize circuit depth and, therefore, gate error in the circuit. This is a challenge in itself.
  3. For non-native gates, use the "conjugation by unitary" operation to represent some of the conjugation by Cliffords in terms of tensor products of Paulis given the fact that Pauli gates share the same set of eigenvalues.
  4. Whenever possible, apply 2-qubit gates between nearest neighbor qubits to avoid non-trivial transpilation (qubit routing).

In step 1, as the number of Trotter steps increases, the simulation becomes more accurate, however, the number of gate operations also increases adding more noise to the quantum circuit. This suggests a prior classical simulation to verify the evolution of the state fidelity as the number of trotter steps increases. In step 4, transpilation converts the gates in the circuit into the native gate set of the particular quantum hardware (processor). The trivial scenario is a Hadamard gate transpiled in terms of a single 1-qubit gate $U(\pi/2,0,\pi)$ with the given Euler angles ($\theta, \phi, \lambda$). However, when the circuit does not follow the hardware graph connectivity (coupling map), qubit routing is required. This procedure is commonly done by moving the state between two qubits using the 2-qubit SWAP gate which is a non-native gate (no direct implementation) in most quantum processors, thus requiring decomposition into CNOT gates. Hence, non-trivial transpilation add extra gates to the original circuit consequently increasing and delocalizing any noise already present. The solution is to avoid, whenever possible, multiple-qubit gates between any non-nearest neighbor physical qubits etched into the processor.

References  

[1] Nielsen MA, Chuang IL. 2010. Quantum Computation and Quantum Information. New York: Cambridge Univ. Press. 10th Anniv. Ed.

  • Corollary 4.2, pg. 176: Gate decomposition.
  • Theorem 4.3, pg. 207: Trotter formula.
  • Chapter 4.7.2, pg. 206: The quantum simulation algorithm.
  • Chapter 9.2.2, pg. 409: State fidelity.

[2] Griffiths, David J., and Darrell F. Schroeter. Introduction to quantum mechanics. Cambridge University Press, 2018.

  • Section 3.2.3, pg. 103: scalar wave function.

[3] ibmq-qsim-challenge.ipynb.

[4] ibmq-qsim-sup-mat.ipynb.

License

This work is licensed under a Apache License 2.0 license.


Created and maintained by @camponogaraviera.

ibm2021-open-science-prize's People

Contributors

camponogaraviera avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.