State Tomography

class lightworks.tomography.StateTomography(n_qubits: int, base_circuit: PhotonicCircuit, experiment: Callable[[list[PhotonicCircuit]], list[dict[State, int]]], experiment_args: list[Any] | None = None)

Generates the required circuit and performs data processing for the calculation of the density matrix of a state.

Parameters:
  • n_qubits (int) – The number of qubits that will be used as part of the tomography.

  • base_circuit (PhotonicCircuit) – An initial circuit which produces the required output state and can be modified for performing tomography. It is required that the number of circuit input modes equals 2 * the number of qubits.

  • experiment (Callable) – A function for performing the required tomography experiments. This should accept a list of circuits and return a list of results to process.

  • experiment_args (list | None) – Optionally provide additional arguments which will be passed directly to the experiment function.

property base_circuit: PhotonicCircuit

The base circuit which is to be modified as part of the tomography calculations.

property experiment: Callable[[list[PhotonicCircuit]], list[dict[State, int]]]

A function to call which runs the required experiments. This should accept a list of circuits as a single argument and then return a list of the corresponding results, with each result being a dictionary or Results object containing output states and counts.

fidelity(rho_exp: ndarray[Any, dtype[complex128]]) float

Calculates the fidelity of the calculated quantum state against the expected density matrix for the state.

Parameters:

rho_exp (np.ndarray) – The expected density matrix.

Returns:

The calculated fidelity value.

Return type:

float

property n_qubits: int

The number of qubits within the system.

process() ndarray[Any, dtype[complex128]]

Performs the state tomography process with the configured elements to calculate the density matrix of the output state.

Returns:

The calculated density matrix from the state tomography

process.

Return type:

np.ndarray

property rho: ndarray[Any, dtype[complex128]]

The most recently calculated density matrix.