operation#

Base classes for photonic quantum operations

Classes

Channel([name, nmode, wires, cutoff])

A base class for photonic quantum channels.

Delay([name, ntau, nmode, wires, cutoff, ...])

Delay loop.

Gate([name, nmode, wires, cutoff, den_mat, ...])

A base class for photonic quantum gates.

Operation([name, nmode, wires, cutoff, ...])

A base class for quantum operations.

class Channel(name: str | None = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None)[source]#

Bases: Operation

A base class for photonic quantum channels.

Parameters:
  • name (str | None) – The name of the channel. Default: None

  • 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: None

  • cutoff (int | None) – The Fock space truncation. Default: None

forward(x: Tensor | list[Tensor]) Tensor | list[Tensor][source]#

Perform a forward pass.

op_cv(x: list[Tensor]) list[Tensor][source]#

Perform a forward pass for Gaussian (Bosonic) states.

See Quantum Continuous Variables: A Primer of Theoretical Methods (2024) by Alessio Serafini Eq.(5.35-5.37) in page 90

op_den_mat(x: Tensor) Tensor[source]#

Perform a forward pass for density matrices.

update_matrix_state() Tensor[source]#

Update the local Kraus matrices acting on Fock state density matrices.

update_transform_xy() tuple[Tensor, Tensor][source]#

Update the local transformation matrices X and Y acting on Gaussian states.

class Delay(name='Delay', ntau: int = 1, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#

Bases: Operation

Delay loop.

Parameters:
  • name – The name of the quantum operation. Default: 'Delay'

  • ntau (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: None

  • cutoff (int | None) – The Fock space truncation. Default: None

  • den_mat (bool) – Whether to use density matrix representation. Default: False

  • noise (bool) – Whether to introduce Gaussian noise. Default: False

  • mu (float) – The mean of Gaussian noise. Default: 0

  • sigma (float) – The standard deviation of Gaussian noise. Default: 0.1

extra_repr() str[source]#
forward(x: Tensor | list[Tensor] | MatrixProductState | DistributedFockState) Tensor | list[Tensor] | MatrixProductState | DistributedFockState[source]#

Perform a forward pass.

init_para(inputs: Any = None) None[source]#

Initialize the parameters.

class Gate(name: str | None = None, nmode: int = 1, wires: int | list[int] | None = None, cutoff: int | None = None, den_mat: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#

Bases: Operation

A base class for photonic quantum gates.

Parameters:
  • name (str | None) – The name of the gate. Default: None

  • 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: None

  • cutoff (int | None) – The Fock space truncation. Default: None

  • den_mat (bool) – Whether to use density matrix representation. Default: False

  • noise (bool) – Whether to introduce Gaussian noise. Default: False

  • mu (float) – The mean of Gaussian noise. Default: 0

  • sigma (float) – The standard deviation of Gaussian noise. Default: 0.1

extra_repr() str[source]#
forward(x: Tensor | list[Tensor] | MatrixProductState | DistributedFockState) Tensor | list[Tensor] | MatrixProductState | DistributedFockState[source]#

Perform a forward pass.

get_displacement() Tensor[source]#

Get the global displacement vector acting on quadrature operators in xxpp order.

get_matrix_state(matrix: Tensor) Tensor[source]#

Get the local transformation matrix acting on Fock state tensors.

get_mpo() tuple[list[Tensor], int][source]#

Convert gate to MPO form with identities at empty sites.

Note

If sites are not adjacent, insert identities in the middle, i.e.,

>>>      |       |            |   |   |
>>>    --A---x---B--   ->   --A---I---B--
>>>      |       |            |   |   |

where

>>>         a
>>>         |
>>>    --i--I--j--
>>>         |
>>>         b

means \(\delta_{i,j} \delta_{a,b}\)

get_symplectic() Tensor[source]#

Get the global symplectic matrix acting on quadrature operators in xxpp order.

get_unitary() Tensor[source]#

Get the global unitary matrix acting on creation operators.

op_cv(x: list[Tensor]) list[Tensor][source]#

Perform a forward pass for Gaussian (Bosonic) states.

op_den_mat(x: Tensor) Tensor[source]#

Perform a forward pass for density matrices.

op_dist_state(x: DistributedFockState) DistributedFockState[source]#

Perform a forward pass for a distributed Fock state tensor.

op_mps(mps: MatrixProductState) MatrixProductState[source]#

Perform a forward pass for the MatrixProductState.

op_state_tensor(x: Tensor) Tensor[source]#

Perform a forward pass for state tensors.

update_matrix() Tensor[source]#

Update the local unitary matrix acting on creation operators.

update_matrix_state() Tensor[source]#

Update the local transformation matrix acting on Fock state tensors.

update_transform_xp() tuple[Tensor, Tensor][source]#

Update the local affine symplectic transformation acting on quadrature operators in xxpp order.

class Operation(name: str | None = None, nmode: int = 1, wires: int | list | None = None, cutoff: int = 2, den_mat: bool = False, noise: bool = False, mu: float = 0, sigma: float = 0.1)[source]#

Bases: Module

A base class for quantum operations.

Parameters:
  • name (str | None) – The name of the quantum operation. Default: None

  • nmode (int) – The number of modes that the quantum operation acts on. Default: 1

  • wires (int | list | None) – The indices of the modes that the quantum operation acts on. Default: None

  • cutoff (int) – The Fock space truncation. Default: 2

  • den_mat (bool) – Whether to use density matrix representation. Default: False

  • noise (bool) – Whether to introduce Gaussian noise. Default: False

  • mu (float) – The mean of Gaussian noise. Default: 0

  • sigma (float) – The standard deviation of Gaussian noise. Default: 0.1

forward(x: Tensor) Tensor[source]#

Perform a forward pass.

init_para() None[source]#

Initialize the parameters.

tensor_rep(x: Tensor) Tensor[source]#

Get the tensor representation of the state.