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:
- (optional) Create a virtual environment to isolate the installation:
python3 -m venv hhl_venv
source hhl_venv/bin/activate
- Clone the git repository:
git clone https://github.com/nelimee/quantum-hhl-4x4.git
cd quantum-hhl-4x4
- Install the requirements:
pip install -r requirements.txt
- Install the HHL implementation:
python3 setup.py install
The main directory contains:
- A
LICENSE
file explaining under which license this code is distributed. For more information go read the Notes about the license section. - This README file.
- A
requirements.txt
file that can be used to install all the dependencies of the software. - A
setup.py
file used to install the code. - The
hhl4x4
directory which contains all the Python code.
The 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:
- The
custom_gates
folder contains the implementation of user-defined quantum gates like the doubly-controlledZ
gate (aZ
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 filehhl4x4.py
. - The
utils
folder contains 2 python files:endianness.py
used to take care of the registers endianness andregisters.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 successfulpython setup.py install
) you can run this file by typing the commandHHL4x4
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 successfulpython setup.py install
) you can run this file by typing the commandHHL4x4_optimise_parameters
in your terminal. You can see the available options withHHL4x4_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:
- Adrien Suau, adrien.suau@cerfacs.fr as the main author.
- CERFACS, cerfacs.fr as a contributor.
If you have any doubt, please read the license. If you still have doubts or questions, please send me a mail at adrien.suau@cerfacs.fr.