A Python-based Quantum Control Instruction Set (QCIS) simulator developed by Zhihao Wu and Xiang Fu from QUANTA@NUDT.
Actually, PyQCISim is more a QCIS parser than a simulator. PyQCISim implements a QCIS parser which translates QCIS files into an internal representation of quantum operations. These quantum operations are then sent to another simulator to simulate the quantum state evolution. Currently, the open-source density matrix simulator QuantumSim is used as the backend. Other quantum state simulators will also be added in the future.
Installation
Install from pip
pip install pyqcisim
Install from repository
Clone (or download) this repository to your computer, and pip install it using the following commands:
git clone https://gitee.com/hpcl_quanta/pyqcisim
cd pyqcisim
pip install -e .
Note, if your computer also has python2 installed, you might require to replace pip with pip3.
Verify the installation under the root directory of pyqcisim:
pytest -ra
A successful installation should see all tests passed.
Note. if your computer also has python2 installed, you might require to replace pytest with pytest-3.
Usage
Direct QCIS simulation in command line
You can use the file pyqcisim/simulate_qcis.py to directly simulate a QCIS file:
If there is no measurement in the circuit, then the result will be empty.
The entire circuit will be simulated for $n$ times, where $n$ is default to 1000 and can be set via the optional parameter num_shots when calling simulate().
If you have any suggestions or encounter any problems in using PyQCISim, please feel free to post an issue at https://gitee.com/hpcl_quanta/pyqcisim/issues, or send an email to Xiang Fu (xiangfu at quanta dot org dot cn)
Currently Supported QCIS and the Syntax
Note, PyQCISim supports a super set of QCIS instructions as supported by the current quantumcomputer.ac.cn.
The user should pay attention to instructions not supported by quantumcomputer.ac.cn.
In the following, we adopt the following conventions:
[qubit], [control_qubit], [target_qubit] are IDENTIFIERs
[theta] $\in [-\pi, \pi]$
[phi] $\in [-\pi, \pi]$
Rx/y/z(θ): rotate the target qubit for $\theta$-radius angle along the $x/y/z$-axis.
Rn^(θ): rotate the target qubit for $\theta$-radius angle along the $\hat{n}$-direction.
PyQCISim
Introduction
A Python-based Quantum Control Instruction Set (QCIS) simulator developed by Zhihao Wu and Xiang Fu from QUANTA@NUDT.
Actually, PyQCISim is more a QCIS parser than a simulator. PyQCISim implements a QCIS parser which translates QCIS files into an internal representation of quantum operations. These quantum operations are then sent to another simulator to simulate the quantum state evolution. Currently, the open-source density matrix simulator QuantumSim is used as the backend. Other quantum state simulators will also be added in the future.
Installation
Install from pip
Install from repository
Clone (or download) this repository to your computer, and pip install it using the following commands:
Note, if your computer also has python2 installed, you might require to replace
pip
withpip3
.Verify the installation under the root directory of pyqcisim:
A successful installation should see all tests passed. Note. if your computer also has python2 installed, you might require to replace
pytest
withpytest-3
.Usage
Direct QCIS simulation in command line
You can use the file
pyqcisim/simulate_qcis.py
to directly simulate a QCIS file:You can use the following command to see its various parameters:
Call PyQCISim in Python
First, import the simulator, instantiate
PyQCISim
, and compile the given QCIS program:Second, you can start simulate the program using either the default
one_shot
mode:or using the
final_state
mode:These two mode has some difference:
one_shot
mode:num_shots
when callingsimulate()
.(['qA', 'qB'], {'00': 0, '01': 1000, '10': 0, '11': 0})
final_state
mode:M qB
in the above code:{'classical': {'qA': 1}, 'quantum': (['qB'], array([1.+0.j, 0.+0.j]))}
Problems and Feedback
If you have any suggestions or encounter any problems in using PyQCISim, please feel free to post an issue at https://gitee.com/hpcl_quanta/pyqcisim/issues, or send an email to Xiang Fu (xiangfu at quanta dot org dot cn)
Currently Supported QCIS and the Syntax
Note, PyQCISim supports a super set of QCIS instructions as supported by the current quantumcomputer.ac.cn. The user should pay attention to instructions not supported by quantumcomputer.ac.cn.
In the following, we adopt the following conventions:
[qubit]
,[control_qubit]
,[target_qubit]
are IDENTIFIERs[theta]
$\in [-\pi, \pi]$[phi]
$\in [-\pi, \pi]$Single Qubit Operation Instructions
X [qubit]
Y [qubit]
Z [qubit]
H [qubit]
S [qubit]
SD [qubit]
T [qubit]
TD [qubit]
X2P [qubit]
X2M [qubit]
Y2P [qubit]
Y2M [qubit]
RX [qubit] [theta]
RY [qubit] [theta]
RZ [qubit] [theta]
XY [qubit] [phi]
XY2P [qubit] [phi]
XY2M [qubit] [phi]
RXY [qubit] [phi] [theta]
XYARB [qubit] [phi] [theta]
RYX
Z2P [qubit]
Z2M [qubit]
Z4P [qubit]
Z4M [qubit]
Two Qubit Operation Instructions
CZ [control_qubit] [target_qubit]
CNOT [control_qubit] [target_qubit]
SWP [control_qubit] [target_qubit]
SSWP [control_qubit] [target_qubit]
ISWP [control_qubit] [target_qubit]
SISWP [control_qubit] [target_qubit]
Measurement Instructions
M [qubit_1] ... [qubit_n]
MEASURE [qubit_1] ... [qubit_n]
Ancillary Instructions
B
Miscellaneous
\n
.#
.