NVIDIA / NVIDIA/cuda-quantum

Sample with function pointer as input

Open
#354 2 comments 0 reactions 2 assignees View on GitHub

@schweitzpgi is already working on this.

Since Jul 5, 2023.

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

Description

__qpu__ void bar(cudaq::qubit& q) {
  x(q);
}

struct baz {
  __qpu__ void operator()(cudaq::qubit& q) {
    x(q);
  }
};

struct foo {
  template <typename CallableKernel>
  __qpu__ void operator()(CallableKernel &&func, int size) {
    cudaq::qreg q(size);
    func(q[0]);
    mz(q[0]);
  }
};


int main() {
  // Not supported, fails
  auto result = cudaq::sample(1000, foo{}, bar, 1);
}

This can be fixed with an update the sample.h to remove the extra std::forward at line 209.

But this leads to another bug with the argument being valid input to a cuda quantum kernel (error: kernel argument type not supported). The argument type is !cc.ptr<!cc.ptr<(!quake.ref) -> ()>>.

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.