Commit 1d760a60 authored by Nguyen, Thien Minh's avatar Nguyen, Thien Minh
Browse files

Fixing unit tests and handling more complex FTQC kernel use cases



- QIR runtime: the qubit Id is always "q" hence we need to set the QIR global reg name to "q" as well.

- For FTQC with CSP, we need to be able to handle kernel chaining and nesting more robustly with the instruction collection mode (to support adjoint, control, compute/action, etc.)

- Fixes a couple of typos in example tests now that we are executing them and I realized those errors.

Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent 7b3800c6
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ using namespace ftqc;
int main() {
  auto q = qalloc(4);
  // Retrieve "bit-flip" code:
  auto [stabilizers, encodeFunc, recoverFunc] = getQecCode("bit_flip");
  auto [stabilizers, encodeFunc, recoverFunc] = getQecCode("bit-flip");
  encodeFunc(q, 0, {1, 2});  
  // If using a perfect simulator, apply a random X error to observe syndrome changes.
  applyError(q, 0);
+2 −0
Original line number Diff line number Diff line
@@ -304,6 +304,8 @@ void QCORSyntaxHandler::GetReplacement(
  OS << ");\n";
  OS << "quantum::persistBitstring(" << bufferNames[0] << ".results());\n";
  OS << "}\n";
  // Use a special submit for FTQC to denote that this executable kernel has been completed.
  OS << "quantum::submit(nullptr);\n";
  OS << "}\n";
  OS << "return;\n";
  OS << "}\n";
+2 −0
Original line number Diff line number Diff line
@@ -194,6 +194,8 @@ std::string construct_kernel_subtype(
  OS << ");\n";
  OS << "quantum::persistBitstring(" << bufferNames[0] << ".results());\n";
  OS << "}\n";
  // Use a special submit for FTQC to denote that this executable kernel has been completed.
  OS << "quantum::submit(nullptr);\n";
  OS << "}\n";
  OS << "return;\n";
  OS << "}\n";
+2 −2
Original line number Diff line number Diff line
@@ -15,13 +15,13 @@ __qpu__ void estimate_term_expectation(qreg q,
  for (int i = 0; i < nSamples; ++i) {
    statePrep(q);
    int parity = 0;
    ftqc::measure_basis(q, bases, parity);
    measure_basis(q, bases, parity);
    if (parity == 1) {
      sum = sum - 1.0;
    } else {
      sum = sum + 1.0;
    }
    ftqc::reset_all(q);
    reset_all(q);
  }
  out_energy = sum / nSamples;
}
+1 −0
Original line number Diff line number Diff line
@@ -188,6 +188,7 @@ Array *__quantum__rt__qubit_allocate_array(uint64_t size) {
  allocated_qbits += size;
  if (!global_qreg) {
    global_qreg = std::make_shared<xacc::AcceleratorBuffer>(size);
    global_qreg->setName("q");
    ::quantum::set_current_buffer(global_qreg.get());
  }
  // Update size.
Loading