gate#
Photonic quantum gates
Classes
|
Barrier. |
|
Beam Splitter. |
|
Beam Splitter with fixed \(\theta\) at \(\pi/4\). |
|
Beam Splitter with a single parameter. |
|
Beam Splitter with fixed \(\phi\) at \(\pi/2\). |
|
Controlled-X gate. |
|
Controlled-Z gate. |
|
Cross-Kerr gate. |
|
Cubic phase gate. |
|
Delay loop with |
|
Delay loop with MZI. |
|
Displacement gate. |
|
Momentum Displacement gate. |
|
Position Displacement gate. |
|
A base class for two-mode photonic quantum gates. |
|
Kerr gate. |
|
Mach-Zehnder Interferometer. |
|
Phase Shifter. |
|
Quadratic phase gate. |
|
A base class for single-mode photonic quantum gates. |
|
Squeezing gate. |
|
Two-mode Squeezing gate. |
|
Arbitrary unitary gate. |
- class Barrier(nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None)[source]#
Bases:
GateBarrier.
- Parameters:
nmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
None
- class BeamSplitter(inputs: Any = None, nmode: int = 2, wires: list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
DoubleGateBeam Splitter.
See https://arxiv.org/abs/2004.11002 Eq.(42b)
Matrix Representation:
\[\begin{split}U_{\text{BS}}(\theta, \phi) = \begin{pmatrix} \cos\left(\theta\right) & -e^{-i\phi} \sin\left(\theta\right) \\ e^{i\phi} \sin\left(\theta\right) & \cos\left(\theta\right) \\ \end{pmatrix}\end{split}\]Symplectic Transformation:
\[\begin{split}BS^\dagger(\theta, \phi) \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix} BS(\theta, \phi) = \begin{pmatrix} \mathrm{Re}(U_{\text{BS}}) & -\mathrm{Im}(U_{\text{BS}}) \\ \mathrm{Im}(U_{\text{BS}}) & \mathrm{Re}(U_{\text{BS}}) \\ \end{pmatrix} \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameters of the gate (\(\theta\) and \(\phi\)). Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- get_matrix(theta: Any, phi: Any) Tensor[source]#
Get the local unitary matrix acting on creation operators.
- get_matrix_state(matrix: Tensor) Tensor[source]#
Get the local transformation matrix acting on Fock state tensors.
See https://arxiv.org/pdf/2004.11002.pdf Eq.(74) and Eq.(75)
- class BeamSplitterPhi(inputs: Any = None, nmode: int = 2, wires: list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
BeamSplitterBeam Splitter with fixed \(\theta\) at \(\pi/4\).
Matrix Representation:
\[\begin{split}U_{\text{BS}}(\phi) = \begin{pmatrix} \frac{\sqrt{2}}{2} & -\frac{\sqrt{2}}{2}e^{-i\phi} \\ \frac{\sqrt{2}}{2}e^{i\phi} & \frac{\sqrt{2}}{2} \\ \end{pmatrix}\end{split}\]Symplectic Transformation:
\[\begin{split}BS^\dagger(\phi) \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix} BS(\phi) = \begin{pmatrix} \mathrm{Re}(U_{\text{BS}}) & -\mathrm{Im}(U_{\text{BS}}) \\ \mathrm{Im}(U_{\text{BS}}) & \mathrm{Re}(U_{\text{BS}}) \\ \end{pmatrix} \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameter is
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class BeamSplitterSingle(inputs: Any = None, nmode: int = 2, wires: list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, convention: str = 'rx', requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
BeamSplitterBeam Splitter with a single parameter.
Matrix Representation:
\[ \begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}U_{\text{BS-Rx}}(\theta) = \begin{pmatrix} \cos\left(\th\right) & i\sin\left(\th\right) \\ i\sin\left(\th\right) & \cos\left(\th\right) \\ \end{pmatrix}\end{split}\end{aligned}\end{align} \]\[ \begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}U_{\text{BS-Ry}}(\theta) = \begin{pmatrix} \cos\left(\th\right) & -\sin\left(\th\right) \\ \sin\left(\th\right) & \cos\left(\th\right) \\ \end{pmatrix}\end{split}\end{aligned}\end{align} \]\[ \begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}U_{\text{BS-H}}(\theta) = \begin{pmatrix} \cos\left(\th\right) & \sin\left(\th\right) \\ \sin\left(\th\right) & -\cos\left(\th\right) \\ \end{pmatrix}\end{split}\end{aligned}\end{align} \]Symplectic Transformation:
\[\begin{split}BS^\dagger(\theta) \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix} BS(\theta) = \begin{pmatrix} \mathrm{Re}(U_{\text{BS}}) & -\mathrm{Im}(U_{\text{BS}}) \\ \mathrm{Im}(U_{\text{BS}}) & \mathrm{Re}(U_{\text{BS}}) \\ \end{pmatrix} \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falseconvention (str) – The convention of the type of the beam splitter, including
'rx','ry'and'h'. Default:'rx'requires_grad (bool) – Whether the parameter is
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class BeamSplitterTheta(inputs: Any = None, nmode: int = 2, wires: list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
BeamSplitterBeam Splitter with fixed \(\phi\) at \(\pi/2\).
Matrix Representation:
\[\begin{split}U_{\text{BS}}(\theta) = \begin{pmatrix} \cos\left(\theta\right) & i\sin\left(\theta\right) \\ i\sin\left(\theta\right) & \cos\left(\theta\right) \\ \end{pmatrix}\end{split}\]Symplectic Transformation:
\[\begin{split}BS^\dagger(\theta) \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix} BS(\theta) = \begin{pmatrix} \mathrm{Re}(U_{\text{BS}}) & -\mathrm{Im}(U_{\text{BS}}) \\ \mathrm{Im}(U_{\text{BS}}) & \mathrm{Re}(U_{\text{BS}}) \\ \end{pmatrix} \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameter is
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class ControlledX(inputs: Any = None, nmode: int = 2, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
DoubleGateControlled-X gate.
Operator Representation:
\[CX(s) = e^{-i \frac{s}{\hbar} \hat{x}_1 \hat{p}_2}\]Symplectic Transformation:
\[\begin{split}CX^\dagger(s) \begin{pmatrix} \hat{a}_1 \\ \hat{a}_2 \\ \hat{a}_1^\dagger \\ \hat{a}_2^\dagger \\ \end{pmatrix} CX(s) = \begin{pmatrix} 1 & -\frac{s}{2} & 0 & \frac{s}{2} \\ \frac{s}{2} & 1 & \frac{s}{2} & 0 \\ 0 & \frac{s}{2} & 1 & -\frac{s}{2} \\ \frac{s}{2} & 0 & \frac{s}{2} & 1 \\ \end{pmatrix} \begin{pmatrix} \hat{a}_1 \\ \hat{a}_2 \\ \hat{a}_1^\dagger \\ \hat{a}_2^\dagger \\ \end{pmatrix}\end{split}\]\[\begin{split}CX^\dagger(s) \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix} CX(s) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ s & 1 & 0 & 0 \\ 0 & 0 & 1 & -s \\ 0 & 0 & 0 & 1 \\ \end{pmatrix} \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix}\end{split}\]Decomposition Representation:
\[CX(s) = BS(\frac{\pi}{2} + \theta, 0) \left(S(r, 0) \otimes S(-r, 0)\right) BS(\theta, 0)\]where \(\sin(2 \theta) = -\frac{1}{\cosh r}, \quad \cos(2 \theta) = -\tanh r, \quad \sinh(r) = -\frac{s}{2}\).
- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- get_matrix(s: Any) Tensor[source]#
Get the local symplectic matrix acting on annihilation and creation operators.
- get_matrix_state(s: Any) Tensor[source]#
Get the local transformation matrix acting on Fock state tensors.
- get_transform_xp(s: Any) tuple[Tensor, Tensor][source]#
Get the local affine symplectic transformation acting on quadrature operators in
xxpporder.
- update_matrix() Tensor[source]#
Update the local symplectic matrix acting on annihilation and creation operators.
- class ControlledZ(inputs: Any = None, nmode: int = 2, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
DoubleGateControlled-Z gate.
Operator Representation:
\[CZ(s) = e^{-i \frac{s}{\hbar} \hat{x}_1 \hat{x}_2}\]Symplectic Transformation:
\[\begin{split}CZ^\dagger(s) \begin{pmatrix} \hat{a}_1 \\ \hat{a}_2 \\ \hat{a}_1^\dagger \\ \hat{a}_2^\dagger \\ \end{pmatrix} CZ(s) = \begin{pmatrix} 1 & i \frac{s}{2} & 0 & i \frac{s}{2} \\ i \frac{s}{2} & 1 & i \frac{s}{2} & 0 \\ 0 & -i \frac{s}{2} & 1 & -i \frac{s}{2} \\ -i \frac{s}{2} & 0 & -i \frac{s}{2} & 1 \\ \end{pmatrix} \begin{pmatrix} \hat{a}_1 \\ \hat{a}_2 \\ \hat{a}_1^\dagger \\ \hat{a}_2^\dagger \\ \end{pmatrix}\end{split}\]\[\begin{split}CZ^\dagger(s) \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix} CZ(s) = \begin{pmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & s & 1 & 0 \\ s & 0 & 0 & 1 \\ \end{pmatrix} \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix}\end{split}\]Decomposition Representation:
\[CZ(s) = PS_2(\pi/2) CX(s) PS_2^\dagger(\pi/2)\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- get_matrix(s: Any) Tensor[source]#
Get the local symplectic matrix acting on annihilation and creation operators.
- get_matrix_state(s: Any) Tensor[source]#
Get the local transformation matrix acting on Fock state tensors.
- get_transform_xp(s: Any) tuple[Tensor, Tensor][source]#
Get the local affine symplectic transformation acting on quadrature operators in
xxpporder.
- update_matrix() Tensor[source]#
Update the local symplectic matrix acting on annihilation and creation operators.
- class CrossKerr(inputs: Any = None, nmode: int = 2, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
DoubleGateCross-Kerr gate.
Operator Representation:
\[CK(\kappa) = e^{i \kappa \hat{n}_1 \hat{n}_2}\]Operator Transformation:
\[\begin{split}CK^\dagger(\kappa) \hat{a}_1 CK(\kappa) &= e^{i \kappa \hat{n}_2} \hat{a}_1 = \hat{a}_1 e^{i \kappa \hat{n}_2}, \\ CK^\dagger(\kappa) \hat{a}_2 CK(\kappa) &= e^{i \kappa \hat{n}_1} \hat{a}_2 = \hat{a}_2 e^{i \kappa \hat{n}_1}, \\ CK^\dagger(\kappa) \hat{a}_1^\dagger CK(\kappa) &= e^{-i \kappa \hat{n}_2} \hat{a}_1^\dagger = \hat{a}_1^\dagger e^{-i \kappa \hat{n}_2}, \\ CK^\dagger(\kappa) \hat{a}_2^\dagger CK(\kappa) &= e^{-i \kappa \hat{n}_1} \hat{a}_2^\dagger = \hat{a}_2^\dagger e^{-i \kappa \hat{n}_1}.\end{split}\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class CubicPhase(inputs: Any = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
SingleGateCubic phase gate.
Operator Representation:
\[CP(\gamma) = e^{i \frac{\gamma}{3 \hbar} \hat{x}^3}\]Operator Transformation:
\[CP^\dagger(\gamma) \hat{a} CP(\gamma) = \hat{a} + i\frac{\gamma(\hat{a} + \hat{a}^\dagger)^2}{2\sqrt{2/\hbar}}\]\[\begin{split}CP^\dagger(\gamma) \hat{x} CP(\gamma) &= \hat{x}, \\ CP^\dagger(\gamma) \hat{p} CP(\gamma) &= \hat{p} + \gamma\hat{x}^2.\end{split}\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class DelayBS(inputs: Any = None, ntau: int = 1, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, loop_gates: list | None = None, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
DelayDelay loop with
BeamSplitterThetaandPhaseShift.- Parameters:
inputs (Any) – The parameters of the gate. Default:
Nonentau (int) – The number of modes in the delay loop. Default: 1
nmode (int) – The number of spatial modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)loop_gates (list | None) – The list of gates added to the delay loop. Default:
Nonenoise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- property phi#
- property theta#
- class DelayMZI(inputs: Any = None, ntau: int = 1, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, loop_gates: list | None = None, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
DelayDelay loop with MZI.
- Parameters:
inputs (Any) – The parameters of the gate. Default:
Nonentau (int) – The number of modes in the delay loop. Default: 1
nmode (int) – The number of spatial modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)loop_gates (list | None) – The list of gates added to the delay loop. Default:
Nonenoise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- property phi#
- property theta#
- class Displacement(inputs: Any = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
SingleGateDisplacement gate.
Symplectic Transformation:
\[\begin{split}D^\dagger(r, \theta) \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix} D(r, \theta) = \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix} + \frac{\sqrt{\hbar}}{\kappa} \begin{pmatrix} r\cos\theta \\ r\sin\theta \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameters of the gate (\(r\) and \(\theta\)). Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- get_matrix(r: Any, theta: Any) Tensor[source]#
Get the local symplectic unitary matrix acting on annihilation and creation operators.
- get_matrix_state(r: Any, theta: Any) Tensor[source]#
Get the local transformation matrix acting on Fock state tensors.
See https://arxiv.org/pdf/2004.11002.pdf Eq.(57) and Eq.(58)
- get_transform_xp(r: Any, theta: Any) tuple[Tensor, Tensor][source]#
Get the local affine symplectic transformation acting on quadrature operators in
xxpporder.
- update_matrix() Tensor[source]#
Update the local symplectic unitary matrix acting on annihilation and creation operators.
- class DisplacementMomentum(inputs: Any = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
DisplacementMomentum Displacement gate.
Symplectic Transformation:
\[\begin{split}Z^\dagger(p) \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix} Z(p) = \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix} + \begin{pmatrix} 0 \\ p \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameter is
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class DisplacementPosition(inputs: Any = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
DisplacementPosition Displacement gate.
Symplectic Transformation:
\[\begin{split}X^\dagger(x) \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix} X(x) = \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix} + \begin{pmatrix} x \\ 0 \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameter is
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class DoubleGate(name: str | None = None, inputs: Any = None, nmode: int = 2, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
GateA base class for two-mode photonic quantum gates.
- Parameters:
name (str | None) – The name of the gate. Default:
Noneinputs (Any) – The parameters of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameter is
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class Kerr(inputs: Any = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
SingleGateKerr gate.
Operator Representation:
\[K(\kappa) = e^{i \kappa \hat{n}^2}\]Operator Transformation:
\[\begin{split}K^\dagger(\kappa) \hat{a} K(\kappa) &= e^{i \kappa (2 \hat{a}^\dagger \hat{a} + 1)} \hat{a} = \hat{a} e^{i \kappa (2 \hat{a}^\dagger \hat{a} - 1)}, \\ K^\dagger(\kappa) \hat{a}^\dagger K(\kappa) &= \hat{a}^\dagger e^{-i \kappa (2 \hat{a}^\dagger \hat{a} + 1)} = e^{i \kappa (2 \hat{a}^\dagger \hat{a} + 1)} \hat{a}^\dagger.\end{split}\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class MZI(inputs: Any = None, nmode: int = 2, wires: list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, phi_first: bool = True, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
BeamSplitterMach-Zehnder Interferometer.
Matrix Representation:
\[ \begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}U_{\text{MZI}}(\theta, \phi) = ie^{i\theta/2} \begin{pmatrix} e^{i\phi} \sin\left(\th\right) & \cos\left(\th\right) \\ e^{i\phi} \cos\left(\th\right) & -\sin\left(\th\right) \\ \end{pmatrix}\end{split}\end{aligned}\end{align} \]or when
phi_firstisFalse:\[ \begin{align}\begin{aligned}\newcommand{\th}{\frac{\theta}{2}}\\\begin{split}U_{\text{MZI}}(\theta, \phi) = ie^{i\theta/2} \begin{pmatrix} e^{i\phi} \sin\left(\th\right) & e^{i\phi} \cos\left(\th\right) \\ \cos\left(\th\right) & -\sin\left(\th\right) \\ \end{pmatrix}\end{split}\end{aligned}\end{align} \]Symplectic Transformation:
\[\begin{split}MZI^\dagger(\theta, \phi) \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix} MZI(\theta, \phi) = \begin{pmatrix} \mathrm{Re}(U_{\text{MZI}}) & -\mathrm{Im}(U_{\text{MZI}}) \\ \mathrm{Im}(U_{\text{MZI}}) & \mathrm{Re}(U_{\text{MZI}}) \\ \end{pmatrix} \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameters of the gate (\(\theta\) and \(\phi\)). Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falsephi_first (bool) – Whether \(\phi\) is the first phase shifter. Default:
Truerequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class PhaseShift(inputs: Any = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1, inv_mode: bool = False)[source]#
Bases:
SingleGatePhase Shifter.
Matrix Representation:
\[U_{\text{PS}}(\theta) = e^{i\theta}\]Symplectic Transformation:
\[\begin{split}PS^\dagger(\theta) \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix} PS(\theta) = \begin{pmatrix} \cos\theta & -\sin\theta \\ \sin\theta & \cos\theta \\ \end{pmatrix} \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameter is
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
inv_mode (bool) – Whether the rotation in the phase space is clockwise. Default:
False
- get_matrix_state(matrix: Tensor) Tensor[source]#
Get the local transformation matrix acting on Fock state tensors.
- class QuadraticPhase(inputs: Any = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
SingleGateQuadratic phase gate.
Operator Representation:
\[QP(s) = e^{i \frac{s}{2 \hbar} \hat{x}^2}\]Symplectic Transformation:
\[\begin{split}QP^\dagger(s) \begin{pmatrix} \hat{a} \\ \hat{a}^\dagger \\ \end{pmatrix} QP(s) = \begin{pmatrix} 1 + i \frac{s}{2} & i \frac{s}{2} \\ -i \frac{s}{2} & 1 - i \frac{s}{2} \\ \end{pmatrix} \begin{pmatrix} \hat{a} \\ \hat{a}^\dagger \\ \end{pmatrix}\end{split}\]\[\begin{split}QP^\dagger(s) \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix} QP(s) = \begin{pmatrix} 1 & 0 \\ s & 1 \\ \end{pmatrix} \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix}\end{split}\]Decomposition Representation:
\[QP(s) = PS(\theta) S(r e^{i \phi})\]where \(\cosh(r) = \sqrt{1 + (\frac{s}{2})^2}, \quad \tan(\theta) = \frac{s}{2}, \quad \phi = -\sign(s)\frac{\pi}{2} - \theta\).
- Parameters:
inputs (Any) – The parameter of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- get_matrix(s: Any) Tensor[source]#
Get the local symplectic matrix acting on annihilation and creation operators.
- get_matrix_state(s: Any) Tensor[source]#
Get the local transformation matrix acting on Fock state tensors.
- get_transform_xp(s: Any) tuple[Tensor, Tensor][source]#
Get the local affine symplectic transformation acting on quadrature operators in
xxpporder.
- update_matrix() Tensor[source]#
Update the local symplectic matrix acting on annihilation and creation operators.
- class SingleGate(name: str | None = None, inputs: Any = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
GateA base class for single-mode photonic quantum gates.
- Parameters:
name (str | None) – The name of the gate. Default:
Noneinputs (Any) – The parameters of the gate. Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameter is
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- class Squeezing(inputs: Any = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
SingleGateSqueezing gate.
Symplectic Transformation:
\[\begin{split}S^\dagger(r, \theta) \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix} S(r, \theta) = \begin{pmatrix} \cosh r - \sinh r \cos\theta & -\sinh r \sin\theta \\ -\sinh r \sin\theta & \cosh r + \sinh r \cos\theta \\ \end{pmatrix} \begin{pmatrix} \hat{x} \\ \hat{p} \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameters of the gate (\(r\) and \(\theta\)). Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (int | list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- get_matrix(r: Any, theta: Any) Tensor[source]#
Get the local symplectic matrix acting on annihilation and creation operators.
- get_matrix_state(r: Any, theta: Any) Tensor[source]#
Get the local transformation matrix acting on Fock state tensors.
See https://arxiv.org/pdf/2004.11002.pdf Eq.(51) and Eq.(52)
- get_transform_xp(r: Any, theta: Any) tuple[Tensor, Tensor][source]#
Get the local affine symplectic transformation acting on quadrature operators in
xxpporder.
- update_matrix() Tensor[source]#
Update the local symplectic matrix acting on annihilation and creation operators.
- class Squeezing2(inputs: Any = None, nmode: int = 2, wires: list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, requires_grad: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#
Bases:
DoubleGateTwo-mode Squeezing gate.
Symplectic Transformation:
\[\begin{split}S_2^\dagger(r, \theta) \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix} S_2(r, \theta) = \begin{pmatrix} \cosh r & \cos\theta\sinh r & 0 & \sin\theta\sinh r \\ \cos\theta\sinh r & \cosh r & \sin\theta\sinh r & 0 \\ 0 & \sin\theta\sinh r & \cosh r & -\cos\theta\sinh r \\ \sin\theta\sinh r & 0 & -\cos\theta\sinh r & \cosh r \\ \end{pmatrix} \begin{pmatrix} \hat{x}_1 \\ \hat{x}_2 \\ \hat{p}_1 \\ \hat{p}_2 \\ \end{pmatrix}\end{split}\]- Parameters:
inputs (Any) – The parameters of the gate (\(r\) and \(\theta\)). Default:
Nonenmode (int) – The number of modes that the quantum operation acts on. Default: 2
wires (list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falserequires_grad (bool) – Whether the parameters are
nn.Parameterorbuffer. Default:False(which meansbuffer)noise (bool) – Whether to introduce Gaussian noise. Default:
Falsemu (float) – The mean of Gaussian noise. Default: 0
sigma (float) – The standard deviation of Gaussian noise. Default: 0.1
- get_matrix(r: Any, theta: Any) Tensor[source]#
Get the local symplectic matrix acting on annihilation and creation operators.
- get_matrix_state(r: Any, theta: Any) Tensor[source]#
Get the local transformation matrix acting on Fock state tensors.
See https://arxiv.org/pdf/2004.11002.pdf Eq.(64-67)
- get_transform_xp(r: Any, theta: Any) tuple[Tensor, Tensor][source]#
Get the local affine symplectic transformation acting on quadrature operators in
xxpporder.
- update_matrix() Tensor[source]#
Update the local symplectic matrix acting on annihilation and creation operators.
- class UAnyGate(unitary: Any, nmode: int = 1, wires: list[int] | None = None, minmax: list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, name: str = 'UAnyGate')[source]#
Bases:
GateArbitrary unitary gate.
- Parameters:
unitary (Any) – Any given unitary matrix.
nmode (int) – The number of modes that the quantum operation acts on. Default: 1
wires (list[int] | None) – The indices of the modes that the quantum operation acts on. Default:
Noneminmax (list[int] | None) – The minimum and maximum indices of the modes that the quantum operation acts on. Only valid when
wiresisNone. Default:Nonecutoff (int | None) – The Fock space truncation. Default:
Noneden_mat (bool) – Whether to use density matrix representation. Default:
Falsename (str) – The name of the gate. Default:
'UAnyGate'
- get_matrix_state(matrix: Tensor) Tensor[source]#
Get the local transformation matrix acting on Fock state tensors.
See https://arxiv.org/pdf/2004.11002.pdf Eq.(71)
- get_transform_xp(matrix: Tensor) tuple[Tensor, Tensor][source]#
Get the local affine symplectic transformation acting on quadrature operators in
xxpporder.