def simulate_qasm_files(qasm_filenames, config_filename, qxc, MC, error_rate=0, nr_averages=int(1e4)): """ Takes one or more asm_files as input and runs them on the hardware """ if len(qasm_filenames) > 1: MC.soft_avg(len(qasm_filenames)) nr_hard_averages = 256 else: nr_hard_averages = nr_averages MC.soft_avg(1) qx_det = det.QX_Hard_Detector(qxc, qasm_filenames, p_error=error_rate, num_avg=nr_hard_averages) measurement_points = extract_msmt_pts_from_config(config_filename) MC.set_sweep_function(swf.None_Sweep()) MC.set_detector_function(qx_det) MC.set_sweep_points(measurement_points) MC.run('Demo QX sim {}'.format(os.path.split(qasm_filenames[0])[-1]))
def measure_asm_files(asm_filenames, config_filename, qubit, MC): """ Takes one or more asm_files as input and runs them on the hardware """ qubit.prepare_for_timedomain() CBox = qubit.CBox # The qubit object contains a reference to the CBox counter_param = ManualParameter('name_ctr', initial_value=0) if len(asm_filenames) > 1: MC.soft_avg(len(asm_filenames)) nr_hard_averages = 256 else: MC.soft_avg(8) nr_hard_averages = qubit.RO_acq_averages() // MC.soft_avg() if qubit.cal_pt_zero() is not None: cal_pts = (qubit.cal_pt_zero(), qubit.cal_pt_one()) else: cal_pts = None prepare_function_kwargs = { 'counter_param': counter_param, 'asm_filenames': asm_filenames, 'CBox': CBox } detector = CBox_int_avg_func_prep_det_CC( CBox, prepare_function=load_range_of_asm_files, prepare_function_kwargs=prepare_function_kwargs, nr_averages=nr_hard_averages, cal_pts=cal_pts) measurement_points = extract_msmt_pts_from_config(config_filename) s = swf.None_Sweep() if 'rb' in asm_filenames[0]: s.parameter_name = 'Number of Cliffords' s.unit = '#' MC.set_sweep_function(s) MC.set_sweep_points(measurement_points) MC.set_detector_function(detector) MC.run('Demo {}'.format(os.path.split(asm_filenames[0])[-1])) if 'rb' in asm_filenames[0]: a = ma.RandomizedBenchmarking_Analysis(label='Demo rb', rotate_and_normalize=False, close_fig=True) p = a.fit_res.best_values['p'] Fcl = p + (1 - p) / 2 Fg = Fcl**(1 / 1.875) print('Clifford Fidelity:\t{:.4f}\nGate Fidelity: \t\t{:.4f}'.format( Fcl, Fg)) Ncl = np.arange(a.sweep_points[0], a.sweep_points[-1]) RB_fit = ma.fit_mods.RandomizedBenchmarkingDecay( Ncl, **a.fit_res.best_values) MC.main_QtPlot.add(x=Ncl, y=RB_fit, subplot=0)
def _simulate_quantumsim(file_path, options): st = station.Station() # Connect to the qx simulator MC_sim = measurement_control.MeasurementControl('MC_sim', live_plot_enabled=False, verbose=True) datadir = os.path.abspath( os.path.join(os.path.dirname(pq.__file__), os.pardir, 'execute_data')) MC_sim.datadir(datadir) MC_sim.station = st st.add_component(MC_sim) quantumsim_sweep = swf.None_Sweep() quantumsim_sweep.parameter_name = 'Circuit number ' quantumsim_sweep.unit = '#' qubit_parameters = { 'Q0': { 'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.0189, 'frac1_1': 0.918 }, 'Q1': { 'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.068, 'frac1_1': 0.949 }, 'q0': { 'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.0189, 'frac1_1': 0.918 }, 'q1': { 'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.068, 'frac1_1': 0.949 } } quantumsim_det = Quantumsim_Two_QB_Hard_Detector( file_path, dt=(40, 280), qubit_parameters=qubit_parameters) sweep_points = range(len(quantumsim_det.parser.circuits)) MC_sim.set_detector_function(quantumsim_det) MC_sim.set_sweep_function(quantumsim_sweep) MC_sim.set_sweep_points(sweep_points) dat = MC_sim.run("run QASM") print('simulation finished') return dat
def fake_folder(self, folder_name): ''' Give folder_name in the form of a string. Creates a folder with the desired folder name containing a dummy measurement. ''' if isinstance(folder_name, str): sweep_pts = np.linspace(0, 10, 3) self.MC.set_sweep_function(swf.None_Sweep()) self.MC.set_sweep_points(sweep_pts) self.MC.set_detector_function(det.Dummy_Detector_Soft()) dat = self.MC.run(folder_name) else: raise ValueError('Please enter a string as the folder name!')
def fake_folder(self, folder_name): ''' Give folder_name in the form of a string. Create a fake folder in the nanowire experiments folder with the desired folder name. This is usefull to use when magnetic fields change or when you start a new measurement cycle. Such that you can distinguish the different measurement sets. ''' if isinstance(folder_name, str): sweep_pts = np.linspace(0, 10, 3) self.MC.set_sweep_function(swf.None_Sweep()) self.MC.set_sweep_points(sweep_pts) self.MC.set_detector_function(det.Dummy_Detector_Soft()) dat = self.MC.run(folder_name) else: raise ValueError('Please enter a string as the folder name!')
def measure_discrimination_fid(self, no_fits=False, return_detector=False, MC=None, analyze=True, close_fig=True, make_fig=True, verbose=True): ''' Measures the single shot discrimination fidelity. Uses whatever sequence is currently loaded and takes 8000 single shots Constructs histograms based on those and uses it to extract the single-shot discrimination fidelity. ''' self.prepare_for_timedomain() if MC is None: MC = self.MC # If I return the detector to use it must do analysis internally # Otherwise I do it here in the qubit object so that I can pass args analysis_in_det = return_detector d = cdet.CBox_SSRO_discrimination_detector( 'SSRO-disc' + self.msmt_suffix, analyze=analysis_in_det, MC=MC, AWG=self.AWG, CBox=self.CBox, sequence_swf=swf.None_Sweep(sweep_control='hard', sweep_points=np.arange(10))) if return_detector: return d d.prepare() discr_vals = d.acquire_data_point() if analyze: current_threshold = self.CBox.sig0_threshold_line.get() a = ma.SSRO_discrimination_analysis( label='SSRO-disc' + self.msmt_suffix, current_threshold=current_threshold, close_fig=close_fig, plot_2D_histograms=make_fig) return (a.F_discr_curr_t * 100, a.F_discr * 100, a.theta, a.opt_I_threshold, a.relative_separation, a.relative_separation_I) return discr_vals
def _simulate_quantumsim(file_path, options): quantumsim_sweep = swf.None_Sweep() quantumsim_sweep.parameter_name = 'Starmon number ' quantumsim_sweep.unit = '#' qubit_parameters = { 'Q0': {'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.0189, 'frac1_1': 0.918}, 'Q1': {'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.068, 'frac1_1': 0.949}, 'q0': {'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.0189, 'frac1_1': 0.918}, 'q1': {'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.068, 'frac1_1': 0.949}} quantumsim_det = Quantumsim_Two_QB_Hard_Detector( file_path, dt=(40, 280), qubit_parameters=qubit_parameters) sweep_points = range(len(quantumsim_det.parser.circuits)) MC_demo.set_detector_function(quantumsim_det) MC_demo.set_sweep_function(quantumsim_sweep) MC_demo.set_sweep_points(sweep_points) dat = MC_demo.run("run QASM") print('simulation execute_Starmon finished') return dat
def _simulate_quantumsim(file_path, options): quantumsim_sweep = swf.None_Sweep() quantumsim_sweep.parameter_name = 'Circuit number ' quantumsim_sweep.unit = '#' qubit_parameters = { 'Q0': {'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.0189, 'frac1_1': 0.918}, 'Q1': {'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.068, 'frac1_1': 0.949}, 'q0': {'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.0189, 'frac1_1': 0.918}, 'q1': {'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.068, 'frac1_1': 0.949}, 'default': {'T1': 30e3, 'T2': 17e3, 'frac1_0': 0.068, 'frac1_1': 0.949}} quantumsim_det = Quantumsim_Two_QB_Hard_Detector( file_path, timegrid=20, gate_1_step=1, gate_2_step=5, qubit_parameters=qubit_parameters) sweep_points = range(len(quantumsim_det.parser.circuits)) MC.set_detector_function(quantumsim_det) MC.set_sweep_function(quantumsim_sweep) MC.set_sweep_points(sweep_points) dat = MC.run("run QASM") print('simulation finished') return _MC_result_to_chart_dict(dat)