Appendix A: Installation of Related SDKs¶
Please install the required runtime environments listed below; this needs to be done once (if you encounter issues when using the cloud platform, please pay attention to platform notifications or update the relevant runtime environments to the latest versions).
It is recommended to install using pip or Python commands, preferably in a command-line interface. The installation commands shown here are for reference only, as installation success may vary depending on the environment configuration.
Video references
In the Jupyter Python environment on the Quantum Innovation Research Institute's cloud platform, all the following environments are pre-installed, and users do not need to install them.
A.1 Install the ezQgd SDK package¶
In a Python environment, install the SDK package for remote access to the quantum computers at QuantumCTek's Cloud Platform.
If you haven't installed ezQgd before, please click the cursor into the command line below and simultaneously press Ctrl+Enter to run the installation command. The subsequent command execution method is the same.
pip install --upgrade ezQgd -i https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: The directory '/home/jovyan/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you should use sudo's -H flag. Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Requirement already satisfied: ezQgd in /opt/conda/lib/python3.9/site-packages (1.0.2) Collecting ezQgd Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ee/35/e5e2227b049be6893c47ec4d3a225dd3e795f3b2f06b694c96901b8cb20f/ezQgd-1.0.6-py3-none-any.whl (17 kB) Requirement already satisfied: isqmap in /opt/conda/lib/python3.9/site-packages (from ezQgd) (0.2) Requirement already satisfied: numpy in /opt/conda/lib/python3.9/site-packages (from ezQgd) (1.24.3) Requirement already satisfied: requests in /opt/conda/lib/python3.9/site-packages (from ezQgd) (2.26.0) Requirement already satisfied: sabreMapper in /opt/conda/lib/python3.9/site-packages (from ezQgd) (0.1.0) Requirement already satisfied: beautifulsoup4 in /opt/conda/lib/python3.9/site-packages (from ezQgd) (4.12.2) Requirement already satisfied: soupsieve>1.2 in /opt/conda/lib/python3.9/site-packages (from beautifulsoup4->ezQgd) (2.4) Requirement already satisfied: qiskit in /opt/conda/lib/python3.9/site-packages (from isqmap->ezQgd) (0.38.0) Requirement already satisfied: matplotlib in /opt/conda/lib/python3.9/site-packages (from isqmap->ezQgd) (3.7.1) Requirement already satisfied: networkx in /opt/conda/lib/python3.9/site-packages (from isqmap->ezQgd) (3.1) Requirement already satisfied: certifi>=2017.4.17 in /opt/conda/lib/python3.9/site-packages (from requests->ezQgd) (2021.10.8) Requirement already satisfied: urllib3<1.27,>=1.21.1 in /opt/conda/lib/python3.9/site-packages (from requests->ezQgd) (1.26.7) Requirement already satisfied: charset-normalizer~=2.0.0 in /opt/conda/lib/python3.9/site-packages (from requests->ezQgd) (2.0.0) Requirement already satisfied: idna<4,>=2.5 in /opt/conda/lib/python3.9/site-packages (from requests->ezQgd) (3.1) Requirement already satisfied: retworkx in /opt/conda/lib/python3.9/site-packages (from sabreMapper->ezQgd) (0.12.1) Requirement already satisfied: qiskit-aer==0.11.0 in /opt/conda/lib/python3.9/site-packages (from qiskit->isqmap->ezQgd) (0.11.0) Requirement already satisfied: qiskit-terra==0.21.2 in /opt/conda/lib/python3.9/site-packages (from qiskit->isqmap->ezQgd) (0.21.2) Requirement already satisfied: qiskit-ibmq-provider==0.19.2 in /opt/conda/lib/python3.9/site-packages (from qiskit->isqmap->ezQgd) (0.19.2) Requirement already satisfied: scipy>=1.0 in /opt/conda/lib/python3.9/site-packages (from qiskit-aer==0.11.0->qiskit->isqmap->ezQgd) (1.10.1) Requirement already satisfied: python-dateutil>=2.8.0 in /opt/conda/lib/python3.9/site-packages (from qiskit-ibmq-provider==0.19.2->qiskit->isqmap->ezQgd) (2.8.2) Requirement already satisfied: websocket-client>=1.0.1 in /opt/conda/lib/python3.9/site-packages (from qiskit-ibmq-provider==0.19.2->qiskit->isqmap->ezQgd) (1.5.1) Requirement already satisfied: websockets>=10.0 in /opt/conda/lib/python3.9/site-packages (from qiskit-ibmq-provider==0.19.2->qiskit->isqmap->ezQgd) (11.0.1) Requirement already satisfied: requests-ntlm>=1.1.0 in /opt/conda/lib/python3.9/site-packages (from qiskit-ibmq-provider==0.19.2->qiskit->isqmap->ezQgd) (1.1.0) Requirement already satisfied: ply>=3.10 in /opt/conda/lib/python3.9/site-packages (from qiskit-terra==0.21.2->qiskit->isqmap->ezQgd) (3.11) Requirement already satisfied: psutil>=5 in /opt/conda/lib/python3.9/site-packages (from qiskit-terra==0.21.2->qiskit->isqmap->ezQgd) (5.9.4) Requirement already satisfied: stevedore>=3.0.0 in /opt/conda/lib/python3.9/site-packages (from qiskit-terra==0.21.2->qiskit->isqmap->ezQgd) (5.0.0) Requirement already satisfied: tweedledum<2.0,>=1.1 in /opt/conda/lib/python3.9/site-packages (from qiskit-terra==0.21.2->qiskit->isqmap->ezQgd) (1.1.1) Requirement already satisfied: symengine>=0.9 in /opt/conda/lib/python3.9/site-packages (from qiskit-terra==0.21.2->qiskit->isqmap->ezQgd) (0.9.2) Requirement already satisfied: dill>=0.3 in /opt/conda/lib/python3.9/site-packages (from qiskit-terra==0.21.2->qiskit->isqmap->ezQgd) (0.3.6) Requirement already satisfied: sympy>=1.3 in /opt/conda/lib/python3.9/site-packages (from qiskit-terra==0.21.2->qiskit->isqmap->ezQgd) (1.11.1) Requirement already satisfied: rustworkx==0.12.1 in /opt/conda/lib/python3.9/site-packages (from retworkx->sabreMapper->ezQgd) (0.12.1) Requirement already satisfied: kiwisolver>=1.0.1 in /opt/conda/lib/python3.9/site-packages (from matplotlib->isqmap->ezQgd) (1.4.4) Requirement already satisfied: contourpy>=1.0.1 in /opt/conda/lib/python3.9/site-packages (from matplotlib->isqmap->ezQgd) (1.0.7) Requirement already satisfied: importlib-resources>=3.2.0 in /opt/conda/lib/python3.9/site-packages (from matplotlib->isqmap->ezQgd) (5.4.0) Requirement already satisfied: cycler>=0.10 in /opt/conda/lib/python3.9/site-packages (from matplotlib->isqmap->ezQgd) (0.11.0) Requirement already satisfied: fonttools>=4.22.0 in /opt/conda/lib/python3.9/site-packages (from matplotlib->isqmap->ezQgd) (4.39.3) Requirement already satisfied: pillow>=6.2.0 in /opt/conda/lib/python3.9/site-packages (from matplotlib->isqmap->ezQgd) (9.5.0) Requirement already satisfied: pyparsing>=2.3.1 in /opt/conda/lib/python3.9/site-packages (from matplotlib->isqmap->ezQgd) (2.4.7) Requirement already satisfied: packaging>=20.0 in /opt/conda/lib/python3.9/site-packages (from matplotlib->isqmap->ezQgd) (21.2) Requirement already satisfied: zipp>=3.1.0 in /opt/conda/lib/python3.9/site-packages (from importlib-resources>=3.2.0->matplotlib->isqmap->ezQgd) (3.6.0) Requirement already satisfied: six>=1.5 in /opt/conda/lib/python3.9/site-packages (from python-dateutil>=2.8.0->qiskit-ibmq-provider==0.19.2->qiskit->isqmap->ezQgd) (1.15.0) Requirement already satisfied: cryptography>=1.3 in /opt/conda/lib/python3.9/site-packages (from requests-ntlm>=1.1.0->qiskit-ibmq-provider==0.19.2->qiskit->isqmap->ezQgd) (35.0.0) Requirement already satisfied: ntlm-auth>=1.0.2 in /opt/conda/lib/python3.9/site-packages (from requests-ntlm>=1.1.0->qiskit-ibmq-provider==0.19.2->qiskit->isqmap->ezQgd) (1.5.0) Requirement already satisfied: pbr!=2.1.0,>=2.0.0 in /opt/conda/lib/python3.9/site-packages (from stevedore>=3.0.0->qiskit-terra==0.21.2->qiskit->isqmap->ezQgd) (5.11.1) Requirement already satisfied: mpmath>=0.19 in /opt/conda/lib/python3.9/site-packages (from sympy>=1.3->qiskit-terra==0.21.2->qiskit->isqmap->ezQgd) (1.3.0) Requirement already satisfied: cffi>=1.12 in /opt/conda/lib/python3.9/site-packages (from cryptography>=1.3->requests-ntlm>=1.1.0->qiskit-ibmq-provider==0.19.2->qiskit->isqmap->ezQgd) (1.14.6) Requirement already satisfied: pycparser in /opt/conda/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=1.3->requests-ntlm>=1.1.0->qiskit-ibmq-provider==0.19.2->qiskit->isqmap->ezQgd) (2.20) Installing collected packages: ezQgd Attempting uninstall: ezQgd Found existing installation: ezQgd 1.0.2 Uninstalling ezQgd-1.0.2: Successfully uninstalled ezQgd-1.0.2 Successfully installed ezQgd-1.0.6 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv Note: you may need to restart the kernel to use updated packages.
If you see success messages in the output, it means the installation was successful. After a successful update installation, you'll need to restart the Python kernel to ensure the latest package takes effect.
Installing collected packages: pyezQ
Successfully installed pyezQ-1.0.1
The current version of pyezQ is 1.0.1, and the SDK for high-performance quantum computers in the internal test devices may receive frequent updates. Please make sure to update to the latest version of the SDK in a timely manner.
A.2 Install the Quingo compiler¶
In a Python environment, install the Quingo compiler
If you haven't installed the Quingo compiler, please execute the following two commands in sequence.
pip install --upgrade quingo -i https://pypi.tuna.tsinghua.edu.cn/simple
#Install Quingo Runtime
# If the installation is successful, you may see the following output:
# Note: you may need to restart the kernel to use updated packages.
File "/tmp/ipykernel_199/396256830.py", line 1 pip install --upgrade quingo -i https://pypi.tuna.tsinghua.edu.cn/simple ^ SyntaxError: invalid syntax
from quingo.install_quingoc import *
default_path = Path.home() / '.quingo'
quingoc_path = distutils.spawn.find_executable(
'quingoc', str(default_path))
if quingoc_path is None:
quingoc_path = distutils.spawn.find_executable('quingoc')
if quingoc_path is None:
download_and_install_latest_quingoc()
else:
if quingoc_path[0] != '"':
quingoc_path = '"{}"'.format(quingoc_path)
if check_update(quingoc_path):
download_and_install_latest_quingoc(pathlib.Path(quingoc_path))
#Install the Quingo compiler
If you are using a non-JupyterLab environment, the installation process involves executing the following two lines directly in the command line.
pip install --upgrade quingo
python -m quingo.install_quingoc
Configure the Quingo compiler path
from quingo.core.compiler_config import set_mlir_compiler_path
import os
# Please modify the path within the parentheses below to the directory where the 'quingoc' executable is located. Make sure that the 'quingoc' executable is in this directory.
# On Linux and Mac, this path may be ~/.local/bin/quingoc
set_mlir_compiler_path(os.path.expanduser('~/.local/bin/quingoc'))
# On Windows, this path may be ~\.quingo\quingoc.exe
# set_mlir_compiler_path(os.path.expanduser(r'~\.quingo\quingoc.exe'))
Add the std_qcis.qu file to the compiler's default search path
This part will be automatically provided with different version releases. If you do not receive a prompt indicating that the std_qcis.qu file cannot be found, you may proceed without installation.
from pathlib import Path
std_qcis = '''
// measurement
opaque MEASURE (qs: qubit[]): bool[]; // measure a list of qubits.
opaque measure (q: qubit): bool; // measure a list of qubits.
// single-qubit gates
opaque X (q:qubit): unit; // Rx( pi )
opaque X2P (q:qubit): unit; // Rx( pi/2)
opaque X2M (q:qubit): unit; // Rx(-pi/2)
opaque RX(q: qubit, angle: double) : unit;
opaque Y (q:qubit): unit; // Ry( pi )
opaque Y2P (q:qubit): unit; // Ry( pi/2)
opaque Y2M (q:qubit): unit; // Ry(-pi/2)
opaque RY(q: qubit, angle: double) : unit;
opaque RZ (q:qubit, angle:double): unit; // Rz(angle)
opaque Z (q:qubit): unit; // Rz( pi )
opaque Z2P (q:qubit): unit; // Rz( pi/2)
opaque Z2M (q:qubit): unit; // Rz(-pi/2)
opaque Z4P (q:qubit): unit; // Rz( pi/4)
opaque Z4M (q:qubit): unit; // Rz(-pi/4)
opaque H (q:qubit): unit; // Hadamard
opaque S(q: qubit) : unit;
opaque SD(q: qubit) : unit;
opaque T(q: qubit) : unit;
opaque TD(q: qubit) : unit;
// This operation performs the following rotation on the state:
// - the angle between the positive x-axis and the rotation axis is `azimuth`;
// - the rotation angle is `angle`.
opaque XYARB (q:qubit, azimuth:double, angle:double): unit;
// two-qubit gates
opaque CZ (control_qubit:qubit, target_qubit:qubit ): unit; // CPhase gate
'''
inc_dir = Path.home() / '.quingo' / 'include'
inc_dir.mkdir(parents=True, exist_ok=True)
std_qcis_fn = inc_dir / 'std_qcis.qu'
with std_qcis_fn.open('w') as f:
f.write(std_qcis)
#Write the std_qcis.qu file into the compiler search path, or you can directly copy this file to the specified location.
A.3 Install the isQ compiler¶
In a Python environment, install the isQ compiler
Official isQ dedicated tutorial, see it here: http://www.arclightquantum.com/isq-core/index.html
If you haven't installed the isQ compiler, please execute the following commands in command-line mode.
pip install --upgrade isqopen -i https://pypi.tuna.tsinghua.edu.cn/simple