Skip to content

[DNM] Adopt cudaq::measure_handle#528

Draft
khalatepradnya wants to merge 12 commits into
NVIDIA:mainfrom
khalatepradnya:pkhalate/measure-handle-cudaq-pr3b-companion
Draft

[DNM] Adopt cudaq::measure_handle#528
khalatepradnya wants to merge 12 commits into
NVIDIA:mainfrom
khalatepradnya:pkhalate/measure-handle-cudaq-pr3b-companion

Conversation

@khalatepradnya
Copy link
Copy Markdown
Collaborator

@khalatepradnya khalatepradnya commented May 2, 2026

  • Based on CUDA-Q PR #4439
  • measure_result -> measure_handle migration.
  • Bring CUDA-QX in alignment.

…syndromes to vector<bool>

CUDA-Q PR #4409 (`pkhalate/measure-handle-pr3b-cpp-frontend`) is the
first source-breaking change in the `measure_result` -> `measure_handle`
migration. Bring CUDA-QX in alignment.

Changes:

- `.cudaq_version` -> `2914390720` (PR 3b head).
- `enqueue_syndromes` signature: `std::vector<cudaq::measure_result>` ->
  `std::vector<bool>` in `decoding.h` plus the two device-side
  implementations. The replay-mode caller in
  `surface_code-1.cpp:787` previously constructed
  `cudaq::measure_result(uint8_t)` from raw saved syndrome bits; the
  Option C alias in CUDA-Q rebinds `measure_result` to `measure_handle`,
  which has no `int` constructor by design (handles carry measurement
  identity, not values). The cleanest resolution is to acknowledge that
  what crosses the host-device boundary in this API is a sequence of
  syndrome *bits*, not measurement events.
- `__qpu__` callers in `surface_code-{1,2,3}.cpp` and
  `real_time_complete.cpp` wrap their handle vectors with
  `cudaq::to_bools(...)` at the call site (preserving handle storage
  shape inside the kernel; explicit discrimination at the API edge).
- `to_integer(mz(...))` sites in `surface_code-1.cpp:438`,
  `surface_code-2.cpp:325`, and `real_time_complete.cpp:125` updated
  to `cudaq::to_integer(cudaq::to_bools(mz(...)))` to match PR 3b's
  `[bridge] Reject to_integer(mz(...))` rule.

Local sanity:

- `cmake -DCUDAQX_ENABLE_LIBS=qec -DCUDAQX_INCLUDE_TESTS=OFF` qec
  library builds clean against installed CUDA-Q from PR 3b head. All 6
  device .o files (`repetition_device`, `steane_device`,
  `surface_code_device`, `memory_circuit`, `quantinuum_device`,
  `simulation_device`) link.
- `nvq++ -fsyntax-only` on `surface_code-{1,2,3}.cpp` and
  `real_time_complete.cpp` succeeds end to end.
- TESTS=ON build is blocked locally on TensorRT, so the test-app
  link/run path is verified by CI.
- Pre-existing `dem_sampling_gpu.cpp` cuStabilizer link errors are
  unrelated.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Comment thread .cudaq_version Outdated
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
@khalatepradnya
Copy link
Copy Markdown
Collaborator Author

/ok to test bdfb537

khalatepradnya and others added 6 commits May 5, 2026 12:58
…_test API

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Fix for error seen in CI
  RuntimeError: Failed to locate init function
  'function_enqueue_syndromes.<...>IbSaIbEEm.init_func' in decoder
  library at libcudaq-qec-realtime-decoding-simulation.so

Update the string to match.

`enqueue_syndromes_test` is intentionally not added to the list: it is
only used by the C++ host-side replay path, which does not go through
the dlopen/dlclose reload cycle this loader defends against.

Co-authored-by: Cursor <cursoragent@cursor.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
* Needs LLVM 22 update!

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Comment thread .cudaq_version Outdated
"cudaq": {
"repository": "NVIDIA/cuda-quantum",
"ref": "e47b30b4d50385b97284fb124f33d3e370107fb2"
"ref": "bb93f26df2ccb5300190318425dc08bd52b60e2e"
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This currently pointing to my dev branch, but should be updated to CUDA-Q commit ID once it is merged.

khalatepradnya added a commit to khalatepradnya/cuda-quantum that referenced this pull request May 13, 2026
…ures

A callable parameter's signature is a device-side type contract for the
callable's body, not a slot for a handle value: the host marshals only
the function-pointer payload, and any handle the callable produces or
consumes lives entirely on the device side. PR 3b previously gated the
entry-point boundary classifier with `includeCallables=true`, which
walked into callable signatures and rejected
`qkernel<vector<measure_handle>(...)>` parameters even though no handle
ever crossed the boundary as data.
`cudaq::cc::containsMeasureHandle` now stops at callable / FunctionType
boundaries, matching what the marshalling layer (Marshal.cpp:776/779)
already did with the default. The `includeCallables` knob had zero
non-default consumers and is removed.
Surfaced by the cudaqx QEC companion (NVIDIA/cudaqx#528): stabilizer-
round callbacks declared `qkernel<vector<measure_handle>(patch, ...)>`
are passed as parameters to entry-point kernels (memory_circuit_mz),
where they are invoked entirely on device.
Tests:
  - test/AST-Quake/measure_handle.cpp: positive lowering coverage for
    callable parameters whose signatures mention measure_handle (both
    return-handle and take-handle shapes); kernel is marked
    `cudaq-entrypoint`, not silently demoted.
  - test/AST-error/measure_handle.cpp: removed the two callable-shape
    rejection cases (BoundaryFunctionTypeParam, BoundaryQkernelParam).
    Existing data-shape rejection cases (vector / tuple / aggregate /
    pointer / reference) cover the negative side and remain.

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
khalatepradnya and others added 4 commits May 12, 2026 18:26
Aligns the companion PR with the rebased PR 3c head
(f0aa11751c on pkhalate/measure-handle-pr3c-python-frontend),
which carries:
  - PR 3b A1 follow-up: relaxed entry-point boundary check so
    `qkernel<vector<measure_handle>(...)>` callable parameters
    are admissible (function-pointer payload, not handle data,
    crosses the host-device boundary).
  - PR 3c follow-up: matching Python `containsMeasureHandle`
    relaxation.

Local verification: cudaq-qec library and
cudaq-qec_memory_circuit.o build clean against the new
cuda-quantum HEAD via cmake --install + ninja qec-only.

Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Signed-off-by: Pradnya Khalate <pkhalate@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants