def test_decomp_five(): for nr_qubits in range(2, 6): qubits = [] for i in range(nr_qubits): qubits.append(cirq.NamedQubit("a" + str(i))) bbcircuit = bb.BucketBrigade( qubits, decomp_scenario=bb.BucketBrigadeDecompType( [ ToffoliDecompType.FOUR_ANCILLA_TDEPTH_1_B, # fan_in_decomp ToffoliDecompType.FOUR_ANCILLA_TDEPTH_1_B, # mem_decomp ToffoliDecompType. FOUR_ANCILLA_TDEPTH_1_B, # fan_out_decomp ], False)) # #Verification assert (bbcircuit.verify_number_qubits() == True) assert (bbcircuit.verify_depth() == True) assert (bbcircuit.verify_T_count() == True) assert (bbcircuit.verify_T_depth() == True) assert (bbcircuit.verify_hadamard_count() == True) assert (bbcircuit.verify_cnot_count() == True)
def test_decomp_one(): for nr_qubits in range(3, 6): qubits = [] for i in range(nr_qubits): qubits.append(cirq.NamedQubit("a" + str(i))) # bbcircuit = bb.BucketBrigade(qubits, # decomp_scenario=decomp_scenario) bbcircuit = bb.BucketBrigade( qubits, decomp_scenario=bb.BucketBrigadeDecompType( [ ToffoliDecompType.NO_DECOMP, # fan_in_decom ToffoliDecompType.NO_DECOMP, # fan_out_decom ToffoliDecompType.NO_DECOMP ], False)) # #Verification assert (bbcircuit.verify_number_qubits() == True) assert (bbcircuit.verify_depth() == True) assert (bbcircuit.verify_T_count() == True) assert (bbcircuit.verify_T_depth() == True) assert (bbcircuit.verify_hadamard_count() == True) assert (bbcircuit.verify_cnot_count() == True)
def main(argv_param, nr): # print("Hello QRAM circuit experiments!", argv_param, nr) if argv_param == "decomp": """ Bucket brigade - DECOMP """ decomp_scenario = bb.BucketBrigadeDecompType( [ ToffoliDecompType.ZERO_ANCILLA_TDEPTH_4_COMPUTE, # fan_in_decomp ToffoliDecompType.ZERO_ANCILLA_TDEPTH_4, # mem_decomp ToffoliDecompType.ZERO_ANCILLA_TDEPTH_0_UNCOMPUTE, # fan_out_decomp ], False ) else: """ Bucket brigade - NO DECOMP """ decomp_scenario = bb.BucketBrigadeDecompType( [ ToffoliDecompType.NO_DECOMP, # fan_in_decomp ToffoliDecompType.NO_DECOMP, # mem_decomp ToffoliDecompType.NO_DECOMP, # fan_out_decomp ], False ) for i in range(nr, nr + 1): nr_qubits = i qubits = [] for i in range(nr_qubits): qubits.append(cirq.NamedQubit("a" + str(i))) start = time.time() bbcircuit = bb.BucketBrigade(qubits, decomp_scenario=decomp_scenario) # print(bbcircuit.circuit.to_text_diagram(use_unicode_characters=False, # qubit_order = bbcircuit.qubit_order)) stop = time.time() - start process = psutil.Process(os.getpid()) """ rss: aka “Resident Set Size”, this is the non-swapped physical memory a process has used. On UNIX it matches “top“‘s RES column). vms: aka “Virtual Memory Size”, this is the total amount of virtual memory used by the process. On UNIX it matches “top“‘s VIRT column. """ print("--> mem bucket brigade, ", argv_param, ",", nr_qubits, ",", stop, ",", process.memory_info().rss , ",", process.memory_info().vms , flush=True)
def test_decomp_six(): for nr_qubits in range(2, 6): qubits = [] for i in range(nr_qubits): qubits.append(cirq.NamedQubit("a" + str(i))) bbcircuit = bb.BucketBrigade( qubits, decomp_scenario=bb.BucketBrigadeDecompType( [ ToffoliDecompType.ZERO_ANCILLA_TDEPTH_3, # fan_in_decomp ToffoliDecompType.ZERO_ANCILLA_TDEPTH_3, # mem_decomp ToffoliDecompType.ZERO_ANCILLA_TDEPTH_3, # fan_out_decomp ], False)) # #Verification assert (bbcircuit.verify_number_qubits() == True) assert (bbcircuit.verify_depth() == True) assert (bbcircuit.verify_T_count() == True) assert (bbcircuit.verify_T_depth() == True) assert (bbcircuit.verify_hadamard_count() == True) assert (bbcircuit.verify_cnot_count() == True) # # def test_decomp_six(): # # for nr_qubits in range(2, 6): # qubits = [] # for i in range(nr_qubits): # qubits.append(cirq.NamedQubit("a" + str(i))) # # bbcircuit = bb.BucketBrigade(qubits,decomp_scenario=bb.BucketBrigadeDecompType( # [ # ToffoliDecompType.ZERO_ANCILLA_TDEPTH_4_COMPUTE, # fan_in_decomp # ToffoliDecompType.ZERO_ANCILLA_TDEPTH_4, # mem_decomp # ToffoliDecompType.ZERO_ANCILLA_TDEPTH_0_UNCOMPUTE, # fan_out_decomp # ], # True # )) # # # #Verification # assert (bbcircuit.verify_number_qubits() == True) # # assert (bbcircuit.verify_depth(Alexandru_scenario=True) == True) # assert (bbcircuit.verify_T_count() == True) # # assert (bbcircuit.verify_T_depth() == True) # assert (bbcircuit.verify_hadamard_count(Alexandru_scenario=True) == True) # assert (bbcircuit.verify_cnot_count() == True)
def main(): print("Hello QRAM circuit experiments!") for i in range(2, 16): nr_qubits = i qubits = [] for i in range(nr_qubits): qubits.append(cirq.NamedQubit("a" + str(i))) # # # # # # #Create the search # # search = [0, 1, 2, 3] # search = list(range(0, 15)) # """ Bucket brigade """ decomp_scenario = bb.BucketBrigadeDecompType( [ ToffoliDecompType.ZERO_ANCILLA_TDEPTH_4_COMPUTE, # fan_in_decomp ToffoliDecompType.ZERO_ANCILLA_TDEPTH_4, # mem_decomp ToffoliDecompType.ZERO_ANCILLA_TDEPTH_0_UNCOMPUTE, # fan_out_decomp ], False ) # Simulation without parallelisation optimisation start1 = time.time() bbcircuit = bb.BucketBrigade(qubits, decomp_scenario = decomp_scenario) stop1 = time.time() - start1 # print(bbcircuit.circuit.to_text_diagram(use_unicode_characters=False, # qubit_order = bbcircuit.qubit_order)) # Simulation with parallelisation optimisation decomp_scenario.parallel_toffolis = True start2 = time.time() bbcircuit = bb.BucketBrigade(qubits, decomp_scenario=decomp_scenario) stop2 = time.time() - start2 # print(bbcircuit.circuit.to_text_diagram(use_unicode_characters=False, # qubit_order = bbcircuit.qubit_order)) # print(bbcircuit.circuit.to_text_diagram(use_unicode_characters=False, # qubit_order = bbcircuit.qubit_order)) # #Verification bbcircuit.verify_number_qubits() bbcircuit.verify_depth( Alexandru_scenario=decomp_scenario.parallel_toffolis) bbcircuit.verify_T_count() bbcircuit.verify_T_depth( Alexandru_scenario=decomp_scenario.parallel_toffolis) bbcircuit.verify_hadamard_count( Alexandru_scenario=decomp_scenario.parallel_toffolis) bbcircuit.verify_cnot_count( Alexandru_scenario=decomp_scenario.parallel_toffolis) end = time.time() print("--> exp bucket brigade, ", nr_qubits, ",", stop1 , ",", stop2, ",", flush=True)
def main(): print("Hello QRAM circuits!") #Create the qubis of the circuits nr_qubits = 5 qubits = [] for i in range(nr_qubits): qubits.append(cirq.NamedQubit("a" + str(i))) # # # # # # #Create the search # # search = [0, 1, 2, 3] # search = list(range(0, 15)) # """ Bucket brigade """ print("*** Bucket Brigade:") decomp_scenario = bb.BucketBrigadeDecompType( [ ToffoliDecompType.ZERO_ANCILLA_TDEPTH_4_COMPUTE, # fan_in_decomp ToffoliDecompType.ZERO_ANCILLA_TDEPTH_4, # mem_decomp ToffoliDecompType. ZERO_ANCILLA_TDEPTH_0_UNCOMPUTE, # fan_out_decomp ], True) no_decomp = bb.BucketBrigadeDecompType( [ ToffoliDecompType.NO_DECOMP, # fan_in_decomp ToffoliDecompType.ZERO_ANCILLA_TDEPTH_4, # mem_decomp ToffoliDecompType.NO_DECOMP, # fan_out_decomp ], True) olivia_decomposition = bb.BucketBrigadeDecompType( [ ToffoliDecompType.FOUR_ANCILLA_TDEPTH_1_A, # fan_in_decomp ToffoliDecompType.FOUR_ANCILLA_TDEPTH_1_A, # mem_decomp ToffoliDecompType.FOUR_ANCILLA_TDEPTH_1_A, # fan_out_decomp ], False) bbcircuit = bb.BucketBrigade(qubits, decomp_scenario=decomp_scenario) # # print(bbcircuit.circuit.to_text_diagram(use_unicode_characters=False, # qubit_order = bbcircuit.qubit_order)) # #Verification print("Verify N_q: {}\n".format(bbcircuit.verify_number_qubits())) print("Verify D: {}\n".format( bbcircuit.verify_depth( Alexandru_scenario=decomp_scenario.parallel_toffolis))) print("Verify T_c: {}\n".format(bbcircuit.verify_T_count())) print("Verify T_d: {}\n".format( bbcircuit.verify_T_depth( Alexandru_scenario=decomp_scenario.parallel_toffolis))) print("Verify H_c: {}\n".format( bbcircuit.verify_hadamard_count( Alexandru_scenario=decomp_scenario.parallel_toffolis))) print("Verify CNOT_c: {}\n".format( bbcircuit.verify_cnot_count( Alexandru_scenario=olivia_decomposition.parallel_toffolis)))