def fit(results: List[Result], rb_opts: Dict, xdata: List,
        log: Logger) -> RBFitter:
    rb_fit = rb.RBFitter(None, xdata, rb_opts['rb_pattern'])
    batch_size = len(rb_opts['length_vector'])
    for rb_seed in range(rb_opts['nseeds']):
        result_batch = results[rb_seed * batch_size:rb_seed * batch_size +
                               batch_size]
        rb_fit.add_data(result_batch)
        log.info('After seed %d, alpha: %f, EPC: %f' %
                 (rb_seed, rb_fit.fit[0]['params'][1], rb_fit.fit[0]['epc']))
    return rb_fit
Beispiel #2
0
noise_model.add_all_qubit_quantum_error(depolarizing_error(p1Q, 1), 'u2')
noise_model.add_all_qubit_quantum_error(depolarizing_error(2 * p1Q, 1), 'u3')
noise_model.add_all_qubit_quantum_error(depolarizing_error(p2Q, 2), 'cx')

backend = qiskit.Aer.get_backend('qasm_simulator')
job00 = qiskit.execute(qc0, backend=backend, basis_gates=basis_gates, noise_model = noise_model)
job11 = qiskit.execute(qc1, backend=backend, basis_gates=basis_gates, noise_model = noise_model)

# Create the RB fitter
basis_gates = ['u1','u2','u3','cx'] 
shots = 200
result_list0 = []
result_list1 = []
transpile_circs_list = []
import time
rb_fit = rb.RBFitter(None, xdata, rb_opts['rb_pattern'])
rb_fit01 = rb.RBFitter(None, xdata, rb_opts['rb_pattern'])

for rb_seed, rb_circ_seed in enumerate(rb_circuits_seeds):
    print('Compiling seed %d'%rb_seed)
    new_rb_circ_seed = qiskit.compiler.transpile(rb_circ_seed, basis_gates=basis_gates)
    transpiled_circs_list.append(new_rb_circ_seed)
    print('Simulating seed %d'%rb_seed)
    job = qiskit.execute(new_rb_circ_seed, backend, shots=shots,
                         noise_model=noise_model,
                         backend_options={'max_parallel_experiments': 0})    
    # Add data to the fitter
    rb_fit.add_data(job.result())
    print('After seed %d, alpha: %f, EPC: %f'%(rb_seed,rb_fit.fit[0]['params'][1], rb_fit.fit[0]['epc']))
    for i in range(2):
        job01 = qiskit.execute(new_rb_circ_seed[i], backend=backend, shots=shots, noise_model = noise_model, backend_options={'max_parallel_experiments': 0})