-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AerState::probability and AerState::amplitude calls for a MPS simulator return the wrong ordering for states #2235
Comments
|
Wait a little bit, I think I fixed it... I'll commit something and then add a comment on what I did. |
A quick and dirty fix. I just modified
Then I added that function simply by copying and altering
The changes are that I simply removed |
Simply altering the original function isn't going to work since that is used elsewhere, too, and it will break some other things. |
…lls for a MPS simulator return the wrong ordering for states"
Informations
Latest dev from main branch.
Irrelevant as it's called from c++ code.
Windows 11
What is the current behavior?
I have a c++ project where I have a test that compares results of my implementation of a MPS simulator with the qiskit aer MPS one. I simply generated random circuits which I applied on the simulators, expecting them to have similar results afterwards.
I tried various approaches for comparisons, one that works on windows (but for some reason crashes on linux) is by using
move_to_vector()
to be able to compare amplitudes... so I tried to switch to some other ways of getting amplitudes/probabilities, to avoid the crash on linux.As a workaround, I tried to go over all base states and call amplitude and/or probability. It turns out that the results do not come as expected, the values seem to be correct but not in the proper order. I know that the MPS simulator must bring together the qubits in order to apply the two or more qubit gates, so it has to map the qubits order as expected from 'outside' to some internal ordering... and I think in there something is not ok when doing the conversion for the amplitude/probability calls.
Steps to reproduce the problem
Execute a circuit with a statevector simulator and the same one with a MPS simulator, try to compare results with amplitude/probability calls.
Another way would be (after fixing #2234) to try to compare the vector obtained by a call to
probabilties()
against values obtained for each basis state withprobability
or with the norm of the value obtained byamplitude
.What is the expected behavior?
Have the same ordering as for the statevector, for example.
Suggested solutions
I couldn't figure out the cause yet, but
move_to_vec
seems to return the expected statevector, maybe this could help.On the other hand, for some reason
move_to_vec
crashes for me on linux... I didn't look into that one yet, I thought I could avoid it by using the mentioned calls.The text was updated successfully, but these errors were encountered: