mindquantum.core.gates#
量子门模块,提供不同的量子门。
基类#
接口名 |
概述 |
|---|---|
BasicGate是所有门的基类。 |
|
非参数化的门。 |
|
参数化的门。 |
|
非参数化的门。 |
|
噪声信道。 |
通用量子门#
接口名 |
概述 |
数学表示 |
|---|---|---|
控制X门。 |
||
FSim 门表示费米子模拟门。FSim 门的矩阵形式为: |
\[\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}\]
|
|
全局相位门。更多用法,请参见 |
\[\begin{split}{\rm GlobalPhase}=\begin{pmatrix}\exp(-i\theta)&0\\
0&\exp(-i\theta)\end{pmatrix}\end{split}\]
|
|
Hadamard门。矩阵为: |
\[\begin{split}{\rm H}=\frac{1}{\sqrt{2}}\begin{pmatrix}1&1\\1&-1\end{pmatrix}\end{split}\]
|
|
Identity门。矩阵为: |
\[\begin{split}{\rm I}=\begin{pmatrix}1&0\\0&1\end{pmatrix}\end{split}\]
|
|
ISWAP门会交换两个不同的量子比特并且为 \(\left|01\right>\) 和 \(\left|10\right>\) 的振幅增加相位 \(i\)。 |
||
测量量子比特的测量门。 |
||
相移门。更多用法,请参见 |
\[\begin{split}{\rm PhaseShift}=\begin{pmatrix}1&0\\
0&\exp(i\theta)\end{pmatrix}\end{split}\]
|
|
Rn 门表示绕布洛赫球中给定轴旋转的量子门。Rn 门的矩阵形式为: |
\[\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}\]
|
|
围绕x轴的旋转门。 |
\[\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 门。更多用法,请参见 |
\[\begin{split}{\rm 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 门。更多用法,请参见 |
\[\begin{split}{\rm 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 门。更多用法,请参见 |
\[\begin{split}{\rm 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}\]
|
|
围绕y轴的旋转门。更多用法,请参见 |
\[\begin{split}{\rm RY}=\begin{pmatrix}\cos(\theta/2)&-\sin(\theta/2)\\
\sin(\theta/2)&\cos(\theta/2)\end{pmatrix}\end{split}\]
|
|
Ryy 门。更多用法,请参见 |
\[\begin{split}{\rm 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 门。更多用法,请参见 |
\[\begin{split}{\rm 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}\]
|
|
围绕z轴的旋转门。更多用法,请参见 |
\[\begin{split}{\rm RZ}=\begin{pmatrix}\exp(-i\theta/2)&0\\
0&\exp(i\theta/2)\end{pmatrix}\end{split}\]
|
|
Rzz 门。更多用法,请参见 |
\[\begin{split}{\rm 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}\]
|
|
任意泡利串的旋转门。 |
\[U(\theta)=e^{-i\theta P/2}, P=\otimes_i\sigma_i, \text{where } \sigma \in \{X, Y, Z\}\]
|
|
S门。矩阵为: |
\[\begin{split}{\rm S}=\begin{pmatrix}1&0\\0&i\end{pmatrix}\end{split}\]
|
|
SWAPalpha 门。更多用法,请参见 |
\[\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}\]
|
|
SWAP门可以交换两个不同的量子比特。 |
||
SX门。矩阵为: |
\[\begin{split}{\rm SX}=\frac{1}{2}\begin{pmatrix}1+i&1-i\\1-i&1+i\end{pmatrix}\end{split}\]
|
|
T门。矩阵为: |
\[\begin{split}{\rm T}=\begin{pmatrix}1&0\\0&(1+i)/\sqrt(2)\end{pmatrix}\end{split}\]
|
|
U3 门表示单比特的任意幺正门。U3 门的矩阵形式为: |
\[\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}\]
|
|
泡利X门。矩阵为: |
\[\begin{split}{\rm X}=\begin{pmatrix}0&1\\1&0\end{pmatrix}\end{split}\]
|
|
泡利Y门。矩阵为: |
\[\begin{split}{\rm Y}=\begin{pmatrix}0&-i\\i&0\end{pmatrix}\end{split}\]
|
|
泡利Z门。矩阵为: |
\[\begin{split}{\rm Z}=\begin{pmatrix}1&0\\0&-1\end{pmatrix}\end{split}\]
|
|
多比特泡利串旋转门。 |
\[U =\otimes_i\sigma_i, \text{where } \sigma \in \{I, X, Y, Z\}\]
|
|
Givens 门。更多用法,请参见 |
\[\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 |
gates |
|---|---|
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 |
量子信道#
接口名 |
概述 |
数学表示 |
|---|---|---|
振幅阻尼信道。可以表示量子比特由于能量耗散导致的错误。 |
\[\begin{split}\begin{gather*}
\epsilon(\rho) = E_0 \rho E_0^\dagger + E_1 \rho E_1^\dagger
\\
\text{其中}\ {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}\]
|
|
比特翻转信道。描述的噪声体现为:以 \(P\) 的概率翻转量子比特(作用 \(X\) 门),或以 \(1-P\) 的概率保持不变(作用 \(I\) 门)。 |
\[\epsilon(\rho) = (1 - P)\rho + P X \rho X\]
|
|
比特相位翻转信道。描述的噪声体现为:以 \(P\) 的概率翻转比特的量子态和相位(作用 \(Y\) 门),或以 \(1-P\) 的概率保持不变(作用 \(I\) 门)。 |
\[\epsilon(\rho) = (1 - P)\rho + P Y \rho Y\]
|
|
去极化信道。描述的噪声体现为:以 \(P\) 的概率将量子态转变为最大混态(随机作用泡利门(I、X、Y、Z)的其中一个,每个泡利门的概率都是 \(P/4\) ),或以 \(1-P\) 的概率保持不变。 |
\[\epsilon(\rho) = (1 - P)\rho + P/4( I \rho I + X \rho X + Y \rho Y + Z \rho Z)\]
|
|
Kraus 信道接受两个或多个 2x2 矩阵作为 Kraus 算子,以在量子电路中构造自定义(单量子比特)噪声。 |
\[\epsilon(\rho) = \sum_{k=0}^{m-1} E_k \rho E_k^\dagger\]
|
|
泡利信道。描述的噪声体现为:在量子比特上随机作用一个额外的泡利门,作用 \(X\) 、 \(Y\) 和 \(Z\) 门对应概率分别为 \(P_x\) 、 \(P_y\) 和 \(P_z\) ,或以概率 \(1-P_x-P_y-P_z\) 的概率保持不变(作用 \(I\) 门)。 |
\[\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\]
|
|
组合泡利信道。 |
\[\epsilon(\rho) = \otimes_i \epsilon_\text{pauli}^i(\rho)\]
|
|
相位阻尼信道。表示的是量子比特在不跟外界产生能量交换时量子信息的损失。 |
\[\begin{split}\begin{gather*}
\epsilon(\rho) = E_0 \rho E_0^\dagger + E_1 \rho E_1^\dagger
\\
\text{其中}\ {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}\]
|
|
相位翻转信道。描述的噪声体现为:以 \(P\) 的概率翻转量子比特的相位(应用Z门),或以 \(1-P\) 的概率保持不变(作用I门)。 |
\[\epsilon(\rho) = (1 - P)\rho + P Z \rho Z\]
|
|
热弛豫信道。 |
\[\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{其中}\ \epsilon_{T_1}=e^{-T_g/T_1}, \epsilon_{T_2}=e^{-T_g/T_2}
\end{gather*}\end{split}\]
|
功能类#
接口名 |
概述 |
|---|---|
测量结果容器。 |
|
作用在非参数化门上的指数运算符。 |