average_gate_fidelity

SimulationResult.average_gate_fidelity(shot='avg', basis='product', frame='rotating', ancilla_state=None)

Return the average gate fidelity. Compare the final time evolution operator in the qubit subspace in the given frame and bases, and the ideal_unitary_matrix.

Parameters:
  • shot (str | int | List[int]) – Specify the shot by its index or indices, or use 'avg' or 'all'.

  • basis (str) – Specify the basis, must be either 'product' or 'eigen'.

  • frame (str) – Specify the frame, must be either 'lab' or 'rotating'.

  • ancilla_state (dict | None) – Specify the spins used as ancilla qubits and their respective initial states.

Returns:

Average gate fidelity or fidelities.

Note

The average gate fidelity is calculated as

\[F = \frac{| \text{Tr}(U_\text{ideal}^{\dagger} U_\text{subspace}) |^2 / d + 1}{d + 1},\]

where \(d = 2^N\) is the dimension of the computational subspace, \(U_\text{ideal}\) is the ideal (target) unitary operation, and \(U_\text{subspace}\) is the actual evolution projected onto the computational subspace.

If an ancilla qubit is present, the reduced operator is obtained by fixing the ancilla in its reference state (e.g., \(|0\rangle\)) and tracing it out:

\[U_r = \mathrm{Tr}_{\text{ancilla}} \Big[ (|0\rangle\langle 0| \otimes \mathbb{1}_{N-1}) \, U \, (|0\rangle\langle 0| \otimes \mathbb{1}_{N-1}) \Big],\]

where \(U\) is the operator including the ancilla, and \(U_r\) is the reduced operator acting only on the \(N-1\) qubit subspace, which is used in the fidelity calculation.