cuda-quantum icon indicating copy to clipboard operation
cuda-quantum copied to clipboard

Nested kernels do not work with hardware provider backends

Open sacpis opened this issue 8 months ago • 1 comments

Required prerequisites

  • [x] Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • [x] Make sure you've read the documentation. Your issue may be addressed there.
  • [x] Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • [x] If possible, make a PR with a failing test to give us a starting point to work on!

Describe the bug

Nested kernels do not work with hardware provider backends. It just keeps on running indefinitely.

Following code does not work with any backend (example, quantinuum)

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

// A kernel that will call `x_kernel` as a controlled operation.
void kernel7() __qpu__ {
  cudaq::qvector control_vector(2);
  cudaq::qubit target;

  x(control_vector);
  x(target);
  x(control_vector[1]);
  cudaq::control(x_kernel, control_vector, target);
}

but this one, equivalent (non-nested) to the above, works

void kernel8() __qpu__ {
  cudaq::qvector qvector(3);

  x(qvector);
  x(qvector[1]);
  x<cudaq::ctrl>(qvector[0], qvector[1]);
  mz(qvector);
}

Steps to reproduce the bug

Run the above examples with any hardware provider backend.

Expected behavior

Should run within a certain period.

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

Not a regression

Environment

  • CUDA-Q version:
  • Python version: 3.10
  • C++ compiler:
  • Operating system: Ubuntu

Suggestions

No response

sacpis avatar May 07 '25 20:05 sacpis

related issues:

  • #2803
  • #2485

potentially related issues:

  • #2535
  • #2346
  • #2137

OliverAh avatar May 15 '25 14:05 OliverAh