0

First I made the circuit in jupyter notebook and ran it. Then I did the same thing in the IBM Quantum Composer, but I got different phases. Circuit in jupyter notebook Results in jupyter notebook Circuit and results in Quantum Composer

For the jupyter notebook version, I got a phase of 0 for the |111> state and a phase of pi for the |011> state.

On the Quantum Composer I got a phase of pi for the |111> state and a phase of 0 for the |011> state.

I have ran both the jupyter notebook and the Quantum Composer several times. I don't see any difference between the circuit from jupyter notebook and the circuit from the Quantum Composer. I believe the problem is in the jupyter notebook, because the results from the Quantum Composer seem right.

Here again is the code from my jupyter notebook:

qc = QuantumCircuit(3)
qc.x(0)
qc.x(1)
qc.h(2)
theta = pi/2
qc.cp(theta,1,2)
qc.cx(0,1)
qc.cp(-theta,1,2)
qc.cx(0,1)
qc.cp(theta,0,2)
qc.draw(output='mpl')


qc.save_statevector()
q = assemble(qc)
result = sim.run(q).result().get_statevector()
plot_state_qsphere(result)

I've imported:

from qiskit import *
%matplotlib inline
from qiskit.visualization import *

Simulator:

sim = Aer.get_backend('aer_simulator')

Quantum Composer:

OPENQASM 2.0;
include "qelib1.inc";

qreg q[3];
creg c[3];

x q[0];
x q[1];
h q[2];
cp(pi/2) q[1],q[2];
cx q[0],q[1];
cp(-pi/2) q[1],q[2];
cx q[0],q[1];
cp(pi/2) q[0],q[2];
  • No comment on what the correct behavior should be, but this phase difference is physically immaterial: the two states differ from one another by "global phase", i.e., by multiplication by -1. – Eric Peterson Jul 21 '21 at 20:03
  • 1
    @EricPeterson Thanks for your answer, but I believe the global phase can have an impact on the circuit's behaviour in some cases, for example when a hadamard gate is applied. Suppose you have 2 circuits, circuit 1 with a hadamard gate followed by not gate and circuit 2 with a hamadard gate followed by a not gate, followed by a Z gate. The only difference is the global phase, but when a hadamard gate is applied to both of the circuits, circuit 1 goes in the 0 state and circuit 2 goes in the 1 state. Even if this wouldn't be true, I still don't see why there would be inconsistencies. – schittering06 Jul 22 '21 at 15:28
  • The two intermediate states you name don't differ by global phase: the first has the form |0> + |1>, the second |0> - |1>, and there is not a constant c so that |0> + |1> = c * (|0> - |1>). The situation in the main question is different: there _is_ a constant c so that -|0> + |1>= c * (|0> - |1>). – Eric Peterson Jul 22 '21 at 17:28
  • It's not just software packages that might display discrepancies about global phase: the mathematics _itself_ is defined to ignore global phase discrepancies. Neither the expression |0> - |1> nor the expression -|0> + |1> is really "a state"; they're both representatives of a state — the same state — rather like x^2 - 1 and (x + 1)(x - 1) look literally different but define the same polynomial. Accordingly, software packages sometimes fluidly move from one representative to the other, since there isn't actually a discrepancy to be encumbered by. – Eric Peterson Jul 22 '21 at 17:35

0 Answers0