Loading benchmarks/vqe/qcor/qcor_run.py +12 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,17 @@ for test_case in test_cases: for i in range(nParameters): params.append(1.0) start = time.time() ansatz.print_kernel(q, nElectrons, params) comp = ansatz.extract_composite(q, nElectrons, params) end = time.time() print("Kernel eval time:", end - start, " [secs]") # Count gate. n_insts = comp.nInstructions() gate_counts = {} for i in range(n_insts): inst_name = comp.getInstruction(i).name() if inst_name in gate_counts: gate_counts[inst_name] = gate_counts[inst_name] + 1 else: gate_counts[inst_name] = 1 for op_name in gate_counts: print(op_name, ":", gate_counts[op_name]) No newline at end of file benchmarks/vqe/qiskit/qiskit_run.py +43 −38 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ hcn_mole = 'C 0.0, 0.0, -0.511747; N 0.0, 0.0, 0.664461; H 0.0, 0.0, -1.580746' test_cases = { "H20": h2o_mole, "N2": n2_mol, "HCN": hcn_mole } for test_case in test_cases: try: print("Run ", test_case) mole_str = test_cases[test_case] driver = PySCFDriver(atom=mole_str, basis = 'sto-3g') Loading Loading @@ -48,6 +49,8 @@ for test_case in test_cases: op_count = iter_circ.count_ops() for op_name in op_count: print(op_name, ":", op_count[op_name]) # We don't want to run the VQE loop raise Exception("Terminate loop.") vqe = VQE(var_form=var_form, optimizer=SLSQP(maxiter=1), include_custom=True, callback=iter_cb_func) vqe.quantum_instance = Aer.get_backend('qasm_simulator') Loading @@ -60,3 +63,5 @@ for test_case in test_cases: import pprint pp = pprint.PrettyPrinter(indent=4) pp.pprint(result) except: pass No newline at end of file Loading
benchmarks/vqe/qcor/qcor_run.py +12 −1 Original line number Diff line number Diff line Loading @@ -34,6 +34,17 @@ for test_case in test_cases: for i in range(nParameters): params.append(1.0) start = time.time() ansatz.print_kernel(q, nElectrons, params) comp = ansatz.extract_composite(q, nElectrons, params) end = time.time() print("Kernel eval time:", end - start, " [secs]") # Count gate. n_insts = comp.nInstructions() gate_counts = {} for i in range(n_insts): inst_name = comp.getInstruction(i).name() if inst_name in gate_counts: gate_counts[inst_name] = gate_counts[inst_name] + 1 else: gate_counts[inst_name] = 1 for op_name in gate_counts: print(op_name, ":", gate_counts[op_name]) No newline at end of file
benchmarks/vqe/qiskit/qiskit_run.py +43 −38 Original line number Diff line number Diff line Loading @@ -19,6 +19,7 @@ hcn_mole = 'C 0.0, 0.0, -0.511747; N 0.0, 0.0, 0.664461; H 0.0, 0.0, -1.580746' test_cases = { "H20": h2o_mole, "N2": n2_mol, "HCN": hcn_mole } for test_case in test_cases: try: print("Run ", test_case) mole_str = test_cases[test_case] driver = PySCFDriver(atom=mole_str, basis = 'sto-3g') Loading Loading @@ -48,6 +49,8 @@ for test_case in test_cases: op_count = iter_circ.count_ops() for op_name in op_count: print(op_name, ":", op_count[op_name]) # We don't want to run the VQE loop raise Exception("Terminate loop.") vqe = VQE(var_form=var_form, optimizer=SLSQP(maxiter=1), include_custom=True, callback=iter_cb_func) vqe.quantum_instance = Aer.get_backend('qasm_simulator') Loading @@ -60,3 +63,5 @@ for test_case in test_cases: import pprint pp = pprint.PrettyPrinter(indent=4) pp.pprint(result) except: pass No newline at end of file