Support mx and my over qubit ranges#4750
Open
spital wants to merge 1 commit into
Open
Conversation
Signed-off-by: spital <11034264+spital@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #3334
Summary
This adds the missing C++ overloads that allow
mxandmyto measure qubit ranges such ascudaq::qvector.mzalready supports range,qview, and mixed variadic measurement arguments, butmxandmyonly accepted a singlequbit&. As a result, code such asmx(qubits)ormy(qubits)failed during C++ overload resolution even though the Quake dialect and lowering path already support vector X/Y-basis measurements.The new overloads mirror the existing
mzAPI shape formxandmy:cudaq::qvectorand other qubit rangesqviewoverloadsmx(q, range, q)/my(q, range, q)The range and variadic overloads delegate to the existing single-qubit
mxandmyimplementations. That keeps the basis-change behavior in exactly one place and avoids applying the X/Y basis conversion twice.Context
This follows the review guidance from the earlier closed, unmerged attempt in #2231:
unittests/test/AST-Quakemzmx/myfunctions already perform themThe PR is intentionally limited to the missing public C++ header overloads plus tests. It does not change OpenQASM lowering, Python lowering, or the Quake measurement operations.
Tests
Local validation included targeted compiler/runtime tests and a full CTest pass:
llvm-lit -sv build-source/cudaq/test --filter mx_my_qvector1/1passedMeasureResetTesterCTest run for the new runtime coverage:MeasureResetTester.checkRangeBasisMeasurementsMeasureResetTester.checkMixedBasisOrderingAndPreservation16/16passed across the configured variants1953/1953passed1723.87scudaq-quake+FileCheckfor themx/myqvector test passednvq++compiled and ran an installedmx/myqvector smoke test successfully