mindquantum.core.gates#

Gate module that provides different quantum gate.

Base Class#

API Name

Description

BasicGate(name, n_qubits)

BasicGate is the base class of all gates.

NoneParameterGate(...)

Base class for non-parametric gates.

ParameterGate(pr, ...)

Gate that is parameterized.

QuantumGate(name, ...)

Base class for quantum gates.

NoiseGate(name, n_qubits)

Noise gate class.

Quantum Gate#

API Name

Description

Math

CNOTGate()

Control-X gate.

FSim(theta, phi)

FSim gate represent fermionic simulation gate.

\[\begin{split}{\rm FSim}(\theta, \phi) = \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & \cos(\theta) & -i\sin(\theta) & 0\\ 0 & -i\sin(\theta) & \cos(\theta) & 0\\ 0 & 0 & 0 & e^{-i\phi}\\ \end{pmatrix}\end{split}\]

GlobalPhase(pr)

Global phase gate.

\[\begin{split}{\rm GlobalPhase}=\begin{pmatrix}\exp(-i\theta)&0\\ 0&\exp(-i\theta)\end{pmatrix}\end{split}\]

HGate()

Hadamard gate.

\[\begin{split}{\rm H}=\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}\end{split}\]

IGate()

Identity gate.

\[\begin{split}{\rm I}=\begin{pmatrix}1&0\\0&1\end{pmatrix}\end{split}\]

ISWAPGate()

ISWAP gate.

Measure([name, reset_to])

Measurement gate that measure quantum qubits.

PhaseShift(pr)

Phase shift gate.

\[\begin{split}{\rm PhaseShift}=\begin{pmatrix}1&0\\ 0&\exp(i\theta)\end{pmatrix}\end{split}\]

Rn(alpha, beta, gamma)

Pauli rotate about a arbitrary axis in bloch sphere.

\[\begin{split}\begin{aligned} {\rm Rn}(\alpha, \beta, \gamma) &= e^{-i(\alpha \sigma_x + \beta \sigma_y + \gamma \sigma_z)/2}\\ &= \cos(f/2)I-i\sin(f/2)(\alpha \sigma_x + \beta \sigma_y + \gamma \sigma_z)/f\\ &\text{where } f=\sqrt{\alpha^2 + \beta^2 + \gamma^2} \end{aligned}\end{split}\]

RX(pr)

Rotation gate around x-axis.

\[\begin{split}{\rm RX}=\begin{pmatrix}\cos(\theta/2)&-i\sin(\theta/2)\\ -i\sin(\theta/2)&\cos(\theta/2)\end{pmatrix}\end{split}\]

Rxx(pr)

Rxx gate.

\[\begin{split}Rxx(\theta) = \exp{\left(-i\frac{\theta}{2} X\otimes X\right)} = \begin{pmatrix} \cos{\frac{\theta}{2}} & 0 & 0 & -i\sin{\frac{\theta}{2}}\\ 0 & \cos{\frac{\theta}{2}} & -i\sin{\frac{\theta}{2}} & 0\\ 0 & -i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0\\ -i\sin{\frac{\theta}{2}} & 0 & 0 & \cos{\frac{\theta}{2}}\\ \end{pmatrix}\end{split}\]

Rxy(pr)

Rxy gate.

\[\begin{split}Rxy(\theta) = \exp{\left(-i\frac{\theta}{2} Y\otimes X\right)} = \begin{pmatrix} \cos{\frac{\theta}{2}} & 0 & 0 & -\sin{\frac{\theta}{2}}\\ 0 & \cos{\frac{\theta}{2}} & -\sin{\frac{\theta}{2}} & 0\\ 0 & \sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0\\ \sin{\frac{\theta}{2}} & 0 & 0 & \cos{\frac{\theta}{2}}\\ \end{pmatrix}\end{split}\]

Rxz(pr)

Rxz gate.

\[\begin{split}Rxz(\theta) = \exp{\left(-i\frac{\theta}{2} Z\otimes X\right)} = \begin{pmatrix} \cos{\frac{\theta}{2}} & -i\sin{\frac{\theta}{2}} & 0 & 0\\ -i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0 & 0\\ 0 & 0 & \cos{\frac{\theta}{2}} & i\sin{\frac{\theta}{2}}\\ 0 & 0 & i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}}\\ \end{pmatrix}\end{split}\]

RY(pr)

Rotation gate around y-axis.

\[\begin{split}{\rm RY}=\begin{pmatrix}\cos(\theta/2)&-\sin(\theta/2)\\ \sin(\theta/2)&\cos(\theta/2)\end{pmatrix}\end{split}\]

Ryy(pr)

Ryy gate.

