Skip to content

Commit

Permalink
feat: Rename execute_cr_sequence to measure_cr_dynamics and update pa…
Browse files Browse the repository at this point in the history
…rameters for enhanced clarity and functionality
  • Loading branch information
Akinori Machino committed Dec 28, 2024
1 parent 21df44d commit 3b10f84
Showing 1 changed file with 64 additions and 6 deletions.
70 changes: 64 additions & 6 deletions src/qubex/experiment/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -6371,17 +6371,19 @@ def measure_population_dynamics(

return result_pops, result_errs

def execute_cr_sequence(
def measure_cr_dynamics(
self,
*,
control_qubit: str,
target_qubit: str,
time_range: ArrayLike = np.arange(100, 401, 20),
time_range: ArrayLike = np.arange(100, 401, 10),
cr_amplitude: float = 1.0,
cr_ramptime: float = 50,
cr_phase: float = 0.0,
cancel_amplitude: float = 0.0,
cancel_phase: float = 0.0,
echo: bool = False,
pi_pulse: TargetMap[Waveform] | None = None,
control_state: str = "0",
shots: int = DEFAULT_SHOTS,
interval: int = DEFAULT_INTERVAL,
Expand All @@ -6394,6 +6396,9 @@ def execute_cr_sequence(
if target_qubit in self.drag_hpi_pulse:
x90[target_qubit] = self.drag_hpi_pulse[target_qubit]

if pi_pulse is None:
pi_pulse = self.pi_pulse

control_states = []
target_states = []
for T in time_range:
Expand All @@ -6408,6 +6413,7 @@ def execute_cr_sequence(
cancel_amplitude=cancel_amplitude,
cancel_phase=cancel_phase,
echo=echo,
pi_pulse=pi_pulse[control_qubit],
),
x90=x90,
initial_state={control_qubit: control_state},
Expand All @@ -6426,6 +6432,7 @@ def execute_cr_sequence(

def cr_hamiltonian_tomography(
self,
*,
control_qubit: str,
target_qubit: str,
flattop_range: ArrayLike = np.arange(0, 301, 10),
Expand All @@ -6440,7 +6447,7 @@ def cr_hamiltonian_tomography(
) -> dict:
time_range = np.array(flattop_range) + cr_ramptime * 2

result_0 = self.execute_cr_sequence(
result_0 = self.measure_cr_dynamics(
time_range=time_range,
control_qubit=control_qubit,
target_qubit=target_qubit,
Expand All @@ -6454,7 +6461,7 @@ def cr_hamiltonian_tomography(
shots=shots,
interval=interval,
)
result_1 = self.execute_cr_sequence(
result_1 = self.measure_cr_dynamics(
time_range=time_range,
control_qubit=control_qubit,
target_qubit=target_qubit,
Expand Down Expand Up @@ -6526,11 +6533,11 @@ def cr_hamiltonian_tomography(
"cancel_phase": cancel_phase_est,
}

def calibrate_cr_sequence(
def calibrate_cr_params(
self,
*,
control_qubit: str,
target_qubit: str,
*,
flattop_range: ArrayLike = np.arange(0, 301, 10),
cr_amplitude: float = 1.0,
cr_ramptime: float = 50,
Expand All @@ -6540,6 +6547,7 @@ def calibrate_cr_sequence(
plot: bool = True,
) -> dict:
cr_pulse = {
"amplitude": cr_amplitude,
"phase": 0.0,
}
cancel_pulse = {
Expand Down Expand Up @@ -6663,6 +6671,7 @@ def update_params(
f"{control_qubit}-{target_qubit}": {
"cr_pulse": cr_pulse,
"cancel_pulse": cancel_pulse,
"ramptime": cr_ramptime,
},
},
)
Expand All @@ -6673,6 +6682,55 @@ def update_params(
"hamiltonian_coeffs": hamiltonian_coeffs,
}

def calibrate_zx90_by_amplitude(
self,
*,
control_qubit: str,
target_qubit: str,
duration: float = 100,
amplitude_range: ArrayLike = np.linspace(0.0, 0.5, 21),
shots: int = DEFAULT_SHOTS,
interval: int = DEFAULT_INTERVAL,
plot: bool = True,
):
amplitude_range = np.array(amplitude_range)

cr_label = f"{control_qubit}-{target_qubit}"
cr_params = self._system_note.get(CR_PARAMS)[cr_label]
cr_ramptime = cr_params["ramptime"]
cr_amplitude = cr_params["cr_pulse"]["amplitude"]
cr_phase = cr_params["cr_pulse"]["phase"]
cancel_amplitude = cr_params["cancel_pulse"]["amplitude"]
cancel_phase = cr_params["cancel_pulse"]["phase"]

sweep_result = self.sweep_parameter(
lambda amplitude: CrossResonance(
control_qubit=control_qubit,
target_qubit=target_qubit,
cr_amplitude=amplitude,
cr_duration=duration,
cr_ramptime=cr_ramptime,
cr_phase=cr_phase,
cancel_amplitude=cancel_amplitude * amplitude / cr_amplitude,
cancel_phase=cancel_phase,
echo=True,
pi_pulse=self.pi_pulse[target_qubit],
),
sweep_range=amplitude_range,
shots=shots,
interval=interval,
plot=plot,
)

data = sweep_result.data[target_qubit].normalized
fit_result = fitting.fit_polynomial(
target=target_qubit,
x=amplitude_range,
y=data,
degree=3,
)
return fit_result


class ExperimentUtil:
@staticmethod
Expand Down

0 comments on commit 3b10f84

Please sign in to comment.