Skip to content

Support mx and my over qubit ranges#4750

Open
spital wants to merge 1 commit into
NVIDIA:mainfrom
spital:fix-qvector-mx-my
Open

Support mx and my over qubit ranges#4750
spital wants to merge 1 commit into
NVIDIA:mainfrom
spital:fix-qvector-mx-my

Conversation

@spital

@spital spital commented Jun 18, 2026

Copy link
Copy Markdown

Fixes #3334

Summary

This adds the missing C++ overloads that allow mx and my to measure qubit ranges such as cudaq::qvector.

mz already supports range, qview, and mixed variadic measurement arguments, but mx and my only accepted a single qubit&. As a result, code such as mx(qubits) or my(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 mz API shape for mx and my:

  • range overloads, covering cudaq::qvector and other qubit ranges
  • qview overloads
  • mixed variadic overloads such as mx(q, range, q) / my(q, range, q)

The range and variadic overloads delegate to the existing single-qubit mx and my implementations. 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:

  • add runtime coverage under unittests/
  • add FileCheck coverage under test/AST-Quake
  • use the issue reproducer shape as test input
  • implement the same overload family that already exists for mz
  • avoid adding basis-change operations in the range overloads because the scalar mx/my functions already perform them

The 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_qvector
    • 1/1 passed
  • Targeted MeasureResetTester CTest run for the new runtime coverage:
    • MeasureResetTester.checkRangeBasisMeasurements
    • MeasureResetTester.checkMixedBasisOrderingAndPreservation
    • 16/16 passed across the configured variants
  • Full CTest suite:
    • 1953/1953 passed
    • final run time: 1723.87s
    • only expected unavailable-backend / MPI tests were skipped
  • Installed toolchain smoke tests:
    • cudaq-quake + FileCheck for the mx/my qvector test passed
    • nvq++ compiled and ran an installed mx/my qvector smoke test successfully

Signed-off-by: spital <11034264+spital@users.noreply.github.com>
@copy-pr-bot

copy-pr-bot Bot commented Jun 18, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

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.

[QEC Support] mx and my are not supported for ranges of qubits

1 participant