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

Error with unnormalized quantum state #1

Open
Nikait opened this issue Jul 26, 2024 · 0 comments
Open

Error with unnormalized quantum state #1

Nikait opened this issue Jul 26, 2024 · 0 comments

Comments

@Nikait
Copy link

Nikait commented Jul 26, 2024

Hello! I've been learning your code (model.py) and noticed a bug in the function below:

def apply_unitaries(base_states, unitary_params, enc, qdev, n_qbs, coeffs):
   repeated_base = base_states.repeat(1, unitary_params.shape[1]).view(-1, 2 ** n_qbs)
   qdev.set_states(repeated_base)

   enc(qdev, unitary_params.view(-1, unitary_params.shape[-1]))
   states = qdev.get_states_1d().view(*unitary_params.shape[:2], 2 ** n_qbs)
   lcs = torch.einsum('bwi,bw->bi', states, coeffs)
   return lcs

After an iteration of QSVT the amplitude vectors of base_states aren't normalized:
For all i=0...repeated_base.shape[0]-1: torch.linalg.vector_norm(repeated_base[i]) != 1.

But the amplitude vector of any quantum state must be normalized...

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

1 participant