NVIDIA / NVIDIA/cuda-quantum

Nested kernels do not work with hardware provider backends

Open
#2,883 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Required prerequisites
  • 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.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • 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

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.

Research direction

Start by running the kernel7 and kernel8 examples against a hardware provider backend, using the issue's nested and non-nested cases as the comparison. Investigate why kernel7 runs indefinitely while kernel8 completes; done means nested controlled kernels complete within a reasonable period on hardware provider backends.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
quantum-computing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.