-
Notifications
You must be signed in to change notification settings - Fork 375
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
MPS::apply_multi_qubit_gate can crash in some circumstances #2292
Comments
It seems that the code that follows expects the matrix to be in a single row format if
|
|
I have look at AI and got this : if (is_diagonal) { |
That would be the case if a full matrix is constructed if is_diagonal is true. Looking down on the call path it seems that other functions expect a vector if is_diagonal is true. I'll do a pull request with the fix. Usually moving the tests outside the for is beneficial for performance, too, but in this case it doesn't matter much as the matrices/vectors are small. |
Informations
What is the current behavior?
I was testing the MPS simulator with some randomly generated circuits... with some I've got crashes.
This one I noticed after fixing #2291
The call chain was:
AerState::apply_measure
->AerState::flush_ops
->Base::apply_ops
->MatrixProductState::State::apply_op
->MPS::apply_diagonal_matrix
->MPS::apply_matrix
->MPS::apply_multi_qubit_gate
.It crashed on this line:
qiskit-aer/src/simulators/matrix_product_state/matrix_product_state_internal.cpp
Line 798 in 582407a
is_diagonal
wastrue
(as it should be by looking at the call chain),mat
had 1 row and 8 columns (being a diagonal matrix, only the diagonal is given, so it's actually a vector)... but at that line it's used withmat(row, col)
which is generating the crash.Steps to reproduce the problem
Again, this might be quite tough to reproduce, I was generating some random circuits with more than 100 ops to test some things and maybe one in 100 circuits crashed.
What is the expected behavior?
No crash.
Suggested solutions
The problem lines should probably be replaced by something like:
... or maybe a vector
new_mat
should be constructed ifis_diagonal
istrue
The text was updated successfully, but these errors were encountered: