示例#1
0
def execute_set3(xtalk_date, today):
    experiments_path = '/Users/rum/Documents/aqua/gp/experiments'
    errorinfo_path = '/Users/rum/Documents/aqua/gp/errors_information'
    # prepare benchmark qc
    name_list_set = load_gspread(worksheet_name='set_3',
                                 num_set=10,
                                 num_qc=3,
                                 shift=3)
    qc_path = experiments_path + '/xtalk_compiler/benchmark_qc/qasmbench.pickle'

    for label, name_list in enumerate(name_list_set):
        try:
            qasmbench = PrepQASMBench(name_list, qc_path)
            qc_list = qasmbench.qc_list()

            # prepare execution environment
            backend = get_IBM_backend('ibmq_toronto')
            simulator = get_IBM_backend('ibmq_qasm_simulator')
            shots_single = 8192
            shots_multi = 8192
            xtalk_prop = pickle_load(
                errorinfo_path +
                '/toronto_from20201224/xtalk_data_daily/ratio/' +
                str(xtalk_date) + '.pickle')
            save_path = experiments_path + '/xtalk_compiler/ibmq_toronto/job_id/' + str(
                today) + '_set3/' + str(label) + '.pickle'

            data = execute_xtalk(qc_list, backend, simulator, shots_single,
                                 shots_multi, xtalk_prop, save_path)

            pprint(data)

        except:
            print('Failed: set3 label:', label, ' ', name_list)
示例#2
0
def execute_set4():
    # prepare benchmark qc
    name_list_set = load_gspread(worksheet_name='set_4',
                                 num_set=11,
                                 num_qc=4,
                                 shift=4)
    qc_path = '/Users/Yasuhiro/Documents/aqua/gp/experiments/xtalk_compiler/benchmark_qc/qasmbench.pickle'

    for label, name_list in enumerate(name_list_set):
        qasmbench = PrepQASMBench(name_list, qc_path)
        qc_list = qasmbench.qc_list()

        # prepare execution environment
        backend = get_IBM_backend('ibmq_toronto')
        simulator = get_IBM_backend('ibmq_qasm_simulator')
        shots_single = 8192
        shots_multi = 8192
        xtalk_prop = pickle_load(
            '/Users/Yasuhiro/Documents/aqua/gp/errors_information/toronto_from20201224/xtalk_data_daily/ratio/2021-01-19.pickle'
        )
        save_path = '/Users/Yasuhiro/Documents/aqua/gp/experiments/xtalk_compiler/ibmq_toronto/job_id/2021-01-19_set4/' + str(
            label) + '.pickle'

        data = execute_xtalk(qc_list, backend, simulator, shots_single,
                             shots_multi, xtalk_prop, save_path)

        pprint(data)
示例#3
0
def test_xtalkadaptivelayout(): 
    name_list_set = load_gspread(worksheet_name='set_3', num_set=10, num_qc=3, shift=3)
    name_list = name_list_set[9]
    print(name_list)

    qc_path = '/Users/Yasuhiro/Documents/aqua/gp/experiments/xtalk_compiler/benchmark_qc/qasmbench.pickle'
    qasmbench = PrepQASMBench(name_list, qc_path)
    qc_list = qasmbench.qc_list()

    backend = get_IBM_backend('ibmq_toronto')
    shots_multi = 1000

    xtalk_prop = {(16, 19): {}, (1, 4): {(7, 10): 1.5523922159364776, (1, 4): 1.0}, (22, 25): {(4, 7): 1.373897836294811, (10, 12): 1.24005278534089, (12, 15): 1.2650717924862478, (14, 13): 1.2295727510296106, (22, 25): 1.0}, (11, 14): {}, (0, 1): {}, (1, 2): {}, (2, 3): {(5, 8): 1.9828579923816556, (19, 20): 1.187980385590695, (2, 3): 1.0}, (4, 7): {(10, 12): 1.4782839452414733, (4, 7): 1.0}, (3, 5): {(8, 11): 1.1101731182299803, (3, 5): 1.0}, (5, 8): {(2, 3): 3.8982912112371535, (5, 8): 1.0}, (7, 6): {}, (7, 10): {(1, 4): 1.384978600658456, (12, 15): 3.716655801629963, (16, 19): 1.0479045105542835, (7, 10): 1.0}, (8, 9): {}, (8, 11): {}, (10, 12): {(4, 7): 4.584756718619288, (14, 13): 3.3950730369059334, (15, 18): 3.7004301070979504, (10, 12): 1.0}, (12, 13): {(11, 14): 1.6664397082756501, (12, 13): 1.0}, (12, 15): {(7, 10): 3.399583065550418, (14, 13): 3.2251935324570224, (12, 15): 1.0}, (14, 13): {(8, 11): 3.704876525263742, (10, 12): 4.890490951462605, (12, 15): 7.076589040196085, (14, 13): 1.0}, (14, 16): {(8, 11): 1.0959863890724943, (14, 16): 1.0}, (15, 18): {(10, 12): 1.7782238443072769, (15, 18): 1.0}, (18, 17): {}, (18, 21): {(18, 21): 1.0}}
    # transpile
    qc_multi = multi_transpile(
            qc_list, backend=backend,
            instruction_durations=None, 
            basis_gates=['id', 'rz', 'sx', 'x', 'cx'], 
            layout_method='xtalk_adaptive', xtalk_prop=xtalk_prop,
            )

    # run combined qc job
    # qobj_multi = assemble(experiments=qc_multi, backend=backend, shots=shots_multi)
    # job_multi = backend.run(qobj_multi)

    # print(job_multi.job_id())
示例#4
0
def execute_alap(size: str,
                 names: List[str],
                 backend,
                 simulator,
                 shots,
                 nseed,
                 save_path=None,
                 instruction_durations=None):
    """
    size: 'small', 'medium', 'large'
    names: List of names of the benchmark circuits
    """
    _qc_list = PrepQASMBench.multi_circuits(size=size, names=names)

    qc_sim = multi_transpile(_qc_list, backend=simulator)
    qc = multi_transpile(
        _qc_list,
        backend=backend,
        basis_gates=[
            'id', 'u1', 'u2', 'u3', 'cx', 'delay', 'u3cx', 'barrier',
            'snapshot', 'measure', 'reset'
        ],
        layout_method='xtalk_adaptive',
        xtalk_prop={},
    )
    qc_alap = multi_transpile(
        _qc_list,
        backend=backend,
        scheduling_method='as_late_as_possible',
        instruction_durations=instruction_durations,
        basis_gates=[
            'id', 'u1', 'u2', 'u3', 'cx', 'delay', 'u3cx', 'barrier',
            'snapshot', 'measure', 'reset'
        ],
        layout_method='xtalk_adaptive',
        xtalk_prop={},
    )

    job_sim, job, job_alap, job_id_sim, job_id, job_id_alap = _execute(
        backend, simulator, shots, qc_sim, qc, qc_alap, nseed)

    if save_path:
        _save_experiments(qc_sim, qc, qc_alap, job_id_sim, job_id, job_id_alap,
                          names, nseed, save_path)

    return job_sim, job, job_alap
示例#5
0
def debug_benchmark_prop():
    bench = PrepQASMBench(size="small")
    bp = bench.benchmark_prop()
    pprint(bp)
    return bp
示例#6
0
def save_medium_bench():
    path = '/Users/Yasuhiro/Documents/aqua/gp/experiments/alap_scheduling/benchmarks/qasmbench_medium.pickle'
    bench = PrepQASMBench(size="medium")
    obj = bench.benchmark_prop()
    PrepQASMBench.save_pickle(obj, path)
示例#7
0
def save_small_bench():
    path = '/Users/Yasuhiro/Documents/aqua/gp/experiments/alap_scheduling/benchmarks/qasmbench_small.pickle'
    obj = debug_benchmark_prop()
    PrepQASMBench.save_pickle(obj, path)