Process Tomography

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

Runs quantum process tomography using the linear inversion estimation method.

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 a list of inputs and then 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 choi: ndarray[Any, dtype[complex128]]

Returns the calculate choi matrix for a circuit.

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

Calculates fidelity of the calculated choi matrix compared to the expected one.

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

Performs process tomography with the configured elements and calculates the choi matrix using linear inversion.

Returns:

The calculated choi matrix for the process.

Return type:

np.ndarray

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

Runs quantum process tomography using the maximum likelihood estimation method.

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 a list of inputs and then 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 choi: ndarray[Any, dtype[complex128]]

Returns the calculate choi matrix for a circuit.

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

Calculates fidelity of the calculated choi matrix compared to the expected one.

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

Performs process tomography with the configured elements and calculates the choi matrix using maximum likelihood estimation.

Returns:

The calculated choi matrix for the process.

Return type:

np.ndarray

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

Process tomography base class, implements some of the common methods required across different approaches.

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 a list of inputs and then 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[State]], 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.

property n_qubits: int

The number of qubits within the system.

class lightworks.tomography.process_tomography_mle.MLETomographyAlgorithm(n_qubits: int)

Implements the pgdB algorithm for maximum likelihood estimation from https://arxiv.org/abs/1803.10062 for calculation of a physical choi matrix from the tomography measurement data.

Parameters:

n_qubits (int) – The number of qubits used within the tomography.

pgdb(data: dict[tuple[str, str], float], max_iter: int = 1000, stop_threshold: float = 1e-10) ndarray[Any, dtype[complex128]]

Runs the pgdB algorithm on the provided data set.

Parameters:
  • data (dict) – The measured tomography experiment data. The keys of this dictionary should be the input/measurement basis and the values should be the calculated expectation values.

  • max_iter (int, optional) – Sets the maximum number of iterations that the algorithm can do, defaults to 1000.

  • stop_threshold (float, optional) – Sets the stopping threshold for the gradient descent algorithm. Defaults to 1e-10.

Returns:

The calculated choi matrix

Return type:

np.ndarray