cudaq.draw raises IndexError (vector::_M_range_check) on kernels with mid-circuit measurement feedback

Open
#5,258 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@VaggelisGian is already working on this.

Since Aug 25, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp, python

Research direction

Start with the supplied cudaq.draw reproducer using the qpp-cpu target and inspect the drawing trace around mid-circuit measurement and classical feedback. Done means the reproducer produces a drawing or a clean documented error instead of the escaping C++ IndexError.

Written by the indexing model from the issue text.

Description

stale-notified

cudaq.draw crashes with a C++ IndexError on kernels containing mid-circuit measurement + classical feedback.

Reproducer (cudaq 0.15.1, PyPI wheels, qpp-cpu):

import cudaq
cudaq.set_target("qpp-cpu")

@cudaq.kernel
def erase_and(q: cudaq.qview):
    h(q[2])
    fired = mz(q[2])
    if fired:
        z.ctrl(q[0], q[1])
        x(q[2])

@cudaq.kernel
def draw_me():
    q = cudaq.qvector(3)
    erase_and(q)

cudaq.draw(draw_me)
# IndexError: vector::_M_range_check: __n (which is 2) >= this->size() (which is 2)

Expected: a drawing (even one that renders the measurement and elides the classical branch), or a clean "cannot draw kernels with classical feedback" error. An IndexError escaping from the C++ layer suggests the trace walks a gate whose operands were registered inconsistently after the measurement.

Severity: crash, diagnostics-only impact — but it removes the most useful debugging tool exactly for the kernels that are hardest to debug.

Dominant language
C++
Stars
1.2k
Forks
508
Avg merge
1d 19h
Merged PRs (30d)
100

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

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.

More from NVIDIA/cuda-quantum

All issues in NVIDIA/cuda-quantum

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.