The lab module is all you need to construct and simulate photonic circuits. It contains the items you’d find in a lab:

  • states (Vacuum, Coherent, SqueezedVacuum, Thermal, etc.)

  • transformations (Sgate, BSgate, LossChannel, etc.)

  • detectors (PNRDetector, Homodyne, etc.)

  • the Circuit class


AdditiveNoise([noise, noise_trainable, ...])

The additive noise channel.

Amplifier([gain, nbar, gain_trainable, ...])

The noisy amplifier channel.

Attenuator([transmissivity, nbar, ...])

The noisy attenuator channel.

BSgate([theta, phi, theta_trainable, ...])

Beam splitter gate.

CXgate([s, s_trainable, s_bounds, modes])

Controlled X gate.

CZgate([s, s_trainable, s_bounds, modes])

Controlled Z gate.


Represents a quantum circuit: a set of operations to be applied on quantum states.

Coherent([x, y, x_trainable, y_trainable, ...])

The N-mode coherent state.

Dgate([x, y, x_trainable, y_trainable, ...])

Displacement gate.

DisplacedSqueezed([r, phi, x, y, ...])

The N-mode displaced squeezed state.

Fock(n[, modes, cutoffs, normalize])

The N-mode Fock state.

Gaussian(num_modes[, symplectic, ...])

The N-mode Gaussian state parametrized by a symplectic matrix and N symplectic eigenvalues.

Generaldyne(state[, outcome, modes])

Generaldyne measurement on given modes.

Ggate(num_modes[, symplectic, ...])

A generic N-mode Gaussian unitary transformation with zero displacement.

Heterodyne([x, y, modes])

Heterodyne measurement on given modes.

Homodyne(quadrature_angle[, result, modes, r])

Homodyne measurement on given modes.

Interferometer(num_modes[, unitary, ...])

N-mode interferometer.

MZgate([phi_a, phi_b, phi_a_trainable, ...])

Mach-Zehnder gate.

PNRDetector([efficiency, dark_counts, ...])

Photon Number Resolving detector.

Pgate([shearing, shearing_trainable, ...])

Quadratic phase gate.

PhaseNoise([phase_stdev, ...])

The phase noise channel.

RealInterferometer(num_modes[, orthogonal, ...])

N-mode interferometer parametrized by an NxN orthogonal matrix (or 2N x 2N block-diagonal orthogonal matrix).

Rgate([angle, angle_trainable, ...])

Rotation gate.

S2gate([r, phi, r_trainable, phi_trainable, ...])

Two-mode squeezing gate.

Sgate([r, phi, r_trainable, phi_trainable, ...])

Squeezing gate.

SqueezedVacuum([r, phi, r_trainable, ...])

The N-mode squeezed vacuum state.

State([cov, means, eigenvalues, symplectic, ...])

Base class for quantum states.

TMSV([r, phi, r_trainable, phi_trainable, ...])

The 2-mode squeezed vacuum state.

Thermal([nbar, nbar_trainable, nbar_bounds, ...])

The N-mode thermal state.

ThresholdDetector([efficiency, ...])

Threshold detector: any Fock component other than vacuum counts toward a click in the detector.


The N-mode vacuum state.

Class Inheritance Diagram

Inheritance diagram of mrmustard.lab.gates.AdditiveNoise, mrmustard.lab.gates.Amplifier, mrmustard.lab.gates.Attenuator, mrmustard.lab.gates.BSgate, mrmustard.lab.gates.CXgate, mrmustard.lab.gates.CZgate, mrmustard.lab.circuit.Circuit, mrmustard.lab.states.Coherent, mrmustard.lab.gates.Dgate, mrmustard.lab.states.DisplacedSqueezed, mrmustard.lab.states.Fock, mrmustard.lab.states.Gaussian, mrmustard.lab.detectors.Generaldyne, mrmustard.lab.gates.Ggate, mrmustard.lab.detectors.Heterodyne, mrmustard.lab.detectors.Homodyne, mrmustard.lab.gates.Interferometer, mrmustard.lab.gates.MZgate, mrmustard.lab.detectors.PNRDetector, mrmustard.lab.gates.Pgate, mrmustard.lab.gates.PhaseNoise, mrmustard.lab.gates.RealInterferometer, mrmustard.lab.gates.Rgate, mrmustard.lab.gates.S2gate, mrmustard.lab.gates.Sgate, mrmustard.lab.states.SqueezedVacuum, mrmustard.lab.abstract.state.State, mrmustard.lab.states.TMSV, mrmustard.lab.states.Thermal, mrmustard.lab.detectors.ThresholdDetector, mrmustard.lab.states.Vacuum