qiskit-aer icon indicating copy to clipboard operation
qiskit-aer copied to clipboard

MPS simulator with low limits can crash

Open aromanro opened this issue 9 months ago • 0 comments

Informations

  • Qiskit Aer version: Latest development version.
  • Python version: Doesn't matter, the issue was noticed by using qiskit aer from c++
  • Operating system: Windows 11, but it's probably present on all available

What is the current behavior?

It's not a big issue, as it's avoidable, but anyway, I thought I should report it. Setting a big value for the singular values threshold can crash the MPS simulator.

Steps to reproduce the problem

I caught this accidentally by generating and executing random circuits (over 100 gates) on a MPS simulator with 50 qubits, with drastic limits set (something like 15 for max bond dimension and 0.05 for truncation threshold), so it's probably not very easy to reproduce...

A crash that I managed to reproduce happened in csvd, more precisely on this line: https://github.com/Qiskit/qiskit-aer/blob/582407a3f8ef5070c850fb4c417c53c1db1f5998/src/simulators/matrix_product_state/svd.cpp#L203 k had a big value, something like 210310 while size was 4.

A had 4 rows and 0 columns for this case, my guess is that due of the big truncation value somehow along the way one of the dimensions gets 0 and that is the source of the issues.

The problem seems to be generated by the too big truncation threshold, if I set it to a lower value, I cannot reproduce the issue anymore.

What is the expected behavior?

Not crashing, obviously.

Suggested solutions

Probably matrices shouldn't be truncated down to 0 dimension(s), if 0 is obtained it should be changed to 1 or something like that, but this is a wild guess.

aromanro avatar Jan 16 '25 08:01 aromanro