Skip to content

Commit

Permalink
Fix number of parallel shots for statevector and unitary sims (#725)
Browse files Browse the repository at this point in the history
* Prevent statevector and unitary controller from running parallel shots

This was causing bugs where number of shots of a statevector and unitary simulators would be the number of CPU cores.
  • Loading branch information
chriseclectic authored May 1, 2020
1 parent dae9a84 commit 6cd0215
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
fixes:
- |
Fixed bug with statevector and unitary simulators running a number of (parallel)
shots equal to the number of CPU threads instead of only running a single shot.
4 changes: 4 additions & 0 deletions src/controllers/statevector_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,10 @@ void StatevectorController::set_config(const json_t& config) {
// Set base controller config
Base::Controller::set_config(config);

// Override max parallel shots to be 1 since this should only be used
// for single shot simulations
Base::Controller::max_parallel_shots_ = 1;

// Add custom initial state
if (JSON::get_value(initial_state_, "initial_statevector", config)) {
// Check initial state is normalized
Expand Down
4 changes: 4 additions & 0 deletions src/controllers/unitary_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ void UnitaryController::set_config(const json_t &config) {
// Set base controller config
Base::Controller::set_config(config);

// Override max parallel shots to be 1 since this should only be used
// for single shot simulations
Base::Controller::max_parallel_shots_ = 1;

// Add custom initial unitary
if (JSON::get_value(initial_unitary_, "initial_unitary", config)) {
// Check initial state is unitary
Expand Down

0 comments on commit 6cd0215

Please sign in to comment.