Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix_backend_v2
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Nov 24, 2023
2 parents c3f0cc4 + 3e8ba71 commit 9618e31
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion qiskit_aer/primitives/estimator.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def __init__(
transpile_options: Options passed to transpile.
run_options: Options passed to run.
approximation: If True, it calculates expectation values with normal distribution
approximation.
approximation. Note that this appproximation ignores readout errors.
skip_transpilation: If True, transpilation is skipped.
abelian_grouping: Whether the observable should be grouped into commuting.
If approximation is True, this parameter is ignored and assumed to be False.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fixes:
- |
Extended stabilizer simulation was sharing a single copy of RngEngine amongst
parallelized states in ``ExtendedStabilizer::State::apply_ops_parallel``,
leading to thread safety issue. Now, a new RngEngine is seeded for each parallel
state.
Original file line number Diff line number Diff line change
Expand Up @@ -463,17 +463,24 @@ template <typename InputIterator>
void State::apply_ops_parallel(InputIterator first, InputIterator last,
ExperimentResult &result, RngEngine &rng) {
const int_t NUM_STATES = BaseState::qreg_.get_num_states();

std::vector<size_t> rng_seeds(NUM_STATES);
for (int_t i = 0; i < NUM_STATES; i++) {
rng_seeds[i] = rng.rand_int<size_t>(0, SIZE_MAX);
}

#pragma omp parallel for if (BaseState::qreg_.check_omp_threshold() && \
BaseState::threads_ > 1) \
num_threads(BaseState::threads_)
for (int_t i = 0; i < NUM_STATES; i++) {
if (!BaseState::qreg_.check_eps(i)) {
continue;
}
RngEngine local_rng(rng_seeds[i]);
for (auto it = first; it != last; it++) {
switch (it->type) {
case Operations::OpType::gate:
apply_gate(*it, rng, i);
apply_gate(*it, local_rng, i);
break;
case Operations::OpType::barrier:
case Operations::OpType::qerror_loc:
Expand Down

0 comments on commit 9618e31

Please sign in to comment.