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

from_state prepares incorrect state #819

Closed
2 of 3 tasks
poojarao8 opened this issue Oct 24, 2023 · 3 comments
Closed
2 of 3 tasks

from_state prepares incorrect state #819

poojarao8 opened this issue Oct 24, 2023 · 3 comments
Labels
bug Something isn't working
Milestone

Comments

@poojarao8
Copy link
Collaborator

poojarao8 commented Oct 24, 2023

Required prerequisites

  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

The from_state seems to work as expected for up to 2 qubits, but for the 3 and 4 qubit examples I tested, several discrepancies show up. For e.g., the statevector (0,0,0,0,0,0,0,1) should correspond to state |111>, but the sampling result is |110> instead.

Steps to reproduce the bug

import numpy as np

N = 3
state = np.zeros(2**N, dtype=complex)
state[7] = 1. `
print(state)
   

kernel = cudaq.from_state(state)
#extracted_state = cudaq.get_state(kernel) 
#print(extracted_state)
result = cudaq.sample(kernel)
print(result) # you get |110> instead of |111>

Expected behavior

from_state on (0,0,0,0,0,0,0,1) should lead to |111> upon sampling

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment

  • CUDA Quantum version:
  • Python version:
  • C++ compiler:
  • Operating system:

Suggestions

No response

@poojarao8
Copy link
Collaborator Author

This might be my lack of understanding, but I am also confused about what convention we are following here - the little endian or the big endian. When initializing from statevector (0,1,0,0,0,0,0,0), you get |001>. Shouldn't it be |100> as per the cudaq convention? Thank you!

@poojarao8 poojarao8 added the bug Something isn't working label Oct 24, 2023
@poojarao8 poojarao8 added bug Something isn't working and removed bug Something isn't working labels Oct 27, 2023
@bettinaheim bettinaheim added the needs triage Marks items that require a follow up for proper processing label Nov 6, 2023
@bettinaheim bettinaheim added this to the release 0.5.0 milestone Nov 6, 2023
@bettinaheim
Copy link
Collaborator

bettinaheim commented Jan 22, 2024

To be tackled as part of #1086.

@bettinaheim bettinaheim removed the needs triage Marks items that require a follow up for proper processing label Jul 1, 2024
@bettinaheim
Copy link
Collaborator

Closing as obsolete, since we completely revised this functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants