-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Environment
- Qiskit version: dev
- Python version: 3.13
- Operating system: Mac
What is happening?
Visualizing quantum circuits with PauliEvolutionGates draws boxes over all of the qubits used by the gate but ignores the "I"-labels. In particular, the following code snippet:
from qiskit.circuit import QuantumCircuit
from qiskit.quantum_info import SparseObservable
from qiskit.circuit.library import PauliEvolutionGate
evo1 = PauliEvolutionGate(SparseObservable.from_list([("XXII", 1)]), 1)
evo2 = PauliEvolutionGate(SparseObservable.from_list([("IXXI", 1)]), 1)
evo3 = PauliEvolutionGate(SparseObservable.from_list([("IIXX", 1)]), 1)
qc = QuantumCircuit(4)
qc.append(evo1, [0, 1, 2, 3])
qc.append(evo2, [0, 1, 2, 3])
qc.append(evo3, [0, 1, 2, 3])
print(qc)
produces
┌─────────────────┐┌─────────────────┐┌─────────────────┐
q_0: ┤0 ├┤0 ├┤0 ├
│ ││ ││ │
q_1: ┤1 ├┤1 ├┤1 ├
│ exp(-it XX)(1) ││ exp(-it XX)(1) ││ exp(-it XX)(1) │
q_2: ┤2 ├┤2 ├┤2 ├
│ ││ ││ │
q_3: ┤3 ├┤3 ├┤3 ├
└─────────────────┘└─────────────────┘└─────────────────┘
with the three different Pauli evolution gates represented exactly the same. I don't have a very strong opinion about this, but it would helpful to keep the missing "I"s in the label.
There is another possible confusion about the representation in that the circuit qubits correspond to Pauli labels in the reverse order, but this is how we had it all along.
How can we reproduce the issue?
please see the code snippet above
What should happen?
I don't have a strong opinion about this, but I would prefer to see the missing Is, as to understand on which qubits the Pauli bitstring is applied.
Any suggestions?
If this can be considered to be a bug, the solution would be to change _get_default_label
in pauli_evolution.py
. If this is not considered to be a bug, then issue can be closed.