NVIDIA / cuda-quantum

C++ and Python support for the CUDA Quantum programming model for heterogeneous quantum-classical workflows
https://nvidia.github.io/cuda-quantum/
Other
486 stars 179 forks source link

Exp_pauli fails on remote simulator #2227

Open annagrin opened 5 days ago

annagrin commented 5 days ago

Required prerequisites

Describe the bug

If a pauli word is created inside the kernel, the execution on a remote simulator fails with a type error in IR generated in quake-to-qir.

Steps to reproduce the bug

#include <cudaq.h>
#include <iostream>

__qpu__ void test() {
    cudaq::qvector q(2);
    cudaq::exp_pauli(1.0, q, "XX");
}

void printCounts(cudaq::sample_result& result) {
  std::vector<std::string> values{};
  for (auto &&[bits, counts] : result) {
    values.push_back(bits);
  }

  std::sort(values.begin(), values.end());
  for (auto &&bits : values) {
    std::cout << bits << '\n';
  }
}

int main() {
  auto counts = cudaq::sample(test);
  printCounts(counts);
}

Run command:

nvq++  --enable-mlir --target remote-mqpu  --emulate  -fkernel-exec-kind=2 exp_pauli.cpp -o tmp.x && ./tmp.x

Expected behavior

The command

nvq++  --enable-mlir --target remote-mqpu  --emulate  -fkernel-exec-kind=2 exp_pauli.cpp -o tmp.x && ./tmp.x

Runs successfully, prints:

00
11

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

Not a regression

Environment

Suggestions

No response