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

[RFC] qubits with initial states #1110

Closed
schweitzpgi opened this issue Jan 18, 2024 · 1 comment
Closed

[RFC] qubits with initial states #1110

schweitzpgi opened this issue Jan 18, 2024 · 1 comment
Labels
duplicate This issue or pull request already exists RFC Request for Comments

Comments

@schweitzpgi
Copy link
Collaborator

schweitzpgi commented Jan 18, 2024

This is a proposal to add the ability to specify an initial state when declaring a qubit.

C++

We add new constructors to qubit and qvector to take a initializer_list or vector<complex<double>> that is $2^N$ double values in length and where $N$ is the number of qubit in the qvector object. (qubit would be restricted to 2 double values.

New constructors

  qubit::qubit(const vector<complex<double>>&);
  qubit::qubit(const initializer_list<complex<double>>&);
  qvector::qvector(const vector<complex<double>>&);
  qvector::qvector(const initializer_list<complex<double>>&);

Some examples in a CUDA Quake kernel might be the following.

  cudaq::qubit q = {0., 1.};
  cudaq::qubit q = cudaq::ket::one;
  cudaq::qubit q = {M_SQRT1_2, M_SQRT1_2};
  cudaq::qvector q = {M_SQRT1_2, 0., 0., M_SQRT1_2};
  cudaq::qvector q = complexVectorObject;

New builder method

  QuakeValue qalloc(vector<complex<double>> &)

When using the builder the builder would be called as in the following.

  std::vector<cudaq::complex> vec{M_SQRT1_2, 0., 0., M_SQRT1_2};
  auto qubits = kernel.qalloc(vec);

Python

The Python builder would be similar as in the following.

  v = [0., 1., 1., 0.]
  qubits = kernel.qalloc(v)

See #1090

@schweitzpgi schweitzpgi added the RFC Request for Comments label Jan 18, 2024
@bettinaheim bettinaheim added the duplicate This issue or pull request already exists label Jan 22, 2024
@bettinaheim
Copy link
Collaborator

Updated #1086 and closing this as duplicate - RFC will be tracked in #1086.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists RFC Request for Comments
Projects
None yet
Development

No branches or pull requests

2 participants