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

code to enable fSim gate in QCOR



Signed-off-by: default avatarThien Nguyen <nguyentm@ornl.gov>
parent ff853cde
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -95,6 +95,10 @@ class FTQC : public quantum::QuantumRuntime {
    applyGate("CRZ", {src_idx.second, tgt_idx.second}, {theta});
  }

  virtual void fsim(const qubit &q1, const qubit &q2, const double theta,
                    const double phi) override {
    applyGate("fSim", {q1.second, q2.second}, {theta, phi});
  }
  // exponential of i * theta * H, where H is an Observable pointer
  virtual void exp(qreg q, const double theta,
                   xacc::Observable &H) override { /* TODO */
+5 −0
Original line number Diff line number Diff line
@@ -144,6 +144,11 @@ class NISQ : public ::quantum::QuantumRuntime,
    two_qubit_inst("CRZ", src_idx, tgt_idx, {theta});
  }

  void fsim(const qubit &q1, const qubit &q2, const double theta,
            const double phi) override {
    two_qubit_inst("fSim", q1, q2, {theta, phi});
  }

  void general_instruction(std::shared_ptr<xacc::Instruction> inst) override {
    std::vector<double> params;
    for (auto p : inst->getParameters()) {
+5 −0
Original line number Diff line number Diff line
@@ -191,6 +191,11 @@ void crz(const qubit &src_idx, const qubit &tgt_idx, const double theta) {
  qrt_impl->crz(src_idx, tgt_idx, theta);
}

void fsim(const qubit &q1, const qubit &q2, const double theta,
          const double phi) {
  qrt_impl->fsim(q1, q2, theta, phi);
}

void exp(qreg q, const double theta, xacc::Observable &H) {
  qrt_impl->exp(q, theta, H);
}
+4 −1
Original line number Diff line number Diff line
@@ -58,6 +58,8 @@ public:
                      const double theta) = 0;
  virtual void crz(const qubit &src_idx, const qubit &tgt_idx,
                   const double theta) = 0;
  virtual void fsim(const qubit &q1, const qubit &q2, const double theta,
                    const double phi) = 0;

  // exponential of i * theta * H, where H is an Observable pointer
  virtual void exp(qreg q, const double theta, xacc::Observable &H) = 0;
@@ -147,7 +149,8 @@ void swap(const qubit &src_idx, const qubit &tgt_idx);
// Common parameterized 2 qubit gates.
void cphase(const qubit &src_idx, const qubit &tgt_idx, const double theta);
void crz(const qubit &src_idx, const qubit &tgt_idx, const double theta);

void fsim(const qubit &q1, const qubit &q2, const double theta,
          const double phi);
// exponential of i * theta * H, where H is an Observable pointer
void exp(qreg q, const double theta, xacc::Observable &H);
void exp(qreg q, const double theta, xacc::Observable *H);
+1 −0
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ public:
  void visit(CRZ &crz) override { addTwoQubitGate("crz", crz); }
  void visit(CH &ch) override { addTwoQubitGate("ch", ch); }
  void visit(CPhase &cphase) override { addTwoQubitGate("cphase", cphase); }
  void visit(fSim &fsim) override { addTwoQubitGate("fsim", fsim); }

  void visit(Measure &measure) override { addOneQubitGate("mz", measure); }
  void visit(Identity &i) override { addOneQubitGate("i", i); }