NVIDIA / NVIDIA/cuda-quantum

Zero-length dynamic control vectors are misinterpreted as scalar controls

Open
#5,331 0 comments 0 reactions 1 assignee View on GitHub

@schweitzpgi is already working on this.

Since Aug 31, 2026.

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

CUDA-Q fails when a dynamically sized control vector is empty. An empty control set should apply the operation without controls, but the runtime instead treats the vector pointer as a scalar qubit pointer.

Steps to reproduce the bug
import cudaq

@cudaq.kernel
def flip_on_slice(v: cudaq.qview, n: int):
    x.ctrl(v[1:n + 1], v[0])

@cudaq.kernel
def controlled(n: int):
    q = cudaq.qvector(n + 1)
    flip_on_slice(q, n)
    mz(q)

print(cudaq.sample(controlled, 0, shots_count=20))
Expected behavior

v[1:1] is an empty control set, so x applies normally to v[0]: { 1:20 }

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

Not a regression

Environment
  • CUDA-Q version: main
  • Python version: N/A
  • C++ compiler: N/A
  • Operating system: N/A
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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.