def calibrate_readout(device, qubit_id, qubit_readout_pulse, transition='01', ignore_other_qubits=None): adc, mnames = device.setup_adc_reducer_iq(qubit_id, raw=True) nums = int(device.get_qubit_constant(qubit_id=qubit_id, name='readout_background_nums')) old_nums = adc.get_adc_nums() adc.set_adc_nop(int(device.get_sample_global('readout_adc_points'))) if ignore_other_qubits is None: ignore_other_qubits = (device.get_qubit_constant(qubit_id=qubit_id, name='readout_calibration_ignore_other_qubits') == 'True') print ('ignore_other_qubits', ignore_other_qubits) other_qubit_pulse_sequence = [] references = {} if not ignore_other_qubits: for other_qubit_id in device.get_qubit_list(): if other_qubit_id != qubit_id: half_excited_pulse = excitation_pulse.get_excitation_pulse(device, other_qubit_id, rotation_angle=np.pi / 2.) references[('other_qubit_pulse', other_qubit_id)] = half_excited_pulse.id other_qubit_pulse_sequence.extend(half_excited_pulse.get_pulse_sequence(0)) qubit_excitation_pulse = excitation_pulse.get_excitation_pulse(device, qubit_id, rotation_angle=np.pi) metadata = {'qubit_id': qubit_id, 'averages': nums, 'ignore_other_qubits': ignore_other_qubits} references.update({'readout_pulse': qubit_readout_pulse.id, 'excitation_pulse': qubit_excitation_pulse.id, 'delay_calibration': device.modem.delay_measurement.id}) classifier = single_shot_readout.single_shot_readout(adc=adc, prepare_seqs=[device.pre_pulses + other_qubit_pulse_sequence, device.pre_pulses + other_qubit_pulse_sequence + qubit_excitation_pulse.get_pulse_sequence( 0)], ro_seq=device.trigger_readout_seq + qubit_readout_pulse.get_pulse_sequence(), pulse_generator=device.pg, ro_delay_seq=None, _readout_classifier=readout_classifier.binary_linear_classifier(), adc_measurement_name='Voltage') classifier.readout_classifier.cov_mode = 'equal' try: adc.set_adc_nums(nums) measurement = device.sweeper.sweep(classifier, measurement_type='readout_calibration', metadata=metadata, references=references) except: raise finally: adc.set_adc_nums(old_nums) return measurement
def readout_Zgate_scan(device, qubit_id, qubit_readout_pulse, Zgate, amplitudes, transition='01', ignore_other_qubits=None): adc, mnames = device.setup_adc_reducer_iq(qubit_id, raw=True) nums = int(device.get_qubit_constant(qubit_id=qubit_id, name='readout_background_nums')) old_nums = adc.get_adc_nums() adc.set_adc_nop(int(device.get_sample_global('readout_adc_points'))) if ignore_other_qubits is None: ignore_other_qubits = (device.get_qubit_constant(qubit_id=qubit_id, name='readout_calibration_ignore_other_qubits') == 'True') print ('ignore_other_qubits', ignore_other_qubits) other_qubit_pulse_sequence = [] references = {} if not ignore_other_qubits: for other_qubit_id in device.get_qubit_list(): if other_qubit_id != qubit_id: half_excited_pulse = excitation_pulse.get_excitation_pulse(device, other_qubit_id, rotation_angle=np.pi / 2.) references[('other_qubit_pulse', other_qubit_id)] = half_excited_pulse.id other_qubit_pulse_sequence.extend(half_excited_pulse.get_pulse_sequence(0)[0]) qubit_excitation_pulse = excitation_pulse.get_excitation_pulse(device, qubit_id, rotation_angle=np.pi) metadata = {'qubit_id': qubit_id, 'averages': nums, 'ignore_other_qubits': ignore_other_qubits} references.update({'readout_pulse': qubit_readout_pulse.id, 'excitation_pulse': qubit_excitation_pulse.id, 'delay_calibration': device.modem.delay_measurement.id, 'Zgate': Zgate.id}, ) classifier = single_shot_readout.single_shot_readout(adc=adc, prepare_seqs=[ device.pre_pulses + other_qubit_pulse_sequence, device.pre_pulses + other_qubit_pulse_sequence + qubit_excitation_pulse.get_pulse_sequence(0)], ro_seq=device.trigger_readout_seq + qubit_readout_pulse.get_pulse_sequence(), control_seq=None, # pulse_generator=device.pg, ro_delay_seq=None, _readout_classifier=readout_classifier.binary_linear_classifier(), adc_measurement_name='Voltage') def set_Zgate_amplitude(x): channel_amplitudes1_ = channel_amplitudes.channel_amplitudes(device, **{Zgate.metadata[ 'carrier_name']: x}) print(channel_amplitudes1_) pulse_seq1 = excitation_pulse.get_rect_cos_pulse_sequence(device=device, channel_amplitudes=channel_amplitudes1_, tail_length=float(Zgate.metadata['tail_length']), length=float(qubit_readout_pulse.metadata['length']), phase=0.0) classifier.ro_seq = device.trigger_readout_seq + device.pg.parallel(pulse_seq1,qubit_readout_pulse.get_pulse_sequence()) classifier.readout_classifier.cov_mode = 'equal' try: adc.set_adc_nums(nums) measurement = device.sweeper.sweep(classifier, (amplitudes, set_Zgate_amplitude, 'amplitude', 'Voltage'), measurement_type='readout_Zgate_scan', metadata=metadata, references=references) except: raise finally: adc.set_adc_nums(old_nums) return measurement # classifier.repeat_samples = 2
def readout_fidelity_scan(device, qubit_id, readout_pulse_lengths, readout_pulse_amplitudes, recalibrate_excitation=True, ignore_other_qubits=False, channel_amplitudes=None): adc, mnames = device.setup_adc_reducer_iq(qubit_id, raw=True) nums = int(device.get_qubit_constant(qubit_id=qubit_id, name='readout_background_nums')) adc.set_adc_nop(int(device.get_sample_global('readout_adc_points'))) old_nums = adc.get_adc_nums() readout_channel = [i for i in device.get_qubit_readout_channel_list(qubit_id).keys()][0] other_qubit_pulse_sequence = [] references = {'frequency_controls': device.get_frequency_control_measurement_id(qubit_id=qubit_id)} if hasattr(device.awg_channels[readout_channel], 'get_calibration_measurement'): references['channel_calibration'] = device.awg_channels[readout_channel].get_calibration_measurement() if not ignore_other_qubits: for other_qubit_id in device.get_qubit_list(): if other_qubit_id != qubit_id: '''Warning''' #TODO half_excited_pulse = excitation_pulse.get_excitation_pulse(device, other_qubit_id, rotation_angle=np.pi / 2., recalibrate=recalibrate_excitation) references[('other_qubit_pulse', other_qubit_id)] = half_excited_pulse.id other_qubit_pulse_sequence.extend(half_excited_pulse.get_pulse_sequence(0)) '''Warning''' # TODO qubit_excitation_pulse = excitation_pulse.get_excitation_pulse(device, qubit_id, rotation_angle=np.pi, channel_amplitudes_override=channel_amplitudes, recalibrate=recalibrate_excitation) metadata = {'qubit_id': qubit_id, 'averages': nums, 'channel': readout_channel, 'ignore_other_qubits': ignore_other_qubits} # print ('len(readout_pulse_lengths): ', len(readout_pulse_lengths)) if len(readout_pulse_lengths) == 1: metadata['length'] = str(readout_pulse_lengths[0]) references.update({'excitation_pulse': qubit_excitation_pulse.id, 'delay_calibration': device.modem.delay_measurement.id}) #TODO exitation_channel = [i for i in device.get_qubit_excitation_channel_list(qubit_id).keys()][0] ex_channel = device.awg_channels[exitation_channel] if ex_channel.is_iq(): control_seq_id = ex_channel.parent.sequencer_id else: control_seq_id = ex_channel.channel//2 ex_sequencers = [] for seq_id in device.pre_pulses.seq_in_use: if seq_id != control_seq_id: ex_seq = zi_scripts.SIMPLESequence(sequencer_id=seq_id, awg=device.modem.awg, awg_amp=1, use_modulation=True, pre_pulses = []) else: ex_seq = zi_scripts.SIMPLESequence(sequencer_id=seq_id, awg=device.modem.awg, awg_amp=1, use_modulation=True, pre_pulses=[], control=True) control_sequence = ex_seq device.pre_pulses.set_seq_offsets(ex_seq) device.pre_pulses.set_seq_prepulses(ex_seq) ex_seq.start() ex_sequencers.append(ex_seq) sequence_control.set_preparation_sequence(device, ex_sequencers, other_qubit_pulse_sequence+ qubit_excitation_pulse.get_pulse_sequence(0)) '''Warning''' #readout_sequencer = sequence_control.define_readout_control_seq(device, readout_channel) #raise ValueError('fallos') re_channel = device.awg_channels[readout_channel] readout_sequencer = zi_scripts.READSequence(re_channel.parent.sequencer_id, device.modem.awg) def_frag, play_frag = device.pg.readout_rect(channel=readout_channel, length=readout_pulse_lengths[0], amplitude=readout_pulse_amplitudes[0]) readout_sequencer.add_readout_pulse(def_frag, play_frag) readout_sequencer.stop() device.modem.awg.set_sequence(readout_sequencer.params['sequencer_id'], readout_sequencer) readout_sequencer.set_delay(device.modem.trigger_channel.delay) readout_sequencer.start() classifier = single_shot_readout.single_shot_readout(device=device, adc=adc, prepare_seqs=[other_qubit_pulse_sequence, other_qubit_pulse_sequence + qubit_excitation_pulse.get_pulse_sequence(0)], ex_seqs=ex_sequencers, ro_seq=readout_sequencer, control_seq=control_sequence, #pulse_generator=device.pg, ro_delay_seq=None, _readout_classifier=readout_classifier.binary_linear_classifier(), adc_measurement_name='Voltage', dbg_storage=False) classifier.readout_classifier.cov_mode = 'equal' # setters for sweep readout_amplitude = 0 readout_length = 0 class ParameterSetter: def __init__(self): self.readout_amplitude = 0 self.readout_length = 0 self.channel = readout_channel def set_readout_amplitude(self, x): #nonlocal readout_amplitude self.readout_amplitude = x #classifier.ro_seq = device.trigger_readout_seq + [ # device.pg.p(readout_channel, readout_length, device.pg.rect, readout_amplitude)] classifier.ro_seq.set_awg_amp(x) def set_readout_length(self, x): #nonlocal readout_length self.readout_length = x #classifier.ro_seq = device.trigger_readout_seq + [ # device.pg.p(readout_channel, readout_length, device.pg.rect, readout_amplitude)] classifier.ro_seq.awg.stop_seq(classifier.ro_seq.params['sequencer_id']) def_frag, play_frag = device.pg.readout_rect(channel=self.channel, length=self.readout_length, amplitude=self.readout_amplitude) classifier.ro_seq.clear_readout_pulse() classifier.ro_seq.add_readout_pulse(def_frag, play_frag) device.modem.awg.set_sequence(classifier.ro_seq.params['sequencer_id'], classifier.ro_seq) classifier.ro_seq.awg.start_seq(classifier.ro_seq.params['sequencer_id']) setter = ParameterSetter() try: adc.set_adc_nums(nums) measurement = device.sweeper.sweep(classifier, (readout_pulse_lengths, setter.set_readout_length, 'length', 's'), (readout_pulse_amplitudes, setter.set_readout_amplitude, 'amplitude', ''), measurement_type='readout_fidelity_scan', metadata=metadata, references=references) except: raise finally: adc.set_adc_nums(old_nums) return measurement
def calibrate_readout(device, qubit_id, qubit_readout_pulse, transition='01', ignore_other_qubits=None): adc, mnames = device.setup_adc_reducer_iq(qubit_id, raw=True) nums = int(device.get_qubit_constant(qubit_id=qubit_id, name='readout_background_nums')) old_nums = adc.get_adc_nums() adc.set_adc_nop(int(device.get_sample_global('readout_adc_points'))) if ignore_other_qubits is None: ignore_other_qubits = (device.get_qubit_constant(qubit_id=qubit_id, name='readout_calibration_ignore_other_qubits') == 'True') print ('ignore_other_qubits', ignore_other_qubits) other_qubit_pulse_sequence = [] references = {} if not ignore_other_qubits: for other_qubit_id in device.get_qubit_list(): if other_qubit_id != qubit_id: # TODO '''Warning''' half_excited_pulse = excitation_pulse.get_excitation_pulse(device, other_qubit_id, rotation_angle=np.pi / 2.) references[('other_qubit_pulse', other_qubit_id)] = half_excited_pulse.id other_qubit_pulse_sequence.extend(half_excited_pulse.get_pulse_sequence(0)) # TODO '''Warning''' qubit_excitation_pulse = excitation_pulse.get_excitation_pulse(device, qubit_id, rotation_angle=np.pi) metadata = {'qubit_id': qubit_id, 'averages': nums, 'ignore_other_qubits': ignore_other_qubits} references.update({'readout_pulse': qubit_readout_pulse.id, 'excitation_pulse': qubit_excitation_pulse.id, 'delay_calibration': device.modem.delay_measurement.id}) #TODO exitation_channel = [i for i in device.get_qubit_excitation_channel_list(qubit_id).keys()][0] ex_channel = device.awg_channels[exitation_channel] if ex_channel.is_iq(): control_seq_id = ex_channel.parent.sequencer_id else: control_seq_id = ex_channel.channel//2 ex_sequencers = [] for seq_id in device.pre_pulses.seq_in_use: if seq_id != control_seq_id: ex_seq = zi_scripts.SIMPLESequence(sequencer_id=seq_id, awg=device.modem.awg, awg_amp=1, use_modulation=True, pre_pulses = []) else: ex_seq = zi_scripts.SIMPLESequence(sequencer_id=seq_id, awg=device.modem.awg, awg_amp=1, use_modulation=True, pre_pulses=[], control=True) control_sequence = ex_seq device.pre_pulses.set_seq_offsets(ex_seq) device.pre_pulses.set_seq_prepulses(ex_seq) ex_seq.start() ex_sequencers.append(ex_seq) sequence_control.set_preparation_sequence(device, ex_sequencers, other_qubit_pulse_sequence+ qubit_excitation_pulse.get_pulse_sequence(0)) '''Warning''' #readout_sequencer = sequence_control.define_readout_control_seq(device, readout_channel) #raise ValueError('fallos') readout_sequencer = sequence_control.define_readout_control_seq(device, qubit_readout_pulse) readout_sequencer.start() classifier = single_shot_readout.single_shot_readout(device=device, adc=adc, prepare_seqs=[other_qubit_pulse_sequence, other_qubit_pulse_sequence + qubit_excitation_pulse.get_pulse_sequence(0)], ex_seqs=ex_sequencers, ro_seq=readout_sequencer, control_seq = control_sequence, #pulse_generator=device.pg, ro_delay_seq=None, _readout_classifier=readout_classifier.binary_linear_classifier(), adc_measurement_name='Voltage', dbg_storage=False) classifier.readout_classifier.cov_mode = 'equal' try: adc.set_adc_nums(nums) measurement = device.sweeper.sweep(classifier, measurement_type='readout_calibration', metadata=metadata, references=references) except: raise finally: adc.set_adc_nums(old_nums) return measurement
def readout_fidelity_scan(device, qubit_id, readout_pulse_lengths, readout_pulse_amplitudes, recalibrate_excitation=True, ignore_other_qubits=False, channel_amplitudes=None): adc, mnames = device.setup_adc_reducer_iq(qubit_id, raw=True) nums = int(device.get_qubit_constant(qubit_id=qubit_id, name='readout_background_nums')) adc.set_adc_nop(int(device.get_sample_global('readout_adc_points'))) old_nums = adc.get_adc_nums() readout_channel = [i for i in device.get_qubit_readout_channel_list(qubit_id).keys()][0] other_qubit_pulse_sequence = [] references = {'frequency_controls': device.get_frequency_control_measurement_id(qubit_id=qubit_id)} if hasattr(device.awg_channels[readout_channel], 'get_calibration_measurement'): references['channel_calibration'] = device.awg_channels[readout_channel].get_calibration_measurement() if not ignore_other_qubits: for other_qubit_id in device.get_qubit_list(): if other_qubit_id != qubit_id: half_excited_pulse = excitation_pulse.get_excitation_pulse(device, other_qubit_id, rotation_angle=np.pi / 2., recalibrate=recalibrate_excitation) references[('other_qubit_pulse', other_qubit_id)] = half_excited_pulse.id other_qubit_pulse_sequence.extend(half_excited_pulse.get_pulse_sequence(0)) qubit_excitation_pulse = excitation_pulse.get_excitation_pulse(device, qubit_id, rotation_angle=np.pi, channel_amplitudes_override=channel_amplitudes, recalibrate=recalibrate_excitation) metadata = {'qubit_id': qubit_id, 'averages': nums, 'channel': readout_channel, 'ignore_other_qubits': ignore_other_qubits} # print ('len(readout_pulse_lengths): ', len(readout_pulse_lengths)) if len(readout_pulse_lengths) == 1: metadata['length'] = str(readout_pulse_lengths[0]) references.update({'excitation_pulse': qubit_excitation_pulse.id, 'delay_calibration': device.modem.delay_measurement.id}) classifier = single_shot_readout.single_shot_readout(adc=adc, prepare_seqs=[device.pre_pulses + other_qubit_pulse_sequence, device.pre_pulses + other_qubit_pulse_sequence + qubit_excitation_pulse.get_pulse_sequence(0)], ro_seq=device.trigger_readout_seq, pulse_generator=device.pg, ro_delay_seq=None, _readout_classifier=readout_classifier.binary_linear_classifier(), adc_measurement_name='Voltage', dbg_storage=False) classifier.readout_classifier.cov_mode = 'equal' # setters for sweep readout_amplitude = 0 readout_length = 0 def set_readout_amplitude(x): nonlocal readout_amplitude readout_amplitude = x classifier.ro_seq = device.trigger_readout_seq + [ device.pg.p(readout_channel, readout_length, device.pg.rect, readout_amplitude)] def set_readout_length(x): nonlocal readout_length readout_length = x classifier.ro_seq = device.trigger_readout_seq + [ device.pg.p(readout_channel, readout_length, device.pg.rect, readout_amplitude)] try: adc.set_adc_nums(nums) measurement = device.sweeper.sweep(classifier, (readout_pulse_lengths, set_readout_length, 'length', 's'), (readout_pulse_amplitudes, set_readout_amplitude, 'amplitude', ''), measurement_type='readout_fidelity_scan', metadata=metadata, references=references) except: raise finally: adc.set_adc_nums(old_nums) return measurement