-
Notifications
You must be signed in to change notification settings - Fork 401
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Informations
- Qiskit Aer version: 0.12.2
- Python version:
- Operating system:
What is the current behavior?
Extended stabilizer uses same random generator among multiple threads without considering thread safety in the parallel section as below
qiskit-aer/src/simulators/extended_stabilizer/extended_stabilizer_state.hpp
Lines 462 to 489 in 5e77fc8
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(); | |
#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; | |
} | |
for (auto it = first; it != last; it++) { | |
switch (it->type) { | |
case Operations::OpType::gate: | |
apply_gate(*it, rng, i); | |
break; | |
case Operations::OpType::barrier: | |
case Operations::OpType::qerror_loc: | |
break; | |
default: | |
throw std::invalid_argument("CH::State::apply_ops_parallel does not " | |
"support operations of the type \'" + | |
it->name + "\'."); | |
break; | |
} | |
} | |
} | |
} |
I think we can not reproduce the same results with the same random seed
Suggested solutions
To get the consistent resault with the same random seed, we have to allocate random generators for each states
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working