Using @Aditya's answer and reference, I got an analytical upper bound on the cx
count of exponentiation of a Pauli operator. Note that this method is for a circuit that has full connectivity, i.e. you can apply a two-qubit gate between any two qubits without SWAP
gates. This is only an upper bound as a sequence of PauliEvolutionGate
could have canceling cx
gates.
By looking at the decomposition of the exponentiation of any general $n$-qubit Pauli operator, you can see that there is a cx
gate between each of the qubit where a non-trivial operator is present and the last qubit with non-trivial operator. Here is the code I am using:
def cx_count(pauli: Pauli) -> int:
"""
Counts the number of non-Identity operators in the multi-qubit Pauli
operator and provide an upper bound for cx gate count
"""
count = 0
for p in pauli:
if str(p) == "I":
continue
count += 1
return 2 * (count - 1)
Example
For the Pauli operator XIXXIZI
, there are 3 X
and 1 Z
operators. The decomposition will have 3 H
gates at the beginning to transform X
to Z
. This will be followed by exponentiation of ZIZZIZI
that will have cx
gates to -2nd qubit from 0th, 2nd, and 3rd qubit. This sequence of cx
and H
will be reversed with a rz
gate sandwiched in between.
q_0: ───────────────────────────────────────────────────
┌───┐┌───┐┌───┐┌─────────┐┌───┐┌───┐┌───┐
q_1: ─────┤ X ├┤ X ├┤ X ├┤ Rz(200) ├┤ X ├┤ X ├┤ X ├─────
└─┬─┘└─┬─┘└─┬─┘└─────────┘└─┬─┘└─┬─┘└─┬─┘
q_2: ───────┼────┼────┼───────────────┼────┼────┼───────
┌───┐ │ │ │ │ │ │ ┌───┐
q_3: ┤ H ├──■────┼────┼───────────────┼────┼────■──┤ H ├
├───┤ │ │ │ │ ┌───┐└───┘
q_4: ┤ H ├───────■────┼───────────────┼────■──┤ H ├─────
└───┘ │ │ └───┘
q_5: ─────────────────┼───────────────┼─────────────────
┌───┐ │ │ ┌───┐
q_6: ┤ H ├────────────■───────────────■──┤ H ├──────────
└───┘ └───┘
Sidenote: It could also be decomposed as a chain of cx
, refer to this answer, this matters when your connectivity isn't full.