Skip to content

Commit

Permalink
Fix cuStateVec_enable option (#2146)
Browse files Browse the repository at this point in the history
* Fix cuStateVec_enable option

* fix function name
  • Loading branch information
doichanj authored May 24, 2024
1 parent ba9eb90 commit 83d679e
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
fixes:
- |
The option `cuStateVec_enable=True` was not set correctly.
This fix set this option to statevector, unitary and density_matrix
simulator states classes before allocating their memory
3 changes: 3 additions & 0 deletions src/simulators/density_matrix/densitymatrix_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,9 @@ bool State<densmat_t>::allocate(uint_t num_qubits, uint_t block_bits,
BaseState::qreg_.set_max_sampling_shots(BaseState::max_sampling_shots_);

BaseState::qreg_.set_target_gpus(BaseState::target_gpus_);
#ifdef AER_CUSTATEVEC
BaseState::qreg_.cuStateVec_enable(BaseState::cuStateVec_enable_);
#endif
BaseState::qreg_.chunk_setup(block_bits * 2, block_bits * 2, 0, 1);

return true;
Expand Down
4 changes: 4 additions & 0 deletions src/simulators/parallel_state_executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,17 @@ bool ParallelStateExecutor<state_t>::allocate_states(uint_t num_states,
Base::num_threads_per_group_);
Base::states_[0].set_num_global_qubits(Base::num_qubits_);
#ifdef AER_CUSTATEVEC
Base::states_[0].enable_cuStateVec(Base::cuStateVec_enable_);
Base::states_[0].qreg().cuStateVec_enable(Base::cuStateVec_enable_);
#endif
Base::states_[0].qreg().set_target_gpus(Base::target_gpus_);
num_states_allocated = Base::states_[0].qreg().chunk_setup(
squbits, gqubits, Base::global_state_index_, num_states);
for (i = 1; i < num_states_allocated; i++) {
Base::states_[i].set_config(config);
#ifdef AER_CUSTATEVEC
Base::states_[i].enable_cuStateVec(Base::cuStateVec_enable_);
#endif
Base::states_[i].qreg().chunk_setup(Base::states_[0].qreg(),
Base::global_state_index_ + i);
Base::states_[i].qreg().set_num_threads_per_group(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ uint_t cuStateVecChunkContainer<data_t>::Allocate(
nc = BaseContainer::Allocate(idev, chunk_bits, num_qubits, chunks, buffers,
multi_shots, matrix_bit, max_shots,
density_matrix);

// initialize custatevevtor handle
custatevecStatus_t err;

Expand Down
3 changes: 3 additions & 0 deletions src/simulators/statevector/statevector_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ bool State<statevec_t>::allocate(uint_t num_qubits, uint_t block_bits,
BaseState::qreg_.set_max_sampling_shots(BaseState::max_sampling_shots_);

BaseState::qreg_.set_target_gpus(BaseState::target_gpus_);
#ifdef AER_CUSTATEVEC
BaseState::qreg_.cuStateVec_enable(BaseState::cuStateVec_enable_);
#endif
BaseState::qreg_.chunk_setup(block_bits, num_qubits, 0, 1);

return true;
Expand Down
3 changes: 3 additions & 0 deletions src/simulators/unitary/unitary_state.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,9 @@ bool State<unitary_matrix_t>::allocate(uint_t num_qubits, uint_t block_bits,
BaseState::qreg_.set_max_matrix_bits(BaseState::max_matrix_qubits_);

BaseState::qreg_.set_target_gpus(BaseState::target_gpus_);
#ifdef AER_CUSTATEVEC
BaseState::qreg_.cuStateVec_enable(BaseState::cuStateVec_enable_);
#endif
BaseState::qreg_.chunk_setup(block_bits * 2, num_qubits * 2, 0, 1);

return true;
Expand Down

0 comments on commit 83d679e

Please sign in to comment.