Module: pennylane.templates.layers

Interferometer(theta, phi, varphi, wires, mesh='rectangular', beamsplitter='pennylane')[source]

General linear interferometer, an array of beamsplitters and phase shifters.

For \(M\) wires, the general interferometer is specified by providing \(M(M-1)/2\) transmittivity angles \(\theta\) and the same number of phase angles \(\phi\), as well as either \(M-1\) or \(M\) additional rotation parameters \(\varphi\).

For the parametrization of a universal interferometer \(M-1\) such rotation parameters are sufficient. If \(M\) rotation parameters are given, the interferometer is over-parametrized, but the resulting circuit is more symmetric, which can be advantageous.

By specifying the keyword argument mesh, the scheme used to implement the interferometer may be adjusted:

  • mesh='rectangular' (default): uses the scheme described in [clements2016optimal], resulting in a rectangular array of \(M(M-1)/2\) beamsplitters arranged in \(M\) slices and ordered from left to right and top to bottom in each slice. The first beamsplitter acts on wires \(0\) and \(1\):

  • mesh='triangular': uses the scheme described in [reck1994experimental], resulting in a triangular array of \(M(M-1)/2\) beamsplitters arranged in \(2M-3\) slices and ordered from left to right and top to bottom. The first and fourth beamsplitters act on wires \(M-1\) and \(M\), the second on \(M-2\) and \(M-1\), and the third on \(M-3\) and \(M-2\), and so on.


In both schemes, the network of Beamsplitter operations is followed by \(M\) (or \(M-1\)) local Rotation Operations. In the latter case, the rotation on the last wire is left out.

The rectangular decomposition is generally advantageous, as it has a lower circuit depth (\(M\) vs \(2M-3\)) and optical depth than the triangular decomposition, resulting in reduced optical loss.

This is an example of a 4-mode interferometer with beamsplitters \(B\) and rotations \(R\), using mesh='rectangular':



The decomposition as formulated in [clements2016optimal] uses a different convention for a beamsplitter \(T(\theta, \phi)\) than PennyLane, namely:

\[T(\theta, \phi) = BS(\theta, 0) R(\phi)\]

For the universality of the decomposition, the used convention is irrelevant, but for a given set of angles the resulting interferometers will be different.

If an interferometer consistent with the convention from [clements2016optimal] is needed, the optional keyword argument beamsplitter='clements' can be specified. This will result in each Beamsplitter being preceded by a Rotation and thus increase the number of elementary operations in the circuit.

  • theta (array) – length \(M(M-1)/2\) array of transmittivity angles \(\theta\)
  • phi (array) – length \(M(M-1)/2\) array of phase angles \(\phi\)
  • varphi (array) – length \(M\) or \(M-1\) array of rotation angles \(\varphi\)
  • wires (Sequence[int]) – wires the interferometer should act on
Keyword Arguments:
  • mesh (string) – the type of mesh to use
  • beamsplitter (str) – if clements, the beamsplitter convention from Clements et al. 2016 ( is used; if pennylane, the beamsplitter is implemented via PennyLane’s Beamsplitter operation.