What does it mean for a gate to "commute with a measurement"?

I think I understand intuitively what this means. For example, I can apply an $$X$$ gate and then perform a measurement in the $$X$$ basis and I will get the same post-measurement states as if I measured in the $$X$$ basis and then applied an $$X$$ gate. This is not the case for a $$Z$$ gate and $$X$$ measurement.

Mathematically, what is the precise way of stating this property? Does it mean the gate commutes with all the Kraus operators of the measurement channel? This seems like a sufficient condition but is it also a necessary condition?

• Maybe you can deem the measurement process as a quantum channel. Then your question becomes the meaning of two quantum channel commutes. Commented Jul 9 at 12:28

I agree with @Simona99's answer. If you want to formulate it in terms of a quantum channel, consider the quantum channel $$\mathcal{E}[\rho] = \sum_i \Pi_i \rho \Pi_i$$ that corresponds to a measurement of an observable of the form $$O = \sum_i \lambda_i \Pi_i$$ with orthogonal projectors $$\Pi_i$$ and real, distinct eigenvalues $$\lambda_i \neq \lambda_j$$. Further consider the unitary channel $$\mathcal{F}[\rho] = G \rho G^\dagger$$ that applies the unitary gate $$G$$. It is easy to see that, whenever $$[G, \Pi_i] = 0 \, \forall i$$, then also the two channels commute.
Because the Kraus operators of the measurement channel are orthogonal projectors, it is also a necessary condition. If we start with $$[G, O] = 0$$, there exists a common eigenbasis of $$G$$ and $$O$$. As the $$\Pi_i$$ project onto a certain eigensubspace of $$O$$, they also decompose into common eigenvectors, i.e. $$[G, \Pi_i] = 0 \, \forall i$$.
What the channel does not capture is whether the measurement outcome is also conserved, but this can be straight forwardly checked: $${\rm Tr}(G\rho G^\dagger O) = {\rm Tr}(\rho O)$$, if $$[G,O]=0$$.