Skip to content

Conversation

@khalatepradnya
Copy link
Collaborator

@khalatepradnya khalatepradnya commented Nov 19, 2025

This PR refactors several C++ example and application files using sample API by removing explicit measurement instructions (mz(...) / my(...) / mx(...)) from quantum kernels and instead extracting measurement results using marginalization (get_marginal) or direct return values (run).

This demonstrates best practices for using sample as we introduce scoping changes.

  • Removed explicit measurement operations from quantum kernels in multiple files (e.g., bernstein_vazirani.cpp, grover.cpp, ghz examples, and noise modeling examples), relying on default measurement behavior or returning measurement results directly.

  • Updated main functions to extract and analyze measurement results using get_marginal or by using run, ensuring only relevant qubits are considered in the analysis.

  • Improved examples to show best practices for extracting and displaying measurement statistics.

  • Identified examples with mid-circuit measurements that cannot (yet) be converted to run to emit qir-adaptive (Work on simulators)

  • Fix the resource estimation tests

@khalatepradnya khalatepradnya added the breaking change Change breaks backwards compatibility label Nov 19, 2025
github-actions bot pushed a commit that referenced this pull request Nov 19, 2025
@github-actions
Copy link

CUDA Quantum Docs Bot: A preview of the documentation can be found here.

no explicit measurement operation allowed.
For simulators, issue a warning.

Signed-off-by: Pradnya Khalate <[email protected]>
@khalatepradnya khalatepradnya force-pushed the update-sampling-api branch 2 times, most recently from 18945eb to 0bc83e7 Compare December 12, 2025 05:38
@khalatepradnya khalatepradnya force-pushed the update-sampling-api branch 2 times, most recently from 20b9805 to f7490d3 Compare December 12, 2025 17:41
Signed-off-by: Pradnya Khalate <[email protected]>
* No checking of measurement operations in this PR

Signed-off-by: Pradnya Khalate <[email protected]>
@khalatepradnya khalatepradnya changed the title [sample] Detect measurement operations, disallow on hardware targets, warning on simulators [sample] [C++] Updated kernels to not have user-specified measurement ops Dec 16, 2025
@khalatepradnya khalatepradnya removed the breaking change Change breaks backwards compatibility label Dec 16, 2025
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.

1 participant