NVIDIA / NVIDIA/cuda-quantum

[C++] [bridge] `measure_handle`: definite-assignment analysis

Open
#4,479 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Background

PR #4409 introduced a static isBoundHandle walk in lib/Frontend/nvqpp/ConvertExpr.cpp that diagnoses
bool b = h; when h was default-constructed. The check is intentionally narrow and has two known unsoundness gaps, documented inline as "defer to a follow-up.

Gap 1: function arguments

__qpu__ bool f(cudaq::measure_handle h) { return h; }

isBoundHandle short-circuits on BlockArgument SSA values (if (!load) return true;). The bridge silently accepts the discriminate even though the caller may pass a default-constructed handle. Solving requires either per-callee verification at every call site that the argument is bound, or a runtime sentinel check at every quake.discriminate.

Gap 2: aggregate / array per-element tracking

For measure_handle hs[N]; and struct Holder { measure_handle h; };, any store anywhere into the base alloca is treated as binding regardless of which element / member is loaded. Per-cc.compute_ptr-index reasoning needs SSA-value index resolution, deferred from PR #4409.

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 in lib/Frontend/nvqpp/ConvertExpr.cpp by reading the existing isBoundHandle walk and its inline notes about deferred gaps. Trace how BlockArgument values and aggregate or array allocas reach quake.discriminate, then define and validate sound handling for function arguments and per-element or per-member tracking.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.