Skip to content

Commit

Permalink
fix a bug in multiple_chunk_required (Qiskit#1282)
Browse files Browse the repository at this point in the history
  • Loading branch information
hhorii authored Jul 15, 2021
1 parent 814dccc commit 45caa49
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
When required memory is smaller than the system memory, multi-chunk was enabled
and simulation was started though memory is short. This fix corrects this behavior
to throw an exception.
19 changes: 13 additions & 6 deletions src/controllers/controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,23 @@ void Controller::set_parallelization_circuit(const Circuit &circ,
}

bool Controller::multiple_chunk_required(const Circuit &circ,
const Noise::NoiseModel &noise) const
{
if(circ.num_qubits < 3)
const Noise::NoiseModel &noise) const {
if (circ.num_qubits < 3)
return false;

if(num_process_per_experiment_ > 1 || Controller::get_min_memory_mb() < required_memory_mb(circ, noise))
if (cache_block_qubit_ >= 2 && cache_block_qubit_ < circ.num_qubits)
return true;

if(cache_block_qubit_ >= 2 && cache_block_qubit_ < circ.num_qubits)
return true;
if(num_process_per_experiment_ == 1 && cache_block_qubit_ >= 2 && num_gpus_ > 0)
return (max_gpu_memory_mb_ / num_gpus_ < required_memory_mb(circ, noise));

if(num_process_per_experiment_ > 1) {
size_t total_mem = max_memory_mb_;
if(cache_block_qubit_ >= 2)
total_mem += max_gpu_memory_mb_;
if(total_mem*num_process_per_experiment_ > required_memory_mb(circ, noise))
return true;
}

return false;
}
Expand Down

0 comments on commit 45caa49

Please sign in to comment.