Package: pyqcs
ContentsLinksWhat Is PyQCS?Using PyQCSBuilt-in GatesUsing the C++ BackendTODOsLinksthe github repositorythe pypi repositorysome examples on githubWhat Is PyQCS?PyQCS is a Quantum Computing Simulator built for physics. It currently features
two simulator backends for different purposes, and a way to construct circuits
in a relatively readable manner.By default PyQCS employs a relatively slow simulator backend using dense state
vectors. Note that any implementation using dense state vectors shows
exponential growth in the number of qbits. Therefore this simulator backend is
limited to qbit numbers  below 30 for reasonable performance. For simulations
requiring more qbits we recommend using a high performance framework, such asGPT’s QIS module.The second backend uses a graphical state representation (see for instancearXiv:quant-ph/0504117) which
allows for the simulation of stabilizer states and -circuits. The graphical
simulator is considerably faster, in particular it does not exhibit exponential
growth in the number of qbits. The graphical states are available aspyqcs.graph.state.GraphState.Unlike other simulators PyQCS focuses on the state: Users start from a state, modify
the state (using circuits) and then either look at the state or sample from the state.
This direct access to the state is useful when debugging circuits or when considering
physical problems. However, it can slow down compuations.Using PyQCSTo do some computation one has to build a quantum circuit and apply it to a state.
States are created usingpyqcs.State.new_zero_state(<numberof qbits>).Circuits are built from the fundamental gates (seeBuilt-in Gates) by joining them
together using the|operator:from pyqcs import H, CX, X

circuit = H(0) | CX(1, 0) | X(1)The usage of the|is in analogy to the UNIX pipe: gates are applied from left to
right. This is in agreement with the Feynman quantum circuit diagrams.Note: the circuit above would have the following matrix representation:\begin{equation*}
X_1 CZ_{1,0} H_0
\end{equation*}Applying a circuit to a state is done using multiplication:from pyqcs import State

state = State.new_zero_state(2)
resulting_state = circuit * stateNew inv2.2.0is thecircuitpngfunction that allows displaying circuits as PNGs
(using apdflateximplementation andimagemagick):from pyqcs import H, CX, circuitpng
circuit = (H(1) | H(2)) | CX(2, 1) | (H(1) | H(2))
circuitpng(circuit)Built-in GatesPyQCS currently has the following gates built-in:XPauli-X or NOT gate. Flips the respective qbit.HHadamard gate.CXCNOT (controlled NOT) gate. Flips the act-qbit, if the control-qbit is set.RR, Rz or R_phi, the rotation gate. Rotates the respective qbit around a given angle.MMeasurement gate: this gate measures the respective gate, collapsing the wave function
and storing the result in the classical part of the state.ZPauli-Z gate.SClifford-S gate.CZControlled Z gate.Using the C++ BackendStarting from version 3.0.0 PyQCS has a pure C++ backend omitting the
previously used numpy arrays. The python package uses handwritten adapters to
this backend.The backend can be used as a stand-alone library. It can be built and installed
using thesrc/backend/meson.buildfile. Its usage is a bit different from
what one would usually expect from a simulator: Operations like measurement are
not implemented explicitly but should be implemented by the user using a random
number generator and the providedcompute_amplitudemethods.Besides that the code should be pretty much self-explaining. See the adapter
code for some ideas how to use the backend.TODOsAdd pretty printers for states.Write lot’s of documentation.Add more tests.Add a noise model.Add a way to export circuits to GPT’s QIS module.[1]Real quantum computers have an intrinsic time evolution. This is omitted
in PyQCS and reintroduced for error simulation. PyQCS therefore operates
on a discrete quasi-time with every time-site being before or after a gate
application.