Running Quantum Computer Simulators on MateriApps LIVE!
Last Update:2024/02/06
1. Introduction
Various quantum computer simulators are featured on MateriApps. This review describes how to install them (blueqat, Cirq, Intel Quantum Simulator, OpenFermion, OpenJij, Qiskit, Qulacs, QuTiP, Strawberry Fields) and run tutorials on MateriApps LIVE!
Most tutorials for Python-based simulators assume execution in Jupyter Notebook or Google Colab, but here, we start the Python interpreter on the command line (python3 or ipython3 command) and run it, assuming batch processing as well.
2. Preparation of venv environment
Here, we will create a new Pyrhon venv environment and install the quantum computer simulator in it. Open a terminal and execute the following:
python3 -m venv $HOME/qc
source $HOME/qc/bin/activate
pip3 install ipython numpy matplotlib pylatexenc
After executing activate
, the shell prompt will be changed as (qc) ...
. This indicates that you are in the venv environment. To exit from the venv environment, use deactivate
command.
3. Installation of required libraries
sudo apt-get update
sudo apt-get -y install libboost-dev pybind11-dev libssl-dev libffi-dev
4. Installation of blueqat, Cirq, OpenFermion, OpenJij, Qiskit, Qulacs (Python version), QuTiP, and Strawberry Fields
Use pip3 for installation. Installation is completed with one line.
pip3 install blueqat cirq openfermion openjij qiskit qulacs qutip strawberryfields
5. Installation of Intel Quantum Simulator
Clone the source code from GitHub and compile it. The patch on the second line is required to compile with MateriApps LIVE! (Docker version) for Apple Silicon.
(cd $HOME/qc && git clone https://github.com/iqusoft/intel-qs.git)
(cd $HOME/qc/intel-qs && curl -sL https://github.com/cmsi/MateriAppsPackages/raw/main/qc/intel-qs.patch | patch -p1)
mkdir $HOME/qc/intel-qs/build
(cd $HOME/qc/intel-qs/build && cmake -DIqsPython=ON .. && make)
cp -fp $HOME/qc/intel-qs/include/* $HOME/qc/include
cp -rp $HOME/qc/intel-qs/build/lib/*.so $HOME/qc/lib/$(python -c "import sys; print('python{}.{}'.format(sys.version_info.major, sys.version_info.minor))")/site-packages
ln -s $HOME/qc/lib/$(python -c "import sys; print('python{}.{}'.format(sys.version_info.major, sys.version_info.minor))")/site-packages/libiqs.so $HOME/qc/lib/
6. Installation of Qulacs (C++ version)
Clone the source code from GitHub and compile it.
(cd $HOME/qc && git clone https://github.com/qulacs/qulacs.git)
mkdir $HOME/qc/qulacs/build
(cd $HOME/qc/qulacs/build && cmake -DCMAKE_BUILD_TYPE=Release .. && make)
cp -rfp $HOME/qc/qulacs/include/* $HOME/qc/include/
cp -fp $HOME/qc/qulacs/lib/* $HOME/qc/lib/
7. Running tutorials
For Python-base simulators, execute python3
or ipython3
in the terminal window, and execute commands by copying and pasting them from the tutorial.
When you draw a figure and only the message, like <Figure size 789.163x785.944 with 1 Axes>
is displayed, but the figure is not actually displayed, execute _.show()
immediately after the result, and the figure should be displayed. Also, if you see <IPython.core.display.Math object>
and no equation is displayed, you can execute _.data
to display its LaTeX source code.
The following tutorials (except for those using real quantum computers) have been tested on MateriApps LIVE!
blueqat: Blueqat Tutorials
Cirq: Cirq basics
Intel Quantum Simulator: Getting started with Intel Quantum Simulator
- https://github.com/intel/intel-qs/blob/master/tutorials/get_started_with_IQS.cpp
- https://github.com/intel/intel-qs/blob/master/tutorials/get_started_with_IQS.ipynb
- How to compile a C++ sample program:
g++ -O3 -I${HOME}/qc/include -Wl,--rpath ${HOME}/qc/lib -L${HOME}/qc/lib example.C -o example -liqs
Qiskit: Learn Quantum Computation using Qiskit
- English: https://qiskit.org/textbook/preface.html
- 日本語: https://qiskit.org/textbook/ja/preface.html
- Installation of tutorial materials:
pip3 install git+https://github.com/qiskit-community/qiskit-textbook.git#subdirectory=qiskit-textbook-src
Qiskit: Getting Started with Qiskit
Qiskit: Quantum Computing Workbook (in Japanese)
- https://utokyo-icepp.github.io/qc-workbook/welcome.html
- 単純な量子回路をゼロから書く
- Installation of exercise materials:
pip3 install pylatexenc tabulate (cd $HOME && git clone https://github.com/UTokyo-ICEPP/qc-workbook.git) ln -s $HOME/qc-workbook/source/qc_workbook $HOME
OpenFermion: Introduction to OpenFermion
OpenJij: OpenJij Introduction
Qulacs: Python Tutorial
Qulacs: C++ Tutorial
- http://docs.qulacs.org/en/latest/intro/4.2_cpp_tutorial.html
- How to compile a C++ sample program:
g++ -O3 -fopenmp -I${HOME}/qc/include -L${HOME}/qc/lib example.C -o example -lvqcsim_static -lcppsim_static -lcsim_static