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

Improve get_state functionality #822

Closed
3 tasks done
zohimchandani opened this issue Oct 25, 2023 · 2 comments
Closed
3 tasks done

Improve get_state functionality #822

zohimchandani opened this issue Oct 25, 2023 · 2 comments

Comments

@zohimchandani
Copy link
Collaborator

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


import cudaq 

kernel = cudaq.make_kernel()

qubits = kernel.qalloc(2)

kernel.x(qubits[0])
kernel.x(qubits[0])

state = cudaq.get_state(kernel)

state.dump()
1+0j 0+0j 0+0j 0+0j 

The code above dumps the state but the output can't be manipulated as it does not have a type. I suggest it be dictionary where the keys are the basis states and the values are the complex amplitudes.

Moreover, it is not clear that the basis state ordering starts from the 11 state. A dictonary key value mapping would solve that too.

Steps to reproduce the bug

NA

Expected behavior

NA

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

Not a regression

Environment

Suggestions

No response

@zohimchandani
Copy link
Collaborator Author

zohimchandani commented Oct 25, 2023

The issue of manipulating the coefficients can be solved by this:

import cudaq 
import numpy as np 

kernel = cudaq.make_kernel()

qubits = kernel.qalloc(2)

kernel.x(qubits[0])
kernel.x(qubits[0])

state = cudaq.get_state(kernel)

npa = np.array(state)

however the labelling of the basis states still remains and I suggest a dictionary style structure to represent this information.

@bettinaheim
Copy link
Collaborator

addressed by #1107

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