NVIDIA / NVIDIA/cuda-quantum

`cudaq.from_state` overload should be a member on the kernel builder class

Open
#618 1 comment 0 reactions 5 assignees View on GitHub

@1tnguyen is already working on this.

Since Sep 7, 2023.

enhancement RFC stale-notified
Dominant language
C++
Stars
1.1k
Forks
456
Avg merge
1d 22h
Merged PRs (30d)
165

Description

Required prerequisites
  • Search the issue tracker to check if your feature has already been mentioned or rejected in other issues.
Describe the feature

We have 2 overloads of the cudaq::from_state function. The first, which I believe should remain the same, returns a kernel given a state vector. The second accepts a kernel, a set of qubits, the state, and returns null (cudaq::from_state(Kernel kernel, QuakeValue qubits, ndarray state) -> None). It would make much more sense if this second overload was a member function on the Kernel/kernel_builder type. See:

kernel = cudaq.make_kernel()
qubits = kernel.qalloc()
state = np.array(...)

# It doesn't make sense to have to use a function from the outer cudaq 
# namespace to generate operations within the kernel function body .
cudaq.from_state(kernel, qubits, state)

# Instead:
# The from_state function now takes the kernel as self, and only needs the qubits and state.
kernel.from_state(qubits, state)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.