NVIDIA / NVIDIA/cuda-quantum

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

Open
#3,334 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Required prerequisites
  • Consult the security policy. If reporting a security vulnerability, do not report the bug using this form. Use the process described in the policy to report the issue.
  • Make sure you've read the documentation. Your issue may be addressed there.
  • Search the issue tracker to verify that this hasn't already been reported. +1 or comment there if it has.
  • If possible, make a PR with a failing test to give us a starting point to work on!
Describe the bug

While trying to write QEC codes, I ran into the problem of having to write different data qubit measurements in the loop. For larger-scale codes, it would be ideal to have all the basic types of measurements implemented, especially to make it more intuitive for the user.

Steps to reproduce the bug
#include <cstdio>
#include <cudaq.h>


__qpu__ int test(int num_qubits) {

  cudaq::qvector qubits(num_qubits);

  h(qubits[0]);
  auto bits = mx(qubits);

  int result = 0;
  for (int i = 0; i < num_qubits; i++) {
    if (bits[i]) {
      result += 1;
    }
  }
  return result;
}

int main() {

  auto results = cudaq::run(20, test, 3);

  
  return 0;
}

The error:

root@567... :/workspaces/cuda-qx-p/build# nvq++ /workspaces/cuda-qx-p/build/mini.cpp -o mini_check
mini.cpp:10:15: error: no matching function for call to 'mx'
auto bits = mx(qubits);
^~
/usr/local/cudaq/include/cudaq/qis/qubit_qis.h:768:23: note: candidate function not viable: no known conversion from 'cudaq::qvector<>' to 'qubit &' (aka 'qudit<2> &') for 1st argument
inline measure_result mx(qubit &q) {
^
error: C++ source has errors. nvq++ cannot proceed.

Expected behavior

Successful compilation and execution.

Is this a regression? If it is, put the last known working version (or commit) here.

Not a regression

Environment
Suggestions

No response

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 by reproducing the compilation failure with the C++ example and inspect cudaq/qis/qubit_qis.h, where the issue identifies the single-qubit mx overload. Check how measurement APIs handle qvector ranges and verify that both mx and my support the requested range usage, then confirm the example compiles and executes successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
quantum-computing
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.