This repository contains an implementation of the HHL algorithm for a specific 4 x 4 matrix:
A = 1/4 * numpy.array([[15, 9, 5, -3],
[9, 15, 3, -5],
[5, 3, 15, -9],
[-3, -5, -9, 15]])
The implementation is inspired from the paper Quantum Circuit Design for Solving Linear Systems of Equations, written by Yudong Cao, Anmer Daskin, Steven Frankel and Sabre Kais.
The installation procedure is composed of multiple steps, some of them being optional:
python3 -m venv hhl_venv
source hhl_venv/bin/activate
git clone https://github.com/nelimee/quantum-hhl-4x4.git
cd quantum-hhl-4x4
pip install -r requirements.txt
python3 setup.py install
The main directory contains:
LICENSE
file explaining under which license this code is distributed.
For more information go read the Notes about the license section.requirements.txt
file that can be used to install all the dependencies
of the software.setup.py
file used to install the code.hhl4x4
directory which contains all the Python code.hhl4x4
folderThe hhl4x4
folder contains all the Python code used to implement the HHL algorithm
for the matrix A. It is organised in 2 folders and 3 python files:
custom_gates
folder contains the implementation of user-defined quantum gates
like the doubly-controlled Z
gate (a Z
gate controlled by 2 qubits) or the
controlled Rzz gate (a controlled global phase shift).
The HHL algorithm is implemented a user-defined quantum gate in the file hhl4x4.py
.utils
folder contains 2 python files: endianness.py
used to take care of
the registers endianness and registers.py
that implements wrapper around the base
register classes used by Qiskit.4x4.py
: the full implementation of the HHL algorithm. Once the software is installed
(after a successful python setup.py install
) you can run this file by typing the
command HHL4x4
in your terminal.optimise_parameters.py
: the script used to find the best parameters for the Hamiltonian
simulation part. Once the software is installed (after a successful python setup.py install
)
you can run this file by typing the command HHL4x4_optimise_parameters
in your terminal.
You can see the available options with HHL4x4_optimise_parameters --help
.Note: The HHL4x4
command or the 4x4.py script will generate the file 4x4.qasm
containing
the OpenQASM code of the implemented HHL algorithm in the current directory. A histogram visualisation
of the final quantum state will also pop at the end of the program.
This software is licensed under the CeCILL-B license. The CeCILL-B license enforce the obligation for anyone who want to use this software (in any way) to cite the original authors and source.
If you want to use this software, please cite:
If you have any doubt, please read the license. If you still have doubts or questions, please send me a mail at [email protected].