merlin.measurement.photon_loss module
Photon loss utilities let you incorporate Perceval NoiseModel instances
directly inside a pcvl.Experiment. The resulting
QuantumLayer automatically inserts a
PhotonLossTransform before any detector
mapping, expanding the classical basis with loss outcomes whilst keeping
probability normalisation intact.
- class merlin.measurement.photon_loss.PhotonLossTransform(simulation_keys, survival_probs, *, dtype=None, device=None)
Bases:
ModuleLinear map applying per-mode photon loss to a Fock probability vector.
- Parameters:
simulation_keys (Sequence[Sequence[int]] | torch.Tensor) – Raw Fock states produced by the simulator.
survival_probs (Sequence[float]) – One survival probability per optical mode.
dtype (torch.dtype | None) – Torch dtype for the transform matrix. Defaults to
torch.float32.device (torch.device | str | None) – Device used to stage the transform matrix.
- forward(distribution)
Apply the photon-loss transform to a Fock probability vector.
- Parameters:
distribution (torch.Tensor) – Fock probability vector.
- Returns:
Probability vector after photon loss as a 1D torch tensor.
- Return type:
- to(*args, **kwargs)
Move the transform to a new device or dtype.
- Parameters:
*args – Positional arguments forwarded to
torch.nn.Module.to().**kwargs – Keyword arguments forwarded to
torch.nn.Module.to().
- Returns:
Updated transform instance.
- Return type:
- merlin.measurement.photon_loss.resolve_photon_loss(experiment, n_modes)
Resolve photon loss from the experiment’s noise model.