Zero-length dynamic control vectors are misinterpreted as scalar controls

Aperta
#5,331 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@schweitzpgi ci sta già lavorando.

Dal 31/8/2026.

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

stale-notified
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

Lingua principale
C++
Stelle
1.2k
Fork
508
Merge medio
1g 19h
PR unite (30g)
100

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di NVIDIA/cuda-quantum

Tutte le issue di NVIDIA/cuda-quantum

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.