From bb00e69b7598451129749dcb44faaebc63f08bba Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Tue, 21 Nov 2023 15:53:50 +0900 Subject: [PATCH 1/2] reverse ordering of read out error in sampling measure --- .../notes/fix_sample_measure_roerr-747b955aa2bf778c.yaml | 7 +++++++ src/simulators/batch_shots_executor.hpp | 2 +- src/simulators/circuit_executor.hpp | 2 +- src/simulators/multi_state_executor.hpp | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/fix_sample_measure_roerr-747b955aa2bf778c.yaml diff --git a/releasenotes/notes/fix_sample_measure_roerr-747b955aa2bf778c.yaml b/releasenotes/notes/fix_sample_measure_roerr-747b955aa2bf778c.yaml new file mode 100644 index 0000000000..a36e891c3d --- /dev/null +++ b/releasenotes/notes/fix_sample_measure_roerr-747b955aa2bf778c.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixes order of applying read out error in sampling measure + in circuit executors. Ordering is reversed to fit to the older verison + of Aer. + Also fixed check of bacth execution. diff --git a/src/simulators/batch_shots_executor.hpp b/src/simulators/batch_shots_executor.hpp index ec98965846..3b497d9257 100644 --- a/src/simulators/batch_shots_executor.hpp +++ b/src/simulators/batch_shots_executor.hpp @@ -150,7 +150,7 @@ template void BatchShotsExecutor::run_circuit_with_sampling( Circuit &circ, const Config &config, RngEngine &init_rng, ResultItr result_it) { - if (circ.num_bind_params == 1 || !enable_batch_multi_shots_) { + if (enable_batch_multi_shots_) { return Executor::run_circuit_with_sampling(circ, config, init_rng, result_it); } diff --git a/src/simulators/circuit_executor.hpp b/src/simulators/circuit_executor.hpp index 02f00224a6..aa8d70d761 100644 --- a/src/simulators/circuit_executor.hpp +++ b/src/simulators/circuit_executor.hpp @@ -1073,7 +1073,7 @@ void Executor::measure_sampler(InputIterator first_meas, uint_t num_registers = (register_map.empty()) ? 0ULL : 1 + register_map.rbegin()->first; ClassicalRegister creg; - for (int_t i = 0; i < all_samples.size(); i++) { + for (int_t i = all_samples.size() - 1; i >= 0; i--) { creg.initialize(num_memory, num_registers); // process memory bit measurements diff --git a/src/simulators/multi_state_executor.hpp b/src/simulators/multi_state_executor.hpp index 27e533c702..be578c0da3 100644 --- a/src/simulators/multi_state_executor.hpp +++ b/src/simulators/multi_state_executor.hpp @@ -863,7 +863,7 @@ void MultiStateExecutor::measure_sampler(InputIterator first_meas, (memory_map.empty()) ? 0ULL : 1 + memory_map.rbegin()->first; uint_t num_registers = (register_map.empty()) ? 0ULL : 1 + register_map.rbegin()->first; - for (int_t i = 0; i < all_samples.size(); i++) { + for (int_t i = all_samples.size() - 1; i >= 0; i--) { ClassicalRegister creg = state.creg(); // process memory bit measurements From 6df4b07b233efbefa0dd77d4be3b2cd3451b0613 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Tue, 21 Nov 2023 16:15:07 +0900 Subject: [PATCH 2/2] fix batch check --- src/simulators/batch_shots_executor.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/simulators/batch_shots_executor.hpp b/src/simulators/batch_shots_executor.hpp index 3b497d9257..6776bb26de 100644 --- a/src/simulators/batch_shots_executor.hpp +++ b/src/simulators/batch_shots_executor.hpp @@ -150,7 +150,7 @@ template void BatchShotsExecutor::run_circuit_with_sampling( Circuit &circ, const Config &config, RngEngine &init_rng, ResultItr result_it) { - if (enable_batch_multi_shots_) { + if (!enable_batch_multi_shots_) { return Executor::run_circuit_with_sampling(circ, config, init_rng, result_it); }