diff --git a/pycqed/analysis_v2/Two_qubit_gate_analysis.py b/pycqed/analysis_v2/Two_qubit_gate_analysis.py index 1c945028d0..7c79d8baef 100644 --- a/pycqed/analysis_v2/Two_qubit_gate_analysis.py +++ b/pycqed/analysis_v2/Two_qubit_gate_analysis.py @@ -2235,33 +2235,20 @@ def process_data(self): # Calculate cost function to find optimal # parameters of amplitude and B amp def cost_function(CP, MF, - phase=180, - cp_tol=3.0, # degrees tolerance for phase - mf_max=0.025, # max acceptable missing fraction error (2.5%) - cp_coef=1.0, l1_coef=0.5, mf_penalty_coef=10.0): + phase=180, + cp_coef=1, l1_coef=1): ''' - Cost function for minimizing conditional phase - error and leakage simultaneously, with tighter constraints. - - CP: conditional phase (degrees) - MF: missing fraction (0 to 1, i.e., percentage) + Cost function for minimizing cphase + error and leakage simultaneously. ''' - # Strongly penalize CP deviation beyond ±2 degrees - A = ((CP - phase) / cp_tol)**2 - - # Normalize MF cost based on acceptable range - B = ((MF - np.min(MF)) / mf_max)**2 - C = (np.mean(MF - np.min(MF), axis=0) / mf_max)**2 - - # Extra penalty for MF exceeding acceptable threshold - MF_penalty = np.where(MF > mf_max, (MF - mf_max)**2, 0) - - return cp_coef*A + l1_coef*(B + C) + mf_penalty_coef * MF_penalty - + A = ((np.abs(CP)-180)/180)**2 + B = ((MF-np.min(MF))/.5)**2 + C = (np.mean(MF-np.min(MF), axis=0)/.5)**2 + return cp_coef*A + l1_coef*(B+C) for i, q0 in enumerate(self.Q0): CP = self.raw_data_dict['data'][:,2*i+2].reshape(ny, nx) MF = self.raw_data_dict['data'][:,2*i+3].reshape(ny, nx) - CF = cost_function(CP, MF) + CF = cost_function(CP, MF, l1_coef=self.l1_coef) # Find minimum of cost function idxs_min = np.unravel_index(np.argmin(CF), CF.shape) A_min, B_min = Amps_list[i][idxs_min[1]], Bamps[idxs_min[0]] diff --git a/pycqed/instrument_drivers/meta_instrument/HAL/HAL_ShimMQ.py b/pycqed/instrument_drivers/meta_instrument/HAL/HAL_ShimMQ.py index 5addd00401..94944bc84e 100644 --- a/pycqed/instrument_drivers/meta_instrument/HAL/HAL_ShimMQ.py +++ b/pycqed/instrument_drivers/meta_instrument/HAL/HAL_ShimMQ.py @@ -160,6 +160,26 @@ def prepare_timing(self): # ch_not_ready += AWG.geti("sigouts/{}/busy".format(i)) # check_keyboard_interrupt() + if "flux" in lat_key: + # Check name to prevent crash when instrument not specified + AWG_name = self.get("instr_AWG_{}".format(lat_key)) + + if AWG_name is not None: + AWG = self.find_instrument(AWG_name) + using_QWG = AWG.__class__.__name__ == "QuTech_AWG_Module" + if not using_QWG: + AWG.stop() + for qubit in self.qubits(): + q_obj = self.find_instrument(qubit) + FLUX_lm = self.find_instrument(q_obj.instr_LutMan_Flux()) + if AWG_name == FLUX_lm.AWG(): + extra_delay = q_obj.flux_fine_delay() + awg_channel = FLUX_lm.cfg_awg_channel() + log.debug("Setting `sigouts_{}_delay` to {:4g}" + " in {}".format(awg_channel, lat_fine, AWG.name)) + AWG.set("sigouts_{}_delay".format(awg_channel - 1), lat_fine + extra_delay) + AWG.start() + def prepare_fluxing(self, qubits): for qb_name in qubits: qb = self.find_instrument(qb_name) diff --git a/pycqed/instrument_drivers/meta_instrument/HAL_Device.py b/pycqed/instrument_drivers/meta_instrument/HAL_Device.py index 60b7af249e..d80aeeeee5 100644 --- a/pycqed/instrument_drivers/meta_instrument/HAL_Device.py +++ b/pycqed/instrument_drivers/meta_instrument/HAL_Device.py @@ -2129,7 +2129,7 @@ def measure_chevron( fl_lutman = self.find_instrument(q0).instr_LutMan_Flux.get_instr() fl_lutman_spec = self.find_instrument(q_spec).instr_LutMan_Flux.get_instr() - + if waveform_name == "square": length_par = fl_lutman.sq_length flux_cw = 6 @@ -2138,7 +2138,7 @@ def measure_chevron( flux_cw = fl_lutman._get_cw_from_wf_name(waveform_name) else: raise ValueError("Waveform shape not understood") - + if prepare_for_timedomain: self.prepare_for_timedomain(qubits=[q0, q_spec]) @@ -2575,6 +2575,7 @@ def measure_cryoscope( self, qubits, times, + park_qubits: List[str] = [], MC=None, nested_MC=None, double_projections: bool = False, @@ -2651,6 +2652,7 @@ def measure_cryoscope( p = mqo.Cryoscope( qubit_idxs=Q_idxs, + parked_qubits_id=[self.find_instrument(q).cfg_qubit_nr() for q in park_qubits], flux_cw=flux_cw, twoq_pair=twoq_pair, wait_time_flux=wait_time_flux, @@ -6453,7 +6455,9 @@ def measure_vcz_A_tmid_landscape( flux_codeword: str = 'cz', flux_pulse_duration: float = 60e-9, prepare_for_timedomain: bool = True, - disable_metadata: bool = False): + disable_metadata: bool = False, + force_lsq_no_detuning: bool = False # added by RDC 21-07-2025 + ): """ Perform 2D sweep of amplitude and wave parameter while measuring conditional phase and missing fraction via the "conditional @@ -6491,9 +6495,11 @@ def measure_vcz_A_tmid_landscape( lm.set(f'vcz_amp_sq_{directions[i][0]}', 1) lm.set(f'vcz_amp_fine_{directions[i][0]}', .5) lm.set(f'vcz_amp_dac_at_11_02_{directions[i][0]}', .5) - for i, lm in enumerate(Flux_lm_1): - print(f'Setting {Q1[i]} vcz_amp_dac_at_11_02_{directions[i][1]} to 0') - lm.set(f'vcz_amp_dac_at_11_02_{directions[i][1]}', 0) + if not force_lsq_no_detuning: # added by RDC 21-07-2025 + for i, lm in enumerate(Flux_lm_1): + print(f'Setting {Q1[i]} vcz_amp_dac_at_11_02_{directions[i][1]} to 0') + lm.set(f'vcz_amp_dac_at_11_02_{directions[i][1]}', 0) + # Look for Tp values if Tp: if isinstance(Tp, str): @@ -6698,7 +6704,8 @@ def measure_vcz_A_B_landscape( cz_repetitions = 1, ro_acq_averages = 2**9, prepare_for_timedomain: bool = True, - disable_metadata: bool = False): + disable_metadata: bool = False, + force_lsq_no_detuning: bool = False): # added by RDC on 21-07-2025 """ Perform 2D sweep of amplitude and wave parameter while measuring conditional phase and missing fraction via the "conditional @@ -6736,9 +6743,12 @@ def measure_vcz_A_B_landscape( print(f'Setting {Q0[i]} vcz_amp_dac_at_11_02_{directions[i][0]} to 0.5') lm.set(f'vcz_amp_sq_{directions[i][0]}', 1) lm.set(f'vcz_amp_dac_at_11_02_{directions[i][0]}', .5) - for i, lm in enumerate(Flux_lm_1): - print(f'Setting {Q1[i]} vcz_amp_dac_at_11_02_{directions[i][1]} to 0') - lm.set(f'vcz_amp_dac_at_11_02_{directions[i][1]}', 0) + if not force_lsq_no_detuning: # added by RDC on 21-07-2025 + for i, lm in enumerate(Flux_lm_1): + print(f'Setting {Q1[i]} vcz_amp_dac_at_11_02_{directions[i][1]} to 0') + lm.set(f'vcz_amp_dac_at_11_02_{directions[i][1]}', 0) + # print('Flux hi') + # print(Flux_lm_1[0].vcz_amp_dac_at_11_02_NE()) # Update two qubit gate parameters if update_flux_params: # List of current flux lutman amplitudes diff --git a/pycqed/instrument_drivers/meta_instrument/Surface17_dependency_graph.py b/pycqed/instrument_drivers/meta_instrument/Surface17_dependency_graph.py index 2977bdf52d..7437402f4e 100644 --- a/pycqed/instrument_drivers/meta_instrument/Surface17_dependency_graph.py +++ b/pycqed/instrument_drivers/meta_instrument/Surface17_dependency_graph.py @@ -554,10 +554,10 @@ def save_snapshot_metadata(station, Qubits=None, Qubit_pairs = None): import pycqed as pq from pycqed.measurement.openql_experiments import generate_CC_cfg as gc input_file = os.path.join(pq.__path__[0], 'measurement', - 'openql_experiments', 'config_cc_s5_direct_iq.json.in') + 'openql_experiments', 'config_cc_s7_direct_iq.json.in') config_fn = os.path.join(pq.__path__[0], 'measurement', - 'openql_experiments', 'output_cc_s5_direct_iq', - 'cc_s5_direct_iq.json') + 'openql_experiments', 'output_cc_s7_direct_iq', + 'cc_s7_direct_iq.json') class Two_qubit_gate_calibration(AutoDepGraph_DAG): def __init__(self, diff --git a/pycqed/measurement/openql_experiments/multi_qubit_oql.py b/pycqed/measurement/openql_experiments/multi_qubit_oql.py index 7b575258ea..c74b79f3bc 100644 --- a/pycqed/measurement/openql_experiments/multi_qubit_oql.py +++ b/pycqed/measurement/openql_experiments/multi_qubit_oql.py @@ -1,4 +1,4 @@ -from typing import List +from typing import List, Optional import numpy as np from pycqed.measurement.openql_experiments.openql_helpers import OqlProgram @@ -587,6 +587,7 @@ def FluxTimingCalibration( def Cryoscope( qubit_idxs: list, + parked_qubits_id: Optional[list] = None, flux_cw: str = 'fl_cw_06', # FIXME: effectively unused twoq_pair=[2, 0], platf_cfg: str = '', @@ -605,6 +606,8 @@ def Cryoscope( Returns: p: OpenQL Program object containing """ + if not parked_qubits_id: + parked_qubits_id = [] p = OqlProgram("Cryoscope", platf_cfg) @@ -615,7 +618,7 @@ def Cryoscope( k.gate('rx90', [q_idx]) k.gate('wait', [], wait_time_flux) k.barrier([]) # alignment workaround - for q_idx in qubit_idxs: + for q_idx in qubit_idxs + parked_qubits_id: k.gate('sf_square', [q_idx]) k.barrier([]) # alignment workaround k.gate('wait', [], wait_time_flux) @@ -633,7 +636,7 @@ def Cryoscope( k.gate('rx90', [q_idx]) k.gate('wait', [], wait_time_flux) k.barrier([]) # alignment workaround - for q_idx in qubit_idxs: + for q_idx in qubit_idxs + parked_qubits_id: k.gate('sf_square', [q_idx]) k.barrier([]) # alignment workaround k.gate('wait', [], wait_time_flux) @@ -652,7 +655,7 @@ def Cryoscope( k.gate('rx90', [q_idx]) k.gate('wait', [], wait_time_flux) k.barrier([]) # alignment workaround - for q_idx in qubit_idxs: + for q_idx in qubit_idxs + parked_qubits_id: k.gate('sf_square', [q_idx]) k.barrier([]) # alignment workaround k.gate('wait', [], wait_time_flux) @@ -670,7 +673,7 @@ def Cryoscope( k.gate('rx90', [q_idx]) k.gate('wait', [], wait_time_flux) k.barrier([]) # alignment workaround - for q_idx in qubit_idxs: + for q_idx in qubit_idxs + parked_qubits_id: k.gate('sf_square', [q_idx]) k.barrier([]) # alignment workaround k.gate('wait', [], wait_time_flux) @@ -910,6 +913,7 @@ def Chevron( k.gate('sf_square', [q_park]) # square pulse # k.gate('sf_{}'.format(flux_cw_name), [qubit_idx]) k.gate('sf_square', [qubit_idx]) + k.gate('sf_square', [qubit_idx_spec]) # Added by RDC 21/07/2025 k.barrier([]) # alignment workaround else: raise ValueError('CC type not understood: {}'.format(cc)) diff --git a/pycqed/measurement/sweep_functions.py b/pycqed/measurement/sweep_functions.py index 55c8b5f76b..0a3af4a479 100644 --- a/pycqed/measurement/sweep_functions.py +++ b/pycqed/measurement/sweep_functions.py @@ -965,7 +965,7 @@ def set_parameter_HDAWG(self, val): old_val_amp = self.lm.cfg_awg_channel_amplitude() self.lm.cfg_awg_channel_amplitude(self.amp_for_generation) self.AWG.stop() - self.lm.load_waveform_onto_AWG_lookuptable(self.waveform_name, regenerate_waveforms=True) + self.lm.load_waveform_onto_AWG_lookuptable(self.waveform_name, regenerate_waveforms=True) if self.amp_for_generation: self.lm.cfg_awg_channel_amplitude(abs(old_val_amp)) diff --git a/requirements.txt b/requirements.txt index c5708baadc..5a3023b7c5 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,7 +6,7 @@ # `pip install qutip` before you install pycqed qcodes -numpy<=1.21 # Required for 3rd party packages that still rely on (deprecated) numpy dtype aliases. Such as np.float, np.complex, etc. (sklearn, ...) +numpy==1.21 # Required for 3rd party packages that still rely on (deprecated) numpy dtype aliases. Such as np.float, np.complex, etc. (sklearn, ...) cython scipy cma