diff --git a/releasenotes/notes/fix_enabling_cuStateVec-1a2f1d3e35f3129d.yaml b/releasenotes/notes/fix_enabling_cuStateVec-1a2f1d3e35f3129d.yaml new file mode 100644 index 0000000000..470b010622 --- /dev/null +++ b/releasenotes/notes/fix_enabling_cuStateVec-1a2f1d3e35f3129d.yaml @@ -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 diff --git a/src/simulators/density_matrix/densitymatrix_state.hpp b/src/simulators/density_matrix/densitymatrix_state.hpp index 5ce6889d49..7210561a32 100644 --- a/src/simulators/density_matrix/densitymatrix_state.hpp +++ b/src/simulators/density_matrix/densitymatrix_state.hpp @@ -344,6 +344,9 @@ bool State::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; diff --git a/src/simulators/parallel_state_executor.hpp b/src/simulators/parallel_state_executor.hpp index cbae13f521..0635da9ef5 100644 --- a/src/simulators/parallel_state_executor.hpp +++ b/src/simulators/parallel_state_executor.hpp @@ -339,6 +339,7 @@ bool ParallelStateExecutor::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_); @@ -346,6 +347,9 @@ bool ParallelStateExecutor::allocate_states(uint_t num_states, 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( diff --git a/src/simulators/statevector/chunk/cuStateVec_chunk_container.hpp b/src/simulators/statevector/chunk/cuStateVec_chunk_container.hpp index 4baad583da..7da1fc75e2 100644 --- a/src/simulators/statevector/chunk/cuStateVec_chunk_container.hpp +++ b/src/simulators/statevector/chunk/cuStateVec_chunk_container.hpp @@ -131,7 +131,6 @@ uint_t cuStateVecChunkContainer::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; diff --git a/src/simulators/statevector/statevector_state.hpp b/src/simulators/statevector/statevector_state.hpp index 8907bb974c..4cccabc5a8 100755 --- a/src/simulators/statevector/statevector_state.hpp +++ b/src/simulators/statevector/statevector_state.hpp @@ -439,6 +439,9 @@ bool State::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; diff --git a/src/simulators/unitary/unitary_state.hpp b/src/simulators/unitary/unitary_state.hpp index ab0ca636f4..224c96c597 100755 --- a/src/simulators/unitary/unitary_state.hpp +++ b/src/simulators/unitary/unitary_state.hpp @@ -383,6 +383,9 @@ bool State::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;