Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default constructor of QubitRegister not working properly #91

Open
snsunx opened this issue May 26, 2023 · 2 comments
Open

Default constructor of QubitRegister not working properly #91

snsunx opened this issue May 26, 2023 · 2 comments

Comments

@snsunx
Copy link

snsunx commented May 26, 2023

I'm trying to simulate a quantum system with Intel QS and need to declare a QubitRegister before initializing it with the number of qubits. However, the default constructor of QubitRegister does not seem to work properly. After including <qureg.hpp>, simply doing

iqs::QubitRegister<ComplexDP> psi;

will throw an error. The error occurs at the checking statement if(GlobalSize()) assert(GlobalSize() * 2UL == new_num_amplitudes);, but after disabling this checking statement other errors come up in num_qubits and in using state vs state_storage.

I'd like to propose the following changes: we should comment out Line 60 of qureg_init.cpp and change Line 38-39 from

Resize(1UL);
state_storage[0] = {1., 0.};

to

Resize(2UL);
state[0] = {1., 0.};

Changing these three lines and rebuilding the library worked for me. These changes also seem consistent with the rest of the QubitRegister class.

@giangiac
Copy link
Contributor

giangiac commented Jun 7, 2023

Hi @snsunx ,

Thanks for looking into the issue and suggesting a fix.
Indeed QubitRegister objects were thought to be initialized with a specific number of qubits.
There is a method to resize the register, but it is not up to date with the rest of the implementation.

I will look into your suggested fix (by the way, have you tested it with MPI enabled?).

As part of the IQS development, we worked on a different approach.
We worked on a method to resize the state register by either adding extra qubits in the |00...0> state, or by removing qubits after projecting them to |00...0><00...0|.
It is MPI-ready and we should be able to open the corresponding PR soon.

@snsunx
Copy link
Author

snsunx commented Jun 12, 2023

I tested it with MPI enabled and also wrote a unit test in unit_test/include/one_qubit_register_test.hpp. I will open a PR soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants