Support calling kernel_builder<qreg,...> from CUDA Quantum Kernel
Open
@1tnguyen is already working on this.
Since Sep 14, 2023.
enhancement
stale-notified
- Dominant language
- C++
- Stars
- 1.1k
- Forks
- 456
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 165
Description
#include "cudaq.h"
#include "cudaq/builder/kernels.h"
#include <iostream>
struct kernel {
void operator()(auto &&callable) __qpu__ {
cudaq::qreg q(2);
callable(q);
}
};
int main() {
std::vector<std::complex<double>> state{.70710678, 0., 0., 0.70710678};
auto [bell, qubits] = cudaq::make_kernel<cudaq::qreg<> &>();
cudaq::from_state(bell, qubits, state, 2);
std::cout << bell << "\n";
kernel test;
cudaq::sample(test, bell).dump();
}
The issue with this is that a pure-device kernel (bell) created by the kernel_builder does not generate a .thunk function since GenKernelExecution will not add the kernel to the worklist at line 720. So when the callable(q) call happens, kernel_builder::operator()(Args...) is invoked, but fails in the JIT compilation (no thunk, kernelReg, kernelInit, etc), and in invokeCode we'll have no way to call it since there is not thunk.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.