Commit df4a8ca3 authored by Dmitry I. Lyakh's avatar Dmitry I. Lyakh
Browse files

Fixed an issue in ExaTN-gen related to the unnecessary output tensor creation.

parent 4199b178
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -87,23 +87,24 @@ int benchmarkExaTnGen2()

int benchmarkExaTnGen3()
{
 constexpr int NB_QUBITS = 16;
 constexpr int NB_QUBITS = 8;
 auto xasmCompiler = xacc::getCompiler("xasm");
 auto ir = xasmCompiler->compile(R"(__qpu__ void bell(qbit q) {
            H(q[0]);
            for (int i = 0; i < 15; i++) {
            for (int i = 0; i < 7; i++) {
             CNOT(q[i], q[i + 1]);
            }
           })");
 std::vector<int> bitstring(NB_QUBITS, 0);
 std::vector<int> bitstring(NB_QUBITS, 0); // -1: Open qubits
 auto program = ir->getComposite("bell");
 auto accelerator =
      xacc::getAccelerator("tnqvm", {{"tnqvm-visitor", "exatn-gen"},
      xacc::getAccelerator("tnqvm", {{"tnqvm-visitor", "exatn-gen:float"},
                                     {"exatn-buffer-size-gb", 2},
                                     {"reconstruct-layers", 4},
                                     {"reconstruct-layers", 2},
                                     {"reconstruct-tolerance", 1e-4},
                                     {"max-bond-dim", 1},
                                     {"bitstring", bitstring}});
                                     {"max-bond-dim", 4},
                                     {"bitstring", bitstring},
                                     {"exatn-contract-seq-optimizer", "metis"}});
 auto qreg = xacc::qalloc(NB_QUBITS);
 accelerator->execute(qreg, program);
 qreg->print();
+1 −2
Original line number Diff line number Diff line
@@ -729,8 +729,7 @@ void ExatnGenVisitor<TNQVM_COMPLEX_TYPE>::reconstructCircuitTensor(bool forced)
            exatn::makeSharedTensorNetwork("Approx", rootTensor, *builder);
        for (auto iter = approximantTensorNetwork->cbegin();
             iter != approximantTensorNetwork->cend(); ++iter) {
          const auto &tensorName = iter->second.getTensor()->getName();
          if (tensorName != "ROOT") {
          if (iter->first != 0) { //ignore output tensor
            auto tensor = iter->second.getTensor();
            const bool created =
                exatn::createTensorSync(tensor, getExatnElementType());
+5 −3
Original line number Diff line number Diff line
@@ -489,10 +489,12 @@ void ExatnVisitor<TNQVM_COMPLEX_TYPE>::initialize(std::shared_ptr<AcceleratorBuf
    });

    //Set up ExaTN computational backend:
    const std::string backend = "cuquantum";
    auto backends = exatn::queryComputationalBackends();
    if(std::find(backends.cbegin(),backends.cend(),"cuquantum") != backends.cend()) {
      exatn::switchComputationalBackend("cuquantum");
      //std::cout << "#MSG(TN-QVM:ExaTN): Switched computational backend to cuQuantum\n"; //debug
    if(std::find(backends.cbegin(),backends.cend(),backend) != backends.cend()) {
      exatn::switchComputationalBackend(backend);
      //std::cout << "#MSG(TN-QVM:ExaTN): Switched computational backend to "
      //          << backend << std::endl << std::flush; //debug
    }
  }