Open 1ucian0 opened 3 years ago
Same for plot_state_paulivec
?
display(plot_state_paulivec(np.array([1, 0])))
display(plot_state_paulivec(np.array([-1, 0])))
It is bot broken per say, but implicitly normalizes the global phase via the largest magnitude component. It has done this since v1 of the qsphere code.
I found this too and figure out it was normalizing as indicated by @nonhermitian. Maybe we can deprecate this behavior in favor of not normalizing. I think the way it is, currently, produces unexpected results, following the implicit normalization, and also goes against the construction of the q-sphere.
At this point, the class DensityMatrix
removes the global phase. Is it intended?
https://github.com/delapuente/qiskit-terra/blob/c3b2d7acb80fa89043e6f38efb501275ec296616/qiskit/quantum_info/states/densitymatrix.py#L98
Would like to also bump this up. In a course while teaching, people where confused why there wasnt a phase change in the QSphere visualization when Y gate was applied to the circuit. It indeed does normalize the phase which confuses a few people when the output on the composer does not really match with the output locally. Would be great if this was fixed!
Found a similar error. Y Gate not flip phase when run on circuit composer while GUI composer show the flip. Also on local computer, it doesn't flip phase.
First three are from circuit composer from IBM-q website, same holds when run on local computer. The last one is GUI based circuit composer which seems to work fine.
Hello,
I also found the same error. Could someone be assigned to the bug?
I want to code the following circuit:
If I code it on IBM Composer, I get the following state vector:
[ 0+0j, 0+0j, 0.707+0j, -0.707+0j ]
The plot of the state vector is:
This corresponds to the following result:
The Python code shown on the IBM Composer is:
OPENQASM 2.0;
include "qelib1.inc";
qreg q[2];
creg c[2];
h q[0];
x q[1];
z q[0];
If I code it on Qiskit, I get the same state vector :
Statevector([ 0.+0.j, 0.+0.j, 0.70710678+0.j, -0.70710678+0.j],
dims=(2, 2))
The plot of the state vector is different, though.
The plot suggests that the result is:
which is incorrect.
The Python code used on Qiskit is:
def create_circuit():
qc = QuantumCircuit(2)
qc.h(0)
qc.x(1)
qc.z(0)
return qc
qc = create_circuit()
sv = Statevector.from_label('00')
sv = sv.evolve(qc)
print(sv)
plot_state_qsphere(sv.data, show_state_labels=True, show_state_phases=True)
There is a bug in the plot of the state vector on Qiskit.
This issues is coming from my attempt to answer this question https://stackoverflow.com/questions/66180030/qiskit-difference-on-statevector-no-difference-on-vizualization
The color of the vector in the second draw should be different .