From 03495efcfcf39f53a185c147e1c7b9be207fa042 Mon Sep 17 00:00:00 2001 From: Adrian Roman Date: Sat, 21 Sep 2024 14:12:14 +0300 Subject: [PATCH 1/2] Fix for https://github.com/Qiskit/qiskit-aer/issues/2234 "Calling AerState::probabilities() crashes for the MPS simulator" --- releasenotes/notes/probabilities-0137851da6c25572.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 releasenotes/notes/probabilities-0137851da6c25572.yaml diff --git a/releasenotes/notes/probabilities-0137851da6c25572.yaml b/releasenotes/notes/probabilities-0137851da6c25572.yaml new file mode 100644 index 0000000000..59fab9b896 --- /dev/null +++ b/releasenotes/notes/probabilities-0137851da6c25572.yaml @@ -0,0 +1,10 @@ +--- +prelude: > + Fixed a crash that occurred when using the MPS simulator, but possibly in + other simulators as well, in AERState::probabilities(). +fixes: + - | + The crash was generated by having op.qubits empty. + Refer to + `#2234 ` for more + information. \ No newline at end of file From fc5eedefe01dd6457eef6d7c73172554dcb02024 Mon Sep 17 00:00:00 2001 From: Adrian Roman Date: Sat, 21 Sep 2024 14:59:07 +0300 Subject: [PATCH 2/2] Forgot to commit the changed source file --- src/controllers/state_controller.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/controllers/state_controller.hpp b/src/controllers/state_controller.hpp index 0977735add..30b1910078 100644 --- a/src/controllers/state_controller.hpp +++ b/src/controllers/state_controller.hpp @@ -1421,6 +1421,9 @@ std::vector AerState::probabilities() { op.string_params.push_back("s"); op.save_type = Operations::DataSubType::list; + for (uint_t i = 0; i < num_of_qubits_; ++i) + op.qubits.push_back(i); + last_result_ = ExperimentResult(); state_->apply_op(op, last_result_, rng_);