Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 9 additions & 22 deletions pycqed/analysis_v2/Two_qubit_gate_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
20 changes: 20 additions & 0 deletions pycqed/instrument_drivers/meta_instrument/HAL/HAL_ShimMQ.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 20 additions & 10 deletions pycqed/instrument_drivers/meta_instrument/HAL_Device.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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])

Expand Down Expand Up @@ -2575,6 +2575,7 @@ def measure_cryoscope(
self,
qubits,
times,
park_qubits: List[str] = [],
MC=None,
nested_MC=None,
double_projections: bool = False,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 9 additions & 5 deletions pycqed/measurement/openql_experiments/multi_qubit_oql.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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 = '',
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion pycqed/measurement/sweep_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down