qsttoolkit.tomography Subpackage

This subpackage contains the models for performing quantum state tomography.

Traditional QST

Traditional quantum state tomography is implemented using Maximum Likelihood Estimation (MLE):

Deep Learning QST

Four deep learning models are currently implemented using TensorFlow: one for quantum state discrimination and three for quantum state tomography. Each model has a dedicated class:

Global QST Utility Functions

Functions used in both traditional and deep learning methods for quantum state tomography.

qsttoolkit.tomography.QST.Husimi_Q_measurement_operators(dim: int, xgrid: array, pgrid: array) array[source]

Computes the measurement operators for the Husimi Q function (projectors of all possible coherent operators created from the phase space provided by xgrid and pgrid).

Parameters:
  • dim (int) – Hilbert space dimensionality.

  • xgrid (np.array) – Phase space X quadrature grid.

  • pgrid (np.array) – Phase space P quadrature grid.

Returns:

Measurement operators.

Return type:

np.array

class qsttoolkit.tomography.QST.QuantumStateTomography[source]

Bases: object

A parent class for all quantum state tomography methods.

fidelity(true_dm: ndarray) float[source]

Computes the fidelity between the true and reconstructed density matrices.

Parameters:

true_dm (np.ndarray) – True density matrix.

Returns:

Fidelity between the true and reconstructed density matrices.

Return type:

float

plot_comparison_Hintons(true_dm: ndarray)[source]

Plots Hinton diagrams of the true and reconstructed density matrices.

Parameters:

true_dm (np.ndarray) – True density matrix.

plot_comparison_Husimi_Qs(true_dm: ndarray, xgrid: ndarray, pgrid: ndarray)[source]

Plots the Husimi Q functions of the true and reconstructed density matrices.

Parameters:
  • true_dm (np.ndarray) – True density matrix.

  • xgrid (np.ndarray) – Phase space X quadrature grid.

  • pgrid (np.ndarray) – Phase space P quadrature grid.

plot_comparison_hintons(true_dm: ndarray)[source]

Deprecated alias for plot_comparison_Hintons.

plot_fidelities(true_dm=None)[source]

Plots the fidelity between the true and reconstructed density matrices over epochs.

plot_intermediate_Hintons()[source]

Plots Hinton diagrams of the density matrices in the progress_saves attribute.

plot_intermediate_Husimi_Qs(xgrid: ndarray, pgrid: ndarray)[source]

Plots the Husimi Q functions of the density matrices in the progress_saves attribute.

Parameters:
  • xgrid (np.ndarray) – Phase space X quadrature grid.

  • pgrid (np.ndarray) – Phase space P quadrature grid.

plot_intermediate_hintons()[source]

Deprecated alias for plot_intermediate_Hintons.

plot_losses()[source]

Plots the losses over epochs.

plot_times()[source]

Plots the cumulative time taken for each epoch.

qsttoolkit.tomography.QST.log_likelihood(rho: Tensor, frequency_data: Tensor, measurement_operators: Tensor, L1_reg: float = 0, thresh_reg: float = 0, thresh_reg_threshold: float = 0.01, dim=None) Tensor[source]

Computes the negative log-likelihood of the data given the density matrix.

Parameters:
  • rho (tf.Tensor) – Density matrix.

  • frequency_data (tf.Tensor) – Frequency of each measurement outcome.

  • measurement_operators (tf.Tensor) – Projective measurement operators corresponding to the measurement outcomes.

  • L1_reg (float) – L1 regularisation parameter. Defaults to 0.

  • thresh_reg (float) – Threshold regularisation parameter. Defaults to 0.

  • thresh_reg_threshold (float) – Threshold for the threshold regularisation. Defaults to 0.01.

Returns:

negative log-likelihood of the data given the density matrix.

Return type:

tf.Tensor

qsttoolkit.tomography.QST.measurement_operators(dim: int, measurement_type: str, **kwargs) array[source]

Computes the measurement operators for the specified measurement type.

Parameters:
  • dim (int) – Hilbert space dimensionality.

  • measurement_type (str) – Type of measurement to be performed.

  • **kwargs (dict) – Additional keyword arguments required for specific measurement types.

Returns:

Measurement operators.

Return type:

np.array

qsttoolkit.tomography.QST.parameterise_density_matrix(rho: Tensor) Tensor[source]

Deprecated alias for parametrize_density_matrix.

qsttoolkit.tomography.QST.parametrize_density_matrix(rho: Tensor) Tensor[source]

parametrizes the density matrix using the Cholesky decomposition.

Parameters:

rho (tf.Tensor) – Density matrix to be parametrized.

Returns:

Cholesky decomposition of the density matrix.

Return type:

tf.Tensor

qsttoolkit.tomography.QST.photon_number_measurement_operators(dim: int) array[source]

Computes the measurement operators for photon occupation number measurement.

Parameters:

dim (int) – Hilbert space dimensionality.

Returns:

Measurement operators.

Return type:

np.array

qsttoolkit.tomography.QST.positivity_constraint(params: array) float[source]

Constraint to ensure the density matrix is positive semi-definite.

Parameters:

params (np.array) – Flattened vector of real parameters.

Returns:

Smallest eigenvalue of the reconstructed density matrix.

Return type:

float

qsttoolkit.tomography.QST.reconstruct_density_matrix(params: Tensor, reg: float = 1e-10, dim=None) Tensor[source]

Reconstructs the density matrix from the Cholesky decomposition.

Parameters:

params (tf.Tensor) – Cholesky decomposition of the density matrix.

Returns:

Reconstructed density matrix.

Return type:

tf.Tensor

qsttoolkit.tomography.QST.trace_constraint(params: array) float[source]

Constraint function to ensure the trace of the density matrix is 1.

Parameters:

params (np.array) – Flattened vector of real parameters.

Returns:

Difference between the trace of the reconstructed density matrix and 1.

Return type:

float