A quantum computing simulator.
To do some computation one has to build a quantum circuit and apply it to a state. States are created using pyqcs.State.new_zero_state(<number of qbits>).
Circuits are built from the fundamental gates (see Built-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:
X(1) CZ(1,0) H(0)
Applying a circuit to a state is done using multiplication:
from pyqcs import State state = State.new_zero_state(2) resulting_state = circuit * state
PyQCS has two fundamental classes for simulating the quantum computation: A state which represents the total simulator state at a single point in quasi-time  and gate circuits that can be applied to such a state; yielding a new state.
A PyQCS state contains a representation of the quantum mechanical state in which the simulator is; using a numpy array. The application of a gate will return a new state with a changed qm state.
The state also contains a representation of the last measurement and information which qbits have been measured. This information will be used by classical parts of an algorithm.
A PyQCS gate is essentially a function mapping a 2**N dimensional cdouble array and an N dimensional double array to a 2**N dimensional cdouble array, an N dimensional double array and a int64 scalar.
PyQCS gates usually are implemented as objects with a numpy ufunc backend and some data.
Circuits are way one describes how the gates are applied to the state. Even single gate applications are described as circuits as those are more convenient to use. Gate circuits can also be used to optimize circuits in an abstract way and implement the error simulation.
Gate circuit builders are a more abstract way to construct gate circuits and are used typically to reduce the effort to construct a circuit. When called a circuit builder returns a new circuit with the given parameters. Typical cases are circuits that can be applied to different qbits.
PyQCS currently has the following gates built-in:
- Pauli-X or NOT gate. Flips the respective qbit.
- Hadamard gate.
- C = CX
- CNOT (controlled NOT) gate. Flips the act-qbit, if the control-qbit is set.
- R, Rz or R_phi, the rotation gate. Rotates the respective qbit around a given angle.
- Measurement gate: this gate measures the respective gate, collapsing the wave function and storing the result in the classical part of the state.
- Pauli-Z gate.
- B = CZ
- Controlled Z gate.
- Add a subclass of pyqcs.state.state.BasicState that has an improved __str__ method.
- Write lot’s of documentation.
- Add more tests.
- Add a NoisyGateListExecutor that allows to implement a noise model.
- Allow states to be multiplied with each other to compute the overlap.
|||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.|
Release history Release notifications
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size pyqcs-2.0.1.tar.gz (312.7 kB)||File type Source||Python version None||Upload date||Hashes View hashes|