The Variational Quantum Linear Solver, or the VQLS is a variational quantum algorithm that utilizes VQE in order to solve systems of linear equations more efficiently than classical computational algorithms.
We implemented the VQLS code by referring to the page below.
https://qiskit.org/textbook/ch-paper-implementations/vqls.html
We improved the performance of the existing implementation based on qiskit, by using Mathematica and SymPy. It is expected that our codebase can be utilized in various ways in further research such as in the field of Quantum Finance, Quantum Chemistry, Quantum Machine Learning, and Quantum Optimization.
The overall procedure is as follows:
- Simplify the circuit code written with Mathematica via the
Simplify
function. - Export the code in LaTeX format.
- Import the code to SymPy using latex2sympy.
The detailed process is described below.
Our code consists of two main parts:
The first part is the vqls.py
file which is provided by the qiskit notebook, and the latter is the customVQLS.py
file written by us.
The main difference is the format of a circuit. When vqls.py
applys a quantum circuit on the qiskit itself, customVQLS.py
uses Mathematica and SymPy to implement the circuit. By pipelining these two methods, we could reduce the computational cost and improve the overall performance.
- Install ANTLR 4:
pip3 install antlr4-python3-runtime==4.9
-
Refer to the following link and finish the process:
https://github.com/antlr/antlr4/blob/master/doc/getting-started.md
-
Finally:
antlr4 PS.g4 -o gen
Step 2. Run customVQLS.py
- If you want to run the code in default settings, go the
/latex2sympy-master
directory and execute:
py customVQLS.py
-
If you want to run a custom code, proceed as follows:
- Write the circuit in Mathematica.
- Export the
.mml
file the.txt
format. - Converting the file via pandoc:
pandoc your_exporting_file_here.txt -f html -t latex -o htest_tex_short.tex
- Remove the following pairs from the the converted file:
- the
\(
,\)
pairs, - the
\left
,\right
pairs, and - the
{❘
,❘}
pairs.
- Caveat: The 'bar's above are not typical
| (U+007C)
but 'light vertical bar's❘ (U+2758)
.
- the
- Put the created circuit in
latex2sympy-master/result
directory. - Run the customVQLS.py.
Hayeon Kim and Jaehoon Hahm