c3.libraries.fidelities
¶
Library of fidelity functions.
Module Contents¶
- c3.libraries.fidelities.state_transfer_infid_set(propagators: dict, instructions: dict, index, dims, psi_0, n_eval=-1, proj=True)[source]¶
Mean state transfer infidelity.
- Parameters
propagators (dict) – Contains unitary representations of the gates, identified by a key.
index (int) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
psi_0 (tf.Tensor) – Initial state of the device
proj (boolean) – Project to computational subspace
- Returns
State infidelity, averaged over the gates in propagators
- Return type
tf.float
- c3.libraries.fidelities.state_transfer_infid(ideal: numpy.ndarray, actual: tensorflow.constant, index, dims, psi_0)[source]¶
Single gate state transfer infidelity. The dimensions of psi_0 and ideal need to be compatible and index and dims need to project actual to these same dimensions.
- Parameters
ideal (np.ndarray) – Contains ideal unitary representations of the gate
actual (tf.Tensor) – Contains actual unitary representations of the gate
index (int) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
psi_0 (tf.Tensor) – Initial state
- Returns
State infidelity for the selected gate
- Return type
tf.float
- c3.libraries.fidelities.unitary_infid(ideal: numpy.ndarray, actual: tensorflow.Tensor, index: List[int] = None, dims=None) tensorflow.Tensor [source]¶
Unitary overlap between ideal and actually performed gate.
- Parameters
ideal (np.ndarray) – Ideal or goal unitary representation of the gate.
actual (np.ndarray) – Actual, physical unitary representation of the gate.
index (List[int]) – Index of the qubit(s) in the Hilbert space to be evaluated
gate (str) – One of the keys of propagators, selects the gate to be evaluated
dims (list) – List of dimensions of qubits
- Returns
Unitary fidelity.
- Return type
tf.float
- c3.libraries.fidelities.unitary_infid_set(propagators: dict, instructions: dict, index, dims, n_eval=-1)[source]¶
Mean unitary overlap between ideal and actually performed gate for the gates in propagators.
- Parameters
propagators (dict) – Contains actual unitary representations of the gates, resulting from physical simulation
instructions (dict) – Contains the perfect unitary representations of the gates, identified by a key.
index (List[int]) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
n_eval (int) – Number of evaluation
- Returns
Unitary fidelity.
- Return type
tf.float
- c3.libraries.fidelities.lindbladian_unitary_infid(ideal: numpy.ndarray, actual: tensorflow.constant, index=[0], dims=[2]) tensorflow.constant [source]¶
Variant of the unitary fidelity for the Lindbladian propagator.
- Parameters
ideal (np.ndarray) – Contains ideal unitary representations of the gate
actual (tf.Tensor) – Contains actual unitary representations of the gate
index (List[int]) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
- Returns
Overlap fidelity for the Lindblad propagator.
- Return type
tf.float
- c3.libraries.fidelities.lindbladian_unitary_infid_set(propagators: dict, instructions: Dict[str, c3.signal.gates.Instruction], index, dims, n_eval)[source]¶
Variant of the mean unitary fidelity for the Lindbladian propagator.
- Parameters
propagators (dict) – Contains actual unitary representations of the gates, resulting from physical simulation
instructions (dict) – Contains the perfect unitary representations of the gates, identified by a key.
index (List[int]) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
n_eval (int) – Number of evaluation
- Returns
Mean overlap fidelity for the Lindblad propagator for all gates in propagators.
- Return type
tf.float
- c3.libraries.fidelities.average_infid(ideal: numpy.ndarray, actual: tensorflow.Tensor, index: List[int] = [0], dims=[2]) tensorflow.constant [source]¶
Average fidelity uses the Pauli basis to compare. Thus, perfect gates are always 2x2 (per qubit) and the actual unitary needs to be projected down.
- Parameters
ideal (np.ndarray) – Contains ideal unitary representations of the gate
actual (tf.Tensor) – Contains actual unitary representations of the gate
index (List[int]) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
- c3.libraries.fidelities.average_infid_set(propagators: dict, instructions: dict, index: List[int], dims, n_eval=-1)[source]¶
Mean average fidelity over all gates in propagators.
- Parameters
propagators (dict) – Contains unitary representations of the gates, identified by a key.
index (int) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
proj (boolean) – Project to computational subspace
- Returns
Mean average fidelity
- Return type
tf.float64
- c3.libraries.fidelities.average_infid_seq(propagators: dict, instructions: dict, index, dims, n_eval=-1)[source]¶
Average sequence fidelity over all gates in propagators.
- Parameters
propagators (dict) – Contains unitary representations of the gates, identified by a key.
index (int) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
proj (boolean) – Project to computational subspace
- Returns
Mean average fidelity
- Return type
tf.float64
- c3.libraries.fidelities.lindbladian_average_infid(ideal: numpy.ndarray, actual: tensorflow.constant, index=[0], dims=[2]) tensorflow.constant [source]¶
Average fidelity uses the Pauli basis to compare. Thus, perfect gates are always 2x2 (per qubit) and the actual unitary needs to be projected down.
- Parameters
ideal (np.ndarray) – Contains ideal unitary representations of the gate
actual (tf.Tensor) – Contains actual unitary representations of the gate
index (int) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
- c3.libraries.fidelities.lindbladian_average_infid_set(propagators: dict, instructions: Dict[str, c3.signal.gates.Instruction], index, dims, n_eval)[source]¶
Mean average fidelity over all gates in propagators.
- Parameters
propagators (dict) – Contains unitary representations of the gates, identified by a key.
index (int) – Index of the qubit(s) in the Hilbert space to be evaluated
dims (list) – List of dimensions of qubits
proj (boolean) – Project to computational subspace
- Returns
Mean average fidelity
- Return type
tf.float64