message: Added special cases in KAK decomposition
  To generate more optimal circuits for those special cases.
diff: @@ -670,6 +670,10 @@ std::shared_ptr<CompositeInstruction> KAK::KakDecomposition::toGates(size_t in_b
  {
  auto gateRegistry = xacc::getService<IRProvider>("quantum");
  const auto generateInteractionComposite = [&](size_t bit1, size_t bit2, double x, double y, double z) {
  + const double TOL = 1e-8;
  + // Full decomposition is required
  + if (std::abs(z) >= TOL)
  + {
  const double xAngle = M_PI * (x * -2 / M_PI + 0.5);
  const double yAngle = M_PI * (y * -2 / M_PI + 0.5);
  const double zAngle = M_PI * (z * -2 / M_PI + 0.5);
  @@ -760,6 +764,41 @@ std::shared_ptr<CompositeInstruction> KAK::KakDecomposition::toGates(size_t in_b
  assert(validateGateSequence(interactionMatrixExp(x, y, z)));
  return composite;
  + }
  + // ZZ interaction is near zero: only XX and YY
  + else if (y >= TOL)
  + {
  + const double xAngle = -2 * x;
  + const double yAngle = -2 * y;
  + auto composite = gateRegistry->createComposite("__TEMP__INTERACTION_COMPOSITE__" + std::to_string(getTempId()));
  + composite->addInstruction(gateRegistry->createInstruction("Rx", { bit1 }, { M_PI_2 }));
  + composite->addInstruction(gateRegistry->createInstruction("H", { bit1 }));
  + composite->addInstruction(gateRegistry->createInstruction("CZ", { bit2, bit1 }));
  + composite->addInstruction(gateRegistry->createInstruction("H", { bit1 }));
  + composite->addInstruction(gateRegistry->createInstruction("Ry", { bit1 }, { yAngle }));
  + composite->addInstruction(gateRegistry->createInstruction("Rx", { bit2 }, { xAngle }));
  + composite->addInstruction(gateRegistry->createInstruction("H", { bit1 }));
  + composite->addInstruction(gateRegistry->createInstruction("CZ", { bit1, bit2 }));
  + composite->addInstruction(gateRegistry->createInstruction("H", { bit1 }));
  + composite->addInstruction(gateRegistry->createInstruction("Rx", { bit2 }, { -M_PI_2 }));
  +
  + // TODO: add validation
  + return composite;
  + }
  + // only XX is significant
  + else
  + {
  + const double xAngle = -2 * x;
  + auto composite = gateRegistry->createComposite("__TEMP__INTERACTION_COMPOSITE__" + std::to_string(getTempId()));
  + composite->addInstruction(gateRegistry->createInstruction("H", { bit1 }));
  + composite->addInstruction(gateRegistry->createInstruction("CZ", { bit2, bit1 }));
  + composite->addInstruction(gateRegistry->createInstruction("Rx", { bit2 }, { xAngle }));
  + composite->addInstruction(gateRegistry->createInstruction("CZ", { bit1, bit2 }));
  + composite->addInstruction(gateRegistry->createInstruction("H", { bit1 }));
  +
  + // TODO: add validation
  + return composite;
  + }
  };
  auto a0Comp = singleQubitGateGen(a0, in_bit2);
  