Sure. Thanks for bringing this nice question! Basically, we have two kinds of fidelity here.

**1. The average gate fidelity:**

$$

F_{avg}(\mathcal{E}, U) = \int \langle \psi|U^\dagger \mathcal{E}(|\psi\rangle\langle\psi|)U|\psi\rangle ~ d\psi, \tag{1}

$$

which calculates the average state fidelity $F(U|\psi\rangle\langle\psi|U^\dagger, \mathcal{E}(|\psi\rangle\langle\psi|))$ among many input states $|\psi\rangle$ (*Haar* just means uniform in most cases). Note $U$ is the ideal unitary quantum gate and $\mathcal{E}$ is the noisy/experimental quantum operation in the language of quantum channels (i.e., trace-preserving completely positive maps as the generalization of quantum gates). A quantum channel can be expressed in the **operator-sum representation**:

$$

\mathcal{E}(\rho) = \sum_k V_k\rho V_k^\dagger, \tag{2}

$$

where {$V_k$} are called **Kraus operators** and satisfies the completeness condition $\sum_k V_k^\dagger V_k = I$. Recall the state fidelity $F$

$$

F(\rho, \sigma) = \big(\text{tr} |\sqrt{\rho} \sqrt{\sigma}| \big)^2 = \bigg(\text{tr}\sqrt{\sqrt{\rho} \sigma \sqrt{\rho}} \bigg)^2, \tag{3}

$$

where the absolute value of an operator is defined as $|U| \equiv \sqrt{U^\dagger U}$. When we use Eq. (1) to experimentally determine the quality of our quantum control technique (how close is the actual quantum process $\mathcal{E}$ and the ideal process $U$), there is an **input state dependence** which is not handy when optimizing in the pulse level.

**Note:** If you want to know more about **Haar measure**, check the following Pennylane post.

**2. The process fidelity**

Let's first write down a more general expression for the process fidelity Eq. (10) from ref [1]:

$$

F_{pro}(\mathcal{E}, U) = \frac{1}{d^2}\sum_k |\text{tr}(U^\dagger V_k)|^2, \tag{4}

$$

where {$V_k$} are the Kraus operators for the actual quantum process $\mathcal{E}$. This metric is originally known as the **entanglement fidelity** $F_e(\mathcal{E})$ of process $\mathcal{E}$ in the literature [2], which **measures how well entanglement with other systems is preserved by the action of $\mathcal{E}$**. A beautiful formula connects $F_{avg}$ and $F_e$ is originally given in ref [3]:

$$

F_{avg}(\mathcal{E}) \equiv F_{avg}(\mathcal{E}, I) = \frac{dF_e(\mathcal{E}) + 1}{d+1}. \tag{5}

$$

This metric can be further generalized into the **gate entanglement fidelity** $F_e(\mathcal{E}, U)$ in ref [4]. The authors further reduce the expression by setting the partial state into a fully mixed state $\rho = I/d$ and finally reach Eq. (4). For details, check IV B in ref [4]. This expression is **state independent** and can be useful when optimizing the pulse level quantum control, although people working in this area often use $||U- V||^2$ as the metric (the operator norm defined as $||U|| \equiv \sqrt{\text{tr}U^\dagger U}$ [5].

**3. Summary**

Experimentally, these two metrics can both be utilized [6]. However, the process fidelity usually requires **Quantum Process Tomography (QPT)** to obtain the characteristic $\chi$ matrix then compare $F_{pro} \propto \text{tr} \big[ \chi_{\text{ideal}^{-1}} \chi \big]$.

Overall, the key idea behind these two metrics is the same. When two unitary operations $U$ and $V$ are identical, we would expect $U^\dagger V=UV^\dagger=I_{d\times d}$. $\dagger$ can be understood as running the quantum circuit backward. Nowadays, the standard tool to charactrize gate errors in a quantum computer is Randomization benchmarking (RB).

**References:**

[1] Fortunato, Evan M., et al. "Design of strongly modulating pulses to implement precise effective Hamiltonians for quantum information processing." *The Journal of chemical physics* 116.17 (2002): 7599-7606.

[2] Nielsen, Michael A. "A simple formula for the average gate fidelity of a quantum dynamical operation." *Physics Letters A* 303.4 (2002): 249-252.

[3] Horodecki, Michał, Paweł Horodecki, and Ryszard Horodecki. "General teleportation channel, singlet fraction, and quasidistillation." *Physical Review A* 60.3 (1999): 1888.

[4] Fortunato, Evan M., et al. "Implementation of universal control on a decoherence-free qubit." *New Journal of Physics* 4.1 (2002): 5.

[5] Wu, Re-Bing, et al. "Data-driven gradient algorithm for high-precision quantum control." *Physical Review A* 97.4 (2018): 042122.

[6] Chow, J. M., et al. "Randomized benchmarking and process tomography for gate errors in a solid-state qubit." *Physical Review Letters* 102.9 (2009): 090502.