\[\begin{split}Ryy(\theta) = \exp{\left(-i\frac{\theta}{2} Y\otimes Y\right)} = \begin{pmatrix} \cos{\frac{\theta}{2}} & 0 & 0 & i\sin{\frac{\theta}{2}}\\ 0 & \cos{\frac{\theta}{2}} & -i\sin{\frac{\theta}{2}} & 0\\ 0 & -i\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0\\ i\sin{\frac{\theta}{2}} & 0 & 0 & \cos{\frac{\theta}{2}}\\ \end{pmatrix}\end{split}\]

Ryz(pr)

Ryz gate.

\[\begin{split}Ryz(\theta) = \exp{\left(-i\frac{\theta}{2} Z\otimes Y\right)} = \begin{pmatrix} \cos{\frac{\theta}{2}} & -\sin{\frac{\theta}{2}} & 0 & 0\\ \sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}} & 0 & 0\\ 0 & 0 & \cos{\frac{\theta}{2}} & \sin{\frac{\theta}{2}}\\ 0 & 0 & -\sin{\frac{\theta}{2}} & \cos{\frac{\theta}{2}}\\ \end{pmatrix}\end{split}\]

RZ(pr)

Rotation gate around z-axis.

\[\begin{split}{\rm RZ}=\begin{pmatrix}\exp(-i\theta/2)&0\\ 0&\exp(i\theta/2)\end{pmatrix}\end{split}\]

Rzz(pr)

Rzz gate.

\[\begin{split}Rzz(\theta) = \exp{\left(-i\frac{\theta}{2} Z\otimes Z\right)} = \begin{pmatrix} e^{-i\frac{\theta}{2}} & 0 & 0 & 0\\ 0 & e^{i\frac{\theta}{2}} & 0 & 0\\ 0 & 0 & e^{i\frac{\theta}{2}} & 0\\ 0 & 0 & 0 & e^{-i\frac{\theta}{2}}\\ \end{pmatrix}\end{split}\]

RotPauliString(...)

Arbitrary pauli string rotation.

\[U(\theta)=e^{-i\theta P/2}, P=\otimes_i\sigma_i, \text{where } \sigma \in \{X, Y, Z\}\]

SGate()

S gate.

\[\begin{split}{\rm S}=\begin{pmatrix}1&0\\0&i\end{pmatrix}\end{split}\]

SWAPGate()

SWAP gate that swap two different qubits.

SWAPalpha(pr)

SWAP alpha gate.

\[\begin{split}\text{SWAP}(\alpha) = \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & \frac{1}{2}\left(1+e^{i\pi\alpha}\right) & \frac{1}{2}\left(1-e^{i\pi\alpha}\right) & 0\\ 0 & \frac{1}{2}\left(1-e^{i\pi\alpha}\right) & \frac{1}{2}\left(1+e^{i\pi\alpha}\right) & 0\\ 0 & 0 & 0 & 1\\ \end{pmatrix}\end{split}\]

SXGate()

Sqrt X (SX) gate.

\[\begin{split}{\rm SX}=\frac{1}{2}\begin{pmatrix}1+i&1-i\\1-i&1+i\end{pmatrix}\end{split}\]

TGate()

T gate.

\[\begin{split}{\rm T}=\begin{pmatrix}1&0\\0&(1+i)/\sqrt(2)\end{pmatrix}\end{split}\]

U3(theta, phi, lamda)

U3 gate represent arbitrary single qubit gate.

\[\begin{split}{\rm U3}(\theta, \phi, \lambda) =\begin{pmatrix}\cos(\theta/2)&-e^{i\lambda}\sin(\theta/2)\\ e^{i\phi}\sin(\theta/2)&e^{i(\phi+\lambda)}\cos(\theta/2)\end{pmatrix}\end{split}\]

XGate()

Pauli-X gate.

\[\begin{split}{\rm X}=\begin{pmatrix}0&1\\1&0\end{pmatrix}\end{split}\]

YGate()

Pauli Y gate.

\[\begin{split}{\rm Y}=\begin{pmatrix}0&-i\\i&0\end{pmatrix}\end{split}\]

ZGate()

Pauli-Z gate.

\[\begin{split}{\rm Z}=\begin{pmatrix}1&0\\0&-1\end{pmatrix}\end{split}\]

GroupedPauli(pauli_string)

Multi qubit pauli string gate.

\[U =\otimes_i\sigma_i, \text{where } \sigma \in \{I, X, Y, Z\}\]

Givens(pr)

Givens rotation gate.

\[\begin{split}{\rm G}(\theta)=\exp{\left(-i\frac{\theta}{2} (Y\otimes X - X\otimes Y)\right)} = \begin{pmatrix} 1 & 0 & 0 & 0\\ 0 & \cos{\theta} & -\sin{\theta} & 0\\ 0 & \sin{\theta} & \cos{\theta} & 0\\ 0 & 0 & 0 & 1\\ \end{pmatrix}\end{split}\]

Functional Gate#

API Name

Description

UnivMathGate(name, ...)

Universal math gate.

gene_univ_parameterized_gate(...)

Generate a customer parameterized gate based on the single parameter defined unitary matrix.

gene_univ_two_params_gate(...)

Generate a customer parameterized gate with two parameters.

BarrierGate([show])

Barrier gate will separate two gate in two different layer.

pre-instantiated gate#

The gates blow are the pre-instantiated quantum gates, which can be used directly as an instance of quantum gate.

pre-instantiated gate

gate

mindquantum.core.gates.CNOT

mindquantum.core.gates.CNOTGate

mindquantum.core.gates.I

mindquantum.core.gates.IGate

mindquantum.core.gates.ISWAP

mindquantum.core.gates.ISWAPGate

mindquantum.core.gates.H

mindquantum.core.gates.HGate

mindquantum.core.gates.S

mindquantum.core.gates.PhaseShift (numpy.pi/2)

mindquantum.core.gates.SWAP

mindquantum.core.gates.SWAPGate

mindquantum.core.gates.SX

mindquantum.core.gates.SXGate

mindquantum.core.gates.T

mindquantum.core.gates.PhaseShift (numpy.pi/4)

mindquantum.core.gates.X

mindquantum.core.gates.XGate

mindquantum.core.gates.Y

mindquantum.core.gates.YGate

mindquantum.core.gates.Z

mindquantum.core.gates.ZGate

Quantum Channel#

API Name

Description

Math

AmplitudeDampingChannel(...)

Amplitude damping channel express error that qubit is affected by the energy dissipation.

\[\begin{split}\begin{gather*} \epsilon(\rho) = E_0 \rho E_0^\dagger + E_1 \rho E_1^\dagger \\ \text{where}\ {E_0}=\begin{bmatrix}1&0\\ 0&\sqrt{1-\gamma}\end{bmatrix}, \ {E_1}=\begin{bmatrix}0&\sqrt{\gamma}\\ 0&0\end{bmatrix} \end{gather*}\end{split}\]

BitFlipChannel(p, ...)

A bit flip channel.

\[\epsilon(\rho) = (1 - P)\rho + P X \rho X\]

BitPhaseFlipChannel(p, ...)

A bit&phase flip channel.

\[\epsilon(\rho) = (1 - P)\rho + P Y \rho Y\]

DepolarizingChannel(p)

A depolarizing channel.

\[\epsilon(\rho) = (1 - P)\rho + P/4( I \rho I + X \rho X + Y \rho Y + Z \rho Z)\]

KrausChannel(name, ...)

A kraus channel.

\[\epsilon(\rho) = \sum_{k=0}^{m-1} E_k \rho E_k^\dagger\]

PauliChannel(px, py, ...)

A pauli channel.

\[\epsilon(\rho) = (1 - P_x - P_y - P_z)\rho + P_x X \rho X + P_y Y \rho Y + P_z Z \rho Z\]

GroupedPauliChannel(...)

A group of pauli channels.

\[\epsilon(\rho) = \otimes_i \epsilon_\text{pauli}^i(\rho)\]

PhaseDampingChannel(...)

A phase damping channel.

\[\begin{split}\begin{gather*} \epsilon(\rho) = E_0 \rho E_0^\dagger + E_1 \rho E_1^\dagger \\ \text{where}\ {E_0}=\begin{bmatrix}1&0\\ 0&\sqrt{1-\gamma}\end{bmatrix}, \ {E_1}=\begin{bmatrix}0&0\\ 0&\sqrt{\gamma}\end{bmatrix} \end{gather*}\end{split}\]

PhaseFlipChannel(p, ...)

A phase flip channel.

\[\epsilon(\rho) = (1 - P)\rho + P Z \rho Z\]

ThermalRelaxationChannel(t1, ...)

Thermal relaxation channel.

\[\begin{split}\begin{gather*} \epsilon(\rho) = \text{tr}_1 \left[ \Lambda \left( \rho^T \otimes I \right) \right], \Lambda=\begin{pmatrix} \epsilon_{T_1} & 0 & 0 & \epsilon_{T_2} \\ 0 & 1-\epsilon_{T_1} & 0 & 0 \\ 0 & 0 & 0 & 0 \\ \epsilon_{T_2} & 0 & 0 & 1 \end{pmatrix} \\ \text{where}\ \epsilon_{T_1}=e^{-T_g/T_1}, \epsilon_{T_2}=e^{-T_g/T_2} \end{gather*}\end{split}\]

Functional Class#

API Name

Description

MeasureResult()

Measurement result container.

Power(gate[, exponent])

Power operator on a non parameterized gate.