Skip to content

Support std::vector<measure_handle>::operator= in kernels #4601

@khalatepradnya

Description

@khalatepradnya

Summary

Enable the QEC vectorized cross-round detector patterns shown below. They are the vectorized counterparts to the scalar prev_s0 = s0; idiom from the internal spec, and they do not compile today.

Examples to enable

C++ — vectorized cross-round, local-only (loop)

#include <cudaq.h>
#include <vector>
__qpu__ void rep_code_vectorized(int nRounds) {
  cudaq::qvector ancillas(2);
  auto prev = mz(ancillas);
  for (int r = 1; r < nRounds; r++) {
    auto curr = mz(ancillas);
    cudaq::detectors(prev, curr);
    prev = curr;                    // carry current round forward
  }
}

C++ — vectorized cross-round with reference parameter

#include <cudaq.h>
#include <vector>
__qpu__ void surface_code_round(cudaq::qvector<>& data,
                                cudaq::qvector<>& ancillas,
                                std::vector<cudaq::measure_result>& prev) {
  auto syndromes = mz(ancillas);
  cudaq::detectors(prev, syndromes);
  prev = syndromes;                 // update caller's `prev` for next round
}

Current Behavior

Compilation fails

$ cudaq-quake rep_code_vectorized.cpp
error: ../cudaq/lib/Frontend/nvqpp/ConvertExpr.cpp:1595: not yet implemented: unhandled std::vector member function, operator=
LLVM ERROR: fatal error, aborting.

Expected Behavior

Program compiles and runs successfully.

Prior work

#4573 attempted to fix by using shallow copy semantics, but, was generating wrong IR.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions