mindquantum.core.gates#
Gate module that provides different quantum gate.
Base Class#
API Name |
Description |
|---|---|
BasicGate is the base class of all gates. |
|
Base class for non-parametric gates. |
|
Gate that is parameterized. |
|
Base class for quantum gates. |
|
Noise gate class. |
Quantum Gate#
API Name |
Description |
Math |
|---|---|---|
Control-X gate. |
||
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}\]
|
|
Global phase gate. |
\[\begin{split}{\rm GlobalPhase}=\begin{pmatrix}\exp(-i\theta)&0\\
0&\exp(-i\theta)\end{pmatrix}\end{split}\]
|
|
Hadamard gate. |
\[\begin{split}{\rm H}=\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}\end{split}\]
|
|
Identity gate. |
\[\begin{split}{\rm I}=\begin{pmatrix}1&0\\0&1\end{pmatrix}\end{split}\]
|
|
ISWAP gate. |
||
Measurement gate that measure quantum qubits. |
||
Phase shift gate. |
\[\begin{split}{\rm PhaseShift}=\begin{pmatrix}1&0\\
0&\exp(i\theta)\end{pmatrix}\end{split}\]
|
|
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}\]
|
|
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 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 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 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}\]
|
|
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 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 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}\]
|
|
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 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}\]
|
|
Arbitrary pauli string rotation. |
\[U(\theta)=e^{-i\theta P/2}, P=\otimes_i\sigma_i, \text{where } \sigma \in \{X, Y, Z\}\]
|
|
S gate. |
\[\begin{split}{\rm S}=\begin{pmatrix}1&0\\0&i\end{pmatrix}\end{split}\]
|
|
SWAP gate that swap two different qubits. |
||
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}\]
|
|
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}\]
|
|
T gate. |
\[\begin{split}{\rm T}=\begin{pmatrix}1&0\\0&(1+i)/\sqrt(2)\end{pmatrix}\end{split}\]
|
|
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}\]
|
|
Pauli-X gate. |
\[\begin{split}{\rm X}=\begin{pmatrix}0&1\\1&0\end{pmatrix}\end{split}\]
|
|
Pauli Y gate. |
\[\begin{split}{\rm Y}=\begin{pmatrix}0&-i\\i&0\end{pmatrix}\end{split}\]
|
|
Pauli-Z gate. |
\[\begin{split}{\rm Z}=\begin{pmatrix}1&0\\0&-1\end{pmatrix}\end{split}\]
|
|
Multi qubit pauli string gate. |
\[U =\otimes_i\sigma_i, \text{where } \sigma \in \{I, X, Y, Z\}\]
|
|
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 |
|---|---|
Universal math gate. |
|
Generate a customer parameterized gate based on the single parameter defined unitary matrix. |
|
Generate a customer parameterized gate with two parameters. |
|
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.I |
|
mindquantum.core.gates.ISWAP |
|
mindquantum.core.gates.H |
|
mindquantum.core.gates.S |
|
mindquantum.core.gates.SWAP |
|
mindquantum.core.gates.SX |
|
mindquantum.core.gates.T |
|
mindquantum.core.gates.X |
|
mindquantum.core.gates.Y |
|
mindquantum.core.gates.Z |
Quantum Channel#
API Name |
Description |
Math |
|---|---|---|
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}\]
|
|
A bit flip channel. |
\[\epsilon(\rho) = (1 - P)\rho + P X \rho X\]
|
|
A bit&phase flip channel. |
\[\epsilon(\rho) = (1 - P)\rho + P Y \rho Y\]
|
|
A depolarizing channel. |
\[\epsilon(\rho) = (1 - P)\rho + P/4( I \rho I + X \rho X + Y \rho Y + Z \rho Z)\]
|
|
A kraus channel. |
\[\epsilon(\rho) = \sum_{k=0}^{m-1} E_k \rho E_k^\dagger\]
|
|
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\]
|
|
A group of pauli channels. |
\[\epsilon(\rho) = \otimes_i \epsilon_\text{pauli}^i(\rho)\]
|
|
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}\]
|
|
A phase flip channel. |
\[\epsilon(\rho) = (1 - P)\rho + P Z \rho Z\]
|
|
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 |
|---|---|
Measurement result container. |
|
Power operator on a non parameterized gate. |