Skip to content

Commit

Permalink
Update 8_cr_calibration.ipynb
Browse files Browse the repository at this point in the history
  • Loading branch information
Akinori Machino committed Dec 27, 2024
1 parent b5ef4ea commit fe3c18d
Showing 1 changed file with 39 additions and 86 deletions.
125 changes: 39 additions & 86 deletions docs/examples/simulator/8_cr_calibration.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -34,7 +34,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -49,10 +49,8 @@
"dephasing_rate = 5e-5\n",
"coupling_strength = 0.01\n",
"\n",
"control_detuning = 0.0\n",
"target_detuning = 0.1e-3\n",
"control_drive_frequency = control_qubit_frequency\n",
"target_drive_frequency = target_qubit_frequency + target_detuning\n",
"target_drive_frequency = target_qubit_frequency\n",
"\n",
"drag_duration = 16\n",
"\n",
Expand All @@ -68,7 +66,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -147,7 +145,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -237,7 +235,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 7,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -331,7 +329,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -346,7 +344,6 @@
" cross_talk_phase: float = 0.0,\n",
" cancel_amplitude: float = 0.0,\n",
" cancel_phase: float = 0.0,\n",
" offresonant: bool = False,\n",
" n_samples: int = 100,\n",
" plot: bool = False,\n",
") -> dict:\n",
Expand Down Expand Up @@ -393,13 +390,11 @@
" fit_0 = fit_rotation(\n",
" times_,\n",
" vectors_0_,\n",
" offresonant=offresonant,\n",
" plot=plot,\n",
" )\n",
" fit_1 = fit_rotation(\n",
" times_,\n",
" vectors_1_,\n",
" offresonant=offresonant,\n",
" plot=plot,\n",
" )\n",
" Omega_0 = fit_0[\"Omega\"]\n",
Expand All @@ -413,67 +408,28 @@
" coeffs = dict(\n",
" zip(\n",
" [\"IX\", \"IY\", \"IZ\", \"ZX\", \"ZY\", \"ZZ\"],\n",
" 0.5 * Omega / (2 * np.pi),\n",
" Omega / (2 * np.pi),\n",
" )\n",
" )\n",
"\n",
" delta = np.array([fit_0[\"delta\"], fit_1[\"delta\"]])\n",
" detuning = -np.mean(delta) / (2 * np.pi)\n",
"\n",
" for key, value in coeffs.items():\n",
" print(f\"{key}: {value * 1e3:+.6f} MHz\")\n",
"\n",
" cr_phase_est = np.arctan2(coeffs[\"ZY\"], coeffs[\"ZX\"])\n",
" cr_phase_est = -np.arctan2(coeffs[\"ZY\"], coeffs[\"ZX\"])\n",
"\n",
" cancel_pulse = (coeffs[\"IX\"] + 1j * coeffs[\"IY\"]) * 2\n",
" cancel_amplitude_est = -np.abs(cancel_pulse)\n",
" cancel_pulse = -(coeffs[\"IX\"] + 1j * coeffs[\"IY\"])\n",
" cancel_amplitude_est = np.abs(cancel_pulse)\n",
" cancel_phase_est = np.angle(cancel_pulse)\n",
"\n",
" return {\n",
" \"Omega\": Omega,\n",
" \"coeffs\": coeffs,\n",
" \"delta\": delta,\n",
" \"detuning\": detuning,\n",
" \"cr_phase_est\": cr_phase_est,\n",
" \"cancel_amplitude_est\": cancel_amplitude_est,\n",
" \"cancel_phase_est\": cancel_phase_est,\n",
" }"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"tomography_0 = hamiltonian_tomography(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_duration=cr_duration,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_ramp=cr_ramp,\n",
" cr_phase=cr_phase,\n",
" cross_talk_amplitude=crosstalk_amplitude,\n",
" cross_talk_phase=crosstalk_phase,\n",
" cancel_amplitude=0.0,\n",
" cancel_phase=0.0,\n",
" offresonant=True,\n",
" plot=True,\n",
")\n",
"\n",
"tomography_0"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"detuning = tomography_0[\"detuning\"]\n",
"detuning"
]
},
{
"cell_type": "code",
"execution_count": null,
Expand All @@ -482,7 +438,7 @@
"source": [
"tomography_1 = hamiltonian_tomography(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_duration=cr_duration,\n",
" cr_ramp=cr_ramp,\n",
Expand All @@ -491,7 +447,6 @@
" cross_talk_phase=crosstalk_phase,\n",
" cancel_amplitude=0.0,\n",
" cancel_phase=0.0,\n",
" offresonant=False,\n",
" plot=True,\n",
")\n",
"\n",
Expand All @@ -516,20 +471,19 @@
"source": [
"tomography_2 = hamiltonian_tomography(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_duration=cr_duration,\n",
" cr_ramp=cr_ramp,\n",
" cr_phase=cr_phase - cr_phase_est,\n",
" cr_phase=cr_phase + cr_phase_est,\n",
" cross_talk_amplitude=crosstalk_amplitude,\n",
" cross_talk_phase=crosstalk_phase,\n",
" cancel_amplitude=0,\n",
" cancel_phase=0,\n",
" offresonant=False,\n",
" plot=True,\n",
")\n",
"\n",
"tomography_2\n"
"tomography_2"
]
},
{
Expand All @@ -552,16 +506,15 @@
"source": [
"tomography_3 = hamiltonian_tomography(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_duration=cr_duration,\n",
" cr_ramp=cr_ramp,\n",
" cr_phase=cr_phase - cr_phase_est,\n",
" cr_phase=cr_phase + cr_phase_est,\n",
" cross_talk_amplitude=crosstalk_amplitude,\n",
" cross_talk_phase=crosstalk_phase,\n",
" cancel_amplitude=cancel_amplitude_est,\n",
" cancel_phase=cancel_phase_est,\n",
" offresonant=False,\n",
" plot=True,\n",
")\n",
"\n",
Expand All @@ -576,11 +529,11 @@
"source": [
"cr_sequence(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_duration=cr_duration,\n",
" cr_ramp=cr_ramp,\n",
" cr_phase=cr_phase - cr_phase_est,\n",
" cr_phase=cr_phase + cr_phase_est,\n",
" crosstalk_amplitude=crosstalk_amplitude,\n",
" crosstalk_phase=crosstalk_phase,\n",
" cancel_amplitude=cancel_amplitude_est,\n",
Expand All @@ -595,7 +548,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 17,
"metadata": {},
"outputs": [],
"source": [
Expand Down Expand Up @@ -665,11 +618,11 @@
" [\n",
" infidelity(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_qubit_frequency - detuning,\n",
" target_drive_frequency=target_qubit_frequency,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_duration=duration,\n",
" cr_ramp=cr_ramp,\n",
" cr_phase=cr_phase - cr_phase_est,\n",
" cr_phase=cr_phase + cr_phase_est,\n",
" cancel_amplitude=cancel_amplitude_est,\n",
" cancel_phase=cancel_phase_est,\n",
" )\n",
Expand Down Expand Up @@ -721,11 +674,11 @@
"source": [
"infidelity(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_qubit_frequency - detuning,\n",
" target_drive_frequency=target_qubit_frequency,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_duration=cr_duration_est,\n",
" cr_ramp=cr_ramp,\n",
" cr_phase=cr_phase - cr_phase_est,\n",
" cr_phase=cr_phase + cr_phase_est,\n",
" cancel_amplitude=cancel_amplitude_est,\n",
" cancel_phase=cancel_phase_est,\n",
")"
Expand All @@ -739,11 +692,11 @@
"source": [
"result_ecr_0 = simulate_cr(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_duration=cr_duration_est,\n",
" cr_ramp=cr_ramp,\n",
" cr_phase=cr_phase - cr_phase_est,\n",
" cr_phase=cr_phase + cr_phase_est,\n",
" crosstalk_amplitude=crosstalk_amplitude,\n",
" crosstalk_phase=crosstalk_phase,\n",
" cancel_amplitude=cancel_amplitude_est,\n",
Expand All @@ -762,11 +715,11 @@
"source": [
"result_ecr_1 = simulate_cr(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_duration=cr_duration_est,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_ramp=cr_ramp,\n",
" cr_phase=cr_phase - cr_phase_est,\n",
" cr_phase=cr_phase + cr_phase_est,\n",
" crosstalk_amplitude=crosstalk_amplitude,\n",
" crosstalk_phase=crosstalk_phase,\n",
" cancel_amplitude=cancel_amplitude_est,\n",
Expand All @@ -779,7 +732,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 24,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -792,7 +745,7 @@
" ) = x\n",
" result_0 = simulate_cr(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_duration=cr_duration_est,\n",
" cr_ramp=cr_ramp,\n",
Expand All @@ -808,7 +761,7 @@
" )\n",
" result_1 = simulate_cr(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude,\n",
" cr_duration=cr_duration_est,\n",
" cr_ramp=cr_ramp,\n",
Expand Down Expand Up @@ -841,7 +794,7 @@
"\n",
"initial_guess = [\n",
" # cr_amplitude,\n",
" cr_phase - cr_phase_est,\n",
" cr_phase + cr_phase_est,\n",
" cancel_amplitude_est,\n",
" 0.0,\n",
"]\n",
Expand Down Expand Up @@ -892,7 +845,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 27,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -917,7 +870,7 @@
"metadata": {},
"outputs": [],
"source": [
"cr_phase - cr_phase_est, cancel_amplitude_est, 0.0"
"cr_phase + cr_phase_est, cancel_amplitude_est, 0.0"
]
},
{
Expand All @@ -928,7 +881,7 @@
"source": [
"result_0 = simulate_cr(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude_opt,\n",
" cr_duration=cr_duration_est,\n",
" cr_ramp=cr_ramp,\n",
Expand All @@ -951,7 +904,7 @@
"source": [
"result_1 = simulate_cr(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude_opt,\n",
" cr_duration=cr_duration_est,\n",
" cr_ramp=cr_ramp,\n",
Expand All @@ -974,7 +927,7 @@
"source": [
"cr_sequence(\n",
" control_drive_frequency=control_drive_frequency,\n",
" target_drive_frequency=target_drive_frequency - detuning,\n",
" target_drive_frequency=target_drive_frequency,\n",
" cr_amplitude=cr_amplitude_opt,\n",
" cr_duration=cr_duration_est,\n",
" cr_ramp=cr_ramp,\n",
Expand All @@ -994,7 +947,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"display_name": "3.9.18",
"language": "python",
"name": "python3"
},
Expand Down

0 comments on commit fe3c18d

Please sign in to comment.