From 610b2257273a88f19796c0ed544ef3e3a832c638 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Sat, 26 Oct 2024 15:28:06 +0900 Subject: [PATCH 01/22] Update fine_amplitude.py update fine_amplitude.py --- .../library/calibration/fine_amplitude.py | 102 +++++++++++++++++- 1 file changed, 100 insertions(+), 2 deletions(-) diff --git a/qiskit_experiments/library/calibration/fine_amplitude.py b/qiskit_experiments/library/calibration/fine_amplitude.py index 8e3ff17972..c99f8d4768 100644 --- a/qiskit_experiments/library/calibration/fine_amplitude.py +++ b/qiskit_experiments/library/calibration/fine_amplitude.py @@ -36,6 +36,40 @@ class FineAmplitudeCal(BaseCalibrationExperiment, FineAmplitude): experiment the circuits that are run have a custom gate with the pulse schedule attached to it through the calibrations. + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=False, seed=101) + + .. jupyter-execute:: + + import numpy as np + from qiskit.circuit.library import XGate + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library import FineAmplitudeCal + + library = FixedFrequencyTransmon() + cals = Calibrations.from_backend(backend=backend, libraries=[library]) + exp_cal = FineAmplitudeCal(physical_qubits=(0,), + calibrations=cals, + schedule_name="x", + backend=backend, + cal_parameter_name="amp", + auto_update=True, + gate=XGate(), + measurement_qubits=(0,)) + # This option is necessary! + exp_cal.analysis.set_options(fixed_parameters={"angle_per_gate" : np.pi, "phase_offset" : np.pi/2}) + + print(exp_cal.circuits()[5]) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) """ def __init__( @@ -156,8 +190,38 @@ def update_calibrations(self, experiment_data: ExperimentData): class FineXAmplitudeCal(FineAmplitudeCal): - """A calibration experiment to calibrate the amplitude of the X schedule.""" + r"""A calibration experiment to calibrate the amplitude of the X schedule. + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=111) + + .. jupyter-execute:: + + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library import FineXAmplitudeCal + + library = FixedFrequencyTransmon(default_values={"duration": 320}) + cals = Calibrations.from_backend(backend, libraries=[library]) + + exp_cal = FineXAmplitudeCal((0,), + cals, + schedule_name="x", + backend=backend, + cal_parameter_name="amp", + auto_update=True, + ) + + exp_data = exp_cal.run().block_for_results() + display(exp_data.figure(0)) + exp_data.analysis_results(dataframe=True) + """ + def __init__( self, physical_qubits: Sequence[int], @@ -204,7 +268,41 @@ def _pre_circuit(self, num_clbits: int) -> QuantumCircuit: class FineSXAmplitudeCal(FineAmplitudeCal): - """A calibration experiment to calibrate the amplitude of the SX schedule.""" + r"""A calibration experiment to calibrate the amplitude of the SX schedule. + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=105) + + .. jupyter-execute:: + + import numpy as np + import qiskit.pulse as pulse + from qiskit import schedule + from qiskit.circuit import Parameter + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library import FineSXAmplitudeCal + + library = FixedFrequencyTransmon(default_values={"duration": 320}) + cals = Calibrations.from_backend(backend, libraries=[library]) + + exp_cal = FineSXAmplitudeCal((0,), + cals, + schedule_name="sx", + backend=backend, + cal_parameter_name="amp", + auto_update=True, + ) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, From 406ed4634c01df7f04dfab91624a3e9a02a40d99 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Sat, 26 Oct 2024 15:49:46 +0900 Subject: [PATCH 02/22] Update fine_drag_cal.py update fine_drag_cal.py --- .../library/calibration/fine_drag_cal.py | 104 +++++++++++++++++- 1 file changed, 101 insertions(+), 3 deletions(-) diff --git a/qiskit_experiments/library/calibration/fine_drag_cal.py b/qiskit_experiments/library/calibration/fine_drag_cal.py index 74ff341657..5735eaf4f6 100644 --- a/qiskit_experiments/library/calibration/fine_drag_cal.py +++ b/qiskit_experiments/library/calibration/fine_drag_cal.py @@ -30,7 +30,38 @@ class FineDragCal(BaseCalibrationExperiment, FineDrag): - """A calibration version of the fine DRAG experiment.""" + r"""A calibration version of the fine DRAG experiment. + + # section: example + .. jupyter-execute:: + :hide-code: + + #backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=False, seed=108) + + .. jupyter-execute:: + + import numpy as np + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library import FineDragCal + + library = FixedFrequencyTransmon(default_values={"duration": 320}) + cals = Calibrations.from_backend(backend, libraries=[library]) + + exp_cal = FineDragCal((0,), + cals, + backend=backend, + schedule_name="sx", + cal_parameter_name="β", + auto_update=True, + ) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, @@ -146,7 +177,44 @@ def update_calibrations(self, experiment_data: ExperimentData): class FineXDragCal(FineDragCal): - """Fine DRAG calibration of X gate.""" + r"""Fine DRAG calibration of X gate. + + # section: example + .. jupyter-execute:: + :hide-code: + + #backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=False, seed=118) + + .. jupyter-execute:: + + import numpy as np + import pandas as pd + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library import FineXDragCal + + library = FixedFrequencyTransmon(default_values={"duration": 320, "amp": 0.4}) + cals = Calibrations.from_backend(backend, libraries=[library]) + + exp_cal = FineXDragCal((0,), + cals, + backend=backend, + cal_parameter_name="β", + auto_update=True, + ) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + display(cal_data.analysis_results(dataframe=True)) + + pd.DataFrame(**cals.parameters_table(qubit_list=[0])) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, @@ -178,7 +246,37 @@ def __init__( class FineSXDragCal(FineDragCal): - """Fine DRAG calibration of X gate.""" + r"""Fine DRAG calibration of X gate. + + # section: example + .. jupyter-execute:: + :hide-code: + + #backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=False, seed=118) + + .. jupyter-execute:: + + import numpy as np + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library import FineSXDragCal + + library = FixedFrequencyTransmon(default_values={"duration": 320}) + cals = Calibrations.from_backend(backend=backend, libraries=[library]) + + exp_cal = FineSXDragCal((0,), + cals, + backend=backend, + cal_parameter_name="β", + auto_update=True, + ) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, From a8c7b910989d8dc9879ac323bc1f3187ba14e497 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Sat, 26 Oct 2024 15:56:21 +0900 Subject: [PATCH 03/22] Update fine_frequency_cal.py update fine_frequency_cal.py --- .../library/calibration/fine_frequency_cal.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/calibration/fine_frequency_cal.py b/qiskit_experiments/library/calibration/fine_frequency_cal.py index 13b1c64b62..7cc161d5f6 100644 --- a/qiskit_experiments/library/calibration/fine_frequency_cal.py +++ b/qiskit_experiments/library/calibration/fine_frequency_cal.py @@ -28,7 +28,31 @@ class FineFrequencyCal(BaseCalibrationExperiment, FineFrequency): - """A calibration version of the fine frequency experiment.""" + r"""A calibration version of the fine frequency experiment. + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_ibm_runtime.fake_provider import FakePerth + from qiskit_aer import AerSimulator + + backend = AerSimulator.from_backend(FakePerth()) + + .. jupyter-execute:: + + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library.calibration.fine_frequency_cal import FineFrequencyCal + + cals = Calibrations.from_backend(backend=backend, libraries=[FixedFrequencyTransmon()]) + exp_cal = FineFrequencyCal((0,), cals, backend=backend, auto_update=True, gate_name="sx") + + cal_data=exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, From edf38217d16bb420190b48d13547bc4aa61d48c0 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:02:11 +0900 Subject: [PATCH 04/22] Update frequency_cal.py update frequency_cal.py --- .../library/calibration/frequency_cal.py | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/calibration/frequency_cal.py b/qiskit_experiments/library/calibration/frequency_cal.py index 5f683b217d..e96d23812b 100644 --- a/qiskit_experiments/library/calibration/frequency_cal.py +++ b/qiskit_experiments/library/calibration/frequency_cal.py @@ -27,7 +27,31 @@ class FrequencyCal(BaseCalibrationExperiment, RamseyXY): - """A qubit frequency calibration experiment based on the Ramsey XY experiment.""" + r"""A qubit frequency calibration experiment based on the Ramsey XY experiment. + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_ibm_runtime.fake_provider import FakePerth + from qiskit_aer import AerSimulator + + backend = AerSimulator.from_backend(FakePerth()) + + .. jupyter-execute:: + + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library.calibration.frequency_cal import FrequencyCal + + cals = Calibrations.from_backend(backend=backend, libraries=[FixedFrequencyTransmon()]) + exp_cal = FrequencyCal((0,), cals, backend=backend, auto_update=True) + + cal_data=exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, From 2aed40fcd10672c816de1fa6b1bed4d7b0eb0883 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:08:22 +0900 Subject: [PATCH 05/22] Update half_angle_cal.py update half_angle_cal.py --- .../library/calibration/half_angle_cal.py | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/calibration/half_angle_cal.py b/qiskit_experiments/library/calibration/half_angle_cal.py index e3c3784ba3..696e0057f5 100644 --- a/qiskit_experiments/library/calibration/half_angle_cal.py +++ b/qiskit_experiments/library/calibration/half_angle_cal.py @@ -28,7 +28,40 @@ class HalfAngleCal(BaseCalibrationExperiment, HalfAngle): - """Calibration version of the :class:`.HalfAngle` experiment.""" + r"""Calibration version of the :class:`.HalfAngle` experiment. + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=False, seed=199) + + .. jupyter-execute:: + + from qiskit import pulse + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library.calibration.half_angle_cal import HalfAngleCal + + library = FixedFrequencyTransmon(default_values={"duration": 640}) + cals = Calibrations.from_backend(backend=backend, libraries=[library]) + exp_cal = HalfAngleCal((0,), cals, backend=backend) + + inst_map = backend.defaults().instruction_schedule_map + with pulse.build(backend=backend, name="y") as sched_build: + pulse.play(pulse.Drag(duration=160, + sigma=40, + beta=5, + amp=0.05821399464431249, + angle=0.0,), pulse.DriveChannel(0),) + inst_map.add("y", (0,), sched_build) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, From 3ce9c6bbb835c888bb98d9d6d2ab82c10a715867 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:25:54 +0900 Subject: [PATCH 06/22] Update rough_amplitude_cal.py update rough_amplitude_cal.py --- .../calibration/rough_amplitude_cal.py | 133 +++++++++++++++++- 1 file changed, 131 insertions(+), 2 deletions(-) diff --git a/qiskit_experiments/library/calibration/rough_amplitude_cal.py b/qiskit_experiments/library/calibration/rough_amplitude_cal.py index c6bea05d53..24f67522f0 100644 --- a/qiskit_experiments/library/calibration/rough_amplitude_cal.py +++ b/qiskit_experiments/library/calibration/rough_amplitude_cal.py @@ -31,7 +31,40 @@ class RoughAmplitudeCal(BaseCalibrationExperiment, Rabi): - """A calibration version of the Rabi experiment.""" + r"""A calibration version of the Rabi experiment. + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=106) + + .. jupyter-execute:: + + import numpy as np + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library.calibration import RoughAmplitudeCal + + library = FixedFrequencyTransmon() + cals = Calibrations.from_backend(backend=backend, libraries=[library]) + + exp_cal = RoughAmplitudeCal(physical_qubits=(0,), + calibrations=cals, + schedule_name="x", + amplitudes=np.linspace(-0.1, 0.1, 51), + cal_parameter_name="amp", + target_angle=np.pi, + auto_update=True, + group="default", + backend=backend) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, @@ -189,7 +222,31 @@ def update_calibrations(self, experiment_data: ExperimentData): class RoughXSXAmplitudeCal(RoughAmplitudeCal): - """A rough amplitude calibration of x and sx gates.""" + r"""A rough amplitude calibration of x and sx gates. + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=180) + + .. jupyter-execute:: + + import numpy as np + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library.calibration import RoughXSXAmplitudeCal + + library = FixedFrequencyTransmon() + cals = Calibrations.from_backend(backend, libraries=[library]) + exp_cal = RoughXSXAmplitudeCal((0,), cals, backend=backend, amplitudes=np.linspace(-0.1, 0.1, 51)) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, @@ -220,6 +277,78 @@ def __init__( class EFRoughXSXAmplitudeCal(RoughAmplitudeCal): r"""A rough amplitude calibration of :math:`X` and :math:`SX` gates on the :math:`|1\rangle` <-> :math:`|2\rangle` transition. + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=180) + + .. jupyter-execute:: + + import numpy as np + import pandas as pd + import qiskit.pulse as pulse + from qiskit.compiler import schedule + from qiskit.circuit import Parameter + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library.calibration import EFRoughXSXAmplitudeCal + + library = FixedFrequencyTransmon() + cals = Calibrations.from_backend( + backend=backend, + libraries=[library] + ) + + amp = Parameter("amp") + + with pulse.build(name="x12") as build_x12: + with pulse.align_left(): + pulse.shift_frequency(-.25e9, pulse.DriveChannel(0)) + pulse.play(pulse.Drag(160, + amp, + 40, + 0., + 0., + ), pulse.DriveChannel(0)) + + with pulse.build(name="sx12") as build_sx12: + with pulse.align_left(): + pulse.shift_frequency(-.25e9, pulse.DriveChannel(0)) + pulse.play(pulse.Drag(160, + amp / 2, + 40, + 0., + 0., + ), pulse.DriveChannel(0)) + + cals.add_schedule(build_x12, qubits=(0,), num_qubits=1) + cals.add_schedule(build_sx12, qubits=(0,), num_qubits=1) + for sched in ["x", "x12"]: + cals.add_parameter_value(0.5, "amp", (0,), schedule=sched) + + for sched in ["sx", "sx12"]: + cals.add_parameter_value(0.25, "amp", (0,), schedule=sched) + + columns_to_show = ["parameter", "qubits", "schedule", "value", "date_time"] + pd.DataFrame(**cals.parameters_table(qubit_list=[0, ()]))[columns_to_show] + + exp_cal = EFRoughXSXAmplitudeCal(physical_qubits=(0,), + calibrations=cals, + amplitudes=np.linspace(-0.1, 0.1, 51), + backend=backend, + ef_pulse_label="12",) + + print(exp_cal.calibrations) + print(exp_cal.circuits()[0]) + print(exp_cal.circuits()[0].calibrations) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) """ __outcome__ = "rabi_rate_12" From 299b66e85bf97697cf6094882dcb43496053b6bf Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:36:09 +0900 Subject: [PATCH 07/22] Update rough_drag_cal.py update rough_drag_cal.py --- .../library/calibration/rough_drag_cal.py | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/qiskit_experiments/library/calibration/rough_drag_cal.py b/qiskit_experiments/library/calibration/rough_drag_cal.py index 21e055f8c4..afe8a2599e 100644 --- a/qiskit_experiments/library/calibration/rough_drag_cal.py +++ b/qiskit_experiments/library/calibration/rough_drag_cal.py @@ -32,6 +32,32 @@ class RoughDragCal(BaseCalibrationExperiment, RoughDrag): # section: manual :ref:`DRAG Calibration` + # section: example + .. jupyter-execute:: + :hide-code: + + #backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=False, seed=161) + + .. jupyter-execute:: + + import numpy as np + import qiskit.pulse as pulse + from qiskit import schedule + from qiskit.circuit import Parameter + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library import RoughDragCal + + library = FixedFrequencyTransmon(default_values={"duration": 320, "amp": 0.03}) + cals = Calibrations.from_backend(backend=backend, libraries=[library]) + exp_cal = RoughDragCal((0,), cals, backend=backend, betas=np.linspace(-20, 20, 25)) + exp_cal.set_experiment_options(reps=[3, 5, 7]) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) """ def __init__( From df39f1ed4fbb4886ab4b7c1638b13d7120a3f142 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Sat, 26 Oct 2024 16:45:14 +0900 Subject: [PATCH 08/22] Update rough_frequency.py update rough_frequency.py remark: RoughEFFrequencyCal is missing --- .../library/calibration/rough_frequency.py | 38 ++++++++++++++++++- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/qiskit_experiments/library/calibration/rough_frequency.py b/qiskit_experiments/library/calibration/rough_frequency.py index a40f7dcb80..2d5bbff39e 100644 --- a/qiskit_experiments/library/calibration/rough_frequency.py +++ b/qiskit_experiments/library/calibration/rough_frequency.py @@ -27,8 +27,37 @@ class RoughFrequencyCal(BaseCalibrationExperiment, QubitSpectroscopy): - """A calibration experiment that runs :class:`.QubitSpectroscopy` to calibrate the qubit - transition frequency.""" + r"""A calibration experiment that runs :class:`.QubitSpectroscopy` to calibrate the qubit + transition frequency. + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5.2e9,-.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=100) + + .. jupyter-execute:: + + import numpy as np + from qiskit_experiments.calibration_management.calibrations import Calibrations + from qiskit_experiments.calibration_management.basis_gate_library import FixedFrequencyTransmon + from qiskit_experiments.library.calibration.rough_frequency import RoughFrequencyCal + + qubit=0 + library = FixedFrequencyTransmon() + cals = Calibrations.from_backend(backend=backend, libraries=[library]) + + freq_est = backend.defaults().qubit_freq_est[qubit] + frequencies = np.linspace(freq_est-15e6, freq_est+15e6, 51) + exp_cal = RoughFrequencyCal((qubit,), cals, frequencies, backend=backend) + exp_cal.set_experiment_options(amp=0.005) + + cal_data = exp_cal.run().block_for_results() + display(cal_data.figure(0)) + cal_data.analysis_results(dataframe=True) + """ def __init__( self, @@ -78,6 +107,11 @@ def _attach_calibrations(self, circuit: QuantumCircuit): class RoughEFFrequencyCal(BaseCalibrationExperiment, EFSpectroscopy): r"""A calibration experiment that runs :class:`.QubitSpectroscopy` for the :math:`|1\rangle` <-> :math:`|2\rangle` transition. + + + + + """ __updater__ = Frequency From 9754dca7c210969e30180b443b7c735dca80c320 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:49:07 +0900 Subject: [PATCH 09/22] Update qst_experiment.py update QST --- .../library/tomography/qst_experiment.py | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/tomography/qst_experiment.py b/qiskit_experiments/library/tomography/qst_experiment.py index 39c17a11d6..226f67cfa5 100644 --- a/qiskit_experiments/library/tomography/qst_experiment.py +++ b/qiskit_experiments/library/tomography/qst_experiment.py @@ -26,7 +26,7 @@ class StateTomography(TomographyExperiment): - """An experiment to reconstruct the quantum state from measurement data. + r"""An experiment to reconstruct the quantum state from measurement data. # section: overview Quantum state tomography (QST) is a method for experimentally @@ -47,6 +47,41 @@ class StateTomography(TomographyExperiment): # section: manual :doc:`/manuals/verification/state_tomography` + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_aer import AerSimulator + from qiskit_ibm_runtime.fake_provider import FakePerth + + backend = AerSimulator.from_backend(FakePerth()) + + .. jupyter-execute:: + + from qiskit import QuantumCircuit + from qiskit_experiments.library import TomographyExperiment + from qiskit_experiments.library.tomography.basis import PauliMeasurementBasis + from qiskit.visualization import plot_state_city + + nq = 2 + qc_ghz = QuantumCircuit(nq) + qc_ghz.h(0) + qc_ghz.s(0) + + for i in range(1, nq): + qc_ghz.cx(0, i) + + qstexp = TomographyExperiment( + circuit=qc_ghz, + backend=backend, + physical_qubits=(0,1), + measurement_basis=PauliMeasurementBasis(), + ) + + qstdata = qstexp.run(backend=backend, shots=1000, seed_simulator=100).block_for_results() + state_result = qstdata.analysis_results("state") + plot_state_city(state_result.value, title="Density Matrix") """ def __init__( From f0bfe3613a27505d2b528ab2fa4eba4bf1c4def8 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Mon, 28 Oct 2024 22:56:58 +0900 Subject: [PATCH 10/22] Update qst_experiment.py upsate StateTomography --- .../library/tomography/qst_experiment.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/qiskit_experiments/library/tomography/qst_experiment.py b/qiskit_experiments/library/tomography/qst_experiment.py index 226f67cfa5..e5fdaae4f4 100644 --- a/qiskit_experiments/library/tomography/qst_experiment.py +++ b/qiskit_experiments/library/tomography/qst_experiment.py @@ -51,7 +51,7 @@ class StateTomography(TomographyExperiment): .. jupyter-execute:: :hide-code: - # backend + # backend from qiskit_aer import AerSimulator from qiskit_ibm_runtime.fake_provider import FakePerth @@ -60,8 +60,7 @@ class StateTomography(TomographyExperiment): .. jupyter-execute:: from qiskit import QuantumCircuit - from qiskit_experiments.library import TomographyExperiment - from qiskit_experiments.library.tomography.basis import PauliMeasurementBasis + from qiskit_experiments.library import StateTomography from qiskit.visualization import plot_state_city nq = 2 @@ -72,17 +71,11 @@ class StateTomography(TomographyExperiment): for i in range(1, nq): qc_ghz.cx(0, i) - qstexp = TomographyExperiment( - circuit=qc_ghz, - backend=backend, - physical_qubits=(0,1), - measurement_basis=PauliMeasurementBasis(), - ) - + qstexp = StateTomography(qc_ghz) qstdata = qstexp.run(backend=backend, shots=1000, seed_simulator=100).block_for_results() state_result = qstdata.analysis_results("state") plot_state_city(state_result.value, title="Density Matrix") - """ + """ def __init__( self, From 6c432531ec94bd74c3caeb66f3486edd6a6860b3 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:03:15 +0900 Subject: [PATCH 11/22] Update tomography_experiment.py update TomographyExperiment --- .../tomography/tomography_experiment.py | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/tomography/tomography_experiment.py b/qiskit_experiments/library/tomography/tomography_experiment.py index bced816a49..f28aab561d 100644 --- a/qiskit_experiments/library/tomography/tomography_experiment.py +++ b/qiskit_experiments/library/tomography/tomography_experiment.py @@ -27,10 +27,46 @@ class TomographyExperiment(BaseExperiment): - """Base experiment for quantum state and process tomography. + r"""Base experiment for quantum state and process tomography. # section: analysis_ref :class:`TomographyAnalysis` + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_aer import AerSimulator + from qiskit_ibm_runtime.fake_provider import FakePerth + + backend = AerSimulator.from_backend(FakePerth()) + + .. jupyter-execute:: + + from qiskit import QuantumCircuit + from qiskit_experiments.library import TomographyExperiment + from qiskit_experiments.library.tomography.basis import PauliMeasurementBasis + from qiskit.visualization import plot_state_city + + nq = 2 + qc_ghz = QuantumCircuit(nq) + qc_ghz.h(0) + qc_ghz.s(0) + + for i in range(1, nq): + qc_ghz.cx(0, i) + + qstexp = TomographyExperiment( + circuit=qc_ghz, + backend=backend, + physical_qubits=(0,1), + measurement_basis=PauliMeasurementBasis(), + ) + + qstdata = qstexp.run(backend=backend, shots=1000, seed_simulator=100).block_for_results() + state_result = qstdata.analysis_results("state") + plot_state_city(state_result.value, title="Density Matrix") """ @classmethod From 0e8e6adb8c266568c9be859637d4854bffa3ba5c Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:14:57 +0900 Subject: [PATCH 12/22] Update mit_qst_experiment.py update MitigatedStateTomography --- .../library/tomography/mit_qst_experiment.py | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/tomography/mit_qst_experiment.py b/qiskit_experiments/library/tomography/mit_qst_experiment.py index 98bec48fe2..cf7c7308ff 100644 --- a/qiskit_experiments/library/tomography/mit_qst_experiment.py +++ b/qiskit_experiments/library/tomography/mit_qst_experiment.py @@ -25,7 +25,7 @@ class MitigatedStateTomography(BatchExperiment): - """A batched experiment to characterize readout error then perform state tomography + r"""A batched experiment to characterize readout error then perform state tomography for doing readout error mitigated state tomography. # section: overview @@ -50,6 +50,41 @@ class MitigatedStateTomography(BatchExperiment): * :py:class:`qiskit_experiments.library.tomography.StateTomography` * :py:class:`qiskit_experiments.library.characterization.LocalReadoutError` + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_aer import AerSimulator + from qiskit_ibm_runtime.fake_provider import FakePerth + from qiskit_aer.noise import NoiseModel + + noise_model = NoiseModel.from_backend(FakePerth(), + thermal_relaxation=False, + gate_error=False, + readout_error=True, + ) + + backend = AerSimulator.from_backend(FakePerth(), noise_model=noise_model) + + .. jupyter-execute:: + + from qiskit import QuantumCircuit + from qiskit_experiments.library import MitigatedStateTomography + from qiskit.visualization import plot_state_city + + nq = 2 + qc_ghz = QuantumCircuit(nq) + qc_ghz.h(0) + qc_ghz.s(0) + + for i in range(1, nq): + qc_ghz.cx(0, i) + + mitqstexp = MitigatedStateTomography(qc_ghz) + mitqstdata = mitqstexp.run(backend=backend, shots=1000, seed_simulator=100).block_for_results() + state_result = mitqstdata.analysis_results("state") + plot_state_city(state_result.value, title="mitigated Density Matrix") """ def __init__( From 5eeea9b329b107d4ea80bbd694b071cb53ef3778 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:22:03 +0900 Subject: [PATCH 13/22] Update qpt_experiment.py update ProcessTomography --- .../library/tomography/qpt_experiment.py | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/tomography/qpt_experiment.py b/qiskit_experiments/library/tomography/qpt_experiment.py index 17d7d7347b..f0b07bc078 100644 --- a/qiskit_experiments/library/tomography/qpt_experiment.py +++ b/qiskit_experiments/library/tomography/qpt_experiment.py @@ -27,7 +27,7 @@ class ProcessTomography(TomographyExperiment): - """An experiment to reconstruct the quantum channel from measurement data. + r"""An experiment to reconstruct the quantum channel from measurement data. # section: overview Quantum process tomography (QPT) is a method for experimentally @@ -46,6 +46,49 @@ class ProcessTomography(TomographyExperiment): # section: analysis_ref :class:`ProcessTomographyAnalysis` + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_aer import AerSimulator + from qiskit_ibm_runtime.fake_provider import FakePerth + + backend = AerSimulator.from_backend(FakePerth()) + + .. jupyter-execute:: + + import numpy as np + from qiskit import QuantumCircuit + from qiskit_experiments.library import ProcessTomography + + num_qubits = 2 + qc_ghz = QuantumCircuit(num_qubits) + qc_ghz.h(0) + qc_ghz.s(0) + + for i in range(1, num_qubits): + qc_ghz.cx(0, i) + + qptexp = ProcessTomography(qc_ghz) + qptdata = qptexp.run(backend=backend, shots=1000, seed_simulator=100).block_for_results() + choi_out = qptdata.analysis_results("state").value + + # extracting a densitymatrix from choi_out + from qiskit.visualization import plot_state_city + import qiskit.quantum_info as qinfo + + _rho_exp_00 = np.array([[None, None, None, None], + [None, None, None, None], + [None, None, None, None], + [None, None, None, None]]) + + for i in range(4): + for j in range(4): + _rho_exp_00[i][j] = choi_out.data[i][j] + + rho_exp_00 = qinfo.DensityMatrix(_rho_exp_00) + display(plot_state_city(rho_exp_00, title="Density Matrix")) """ def __init__( From 0be4c0ddf48c89f19ae1185e9ae9da4b3cff44de Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Mon, 28 Oct 2024 23:32:01 +0900 Subject: [PATCH 14/22] Update mit_qpt_experiment.py update MitigatedProcessTomography --- .../library/tomography/mit_qpt_experiment.py | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/tomography/mit_qpt_experiment.py b/qiskit_experiments/library/tomography/mit_qpt_experiment.py index bdebf34bd0..0d31d79c06 100644 --- a/qiskit_experiments/library/tomography/mit_qpt_experiment.py +++ b/qiskit_experiments/library/tomography/mit_qpt_experiment.py @@ -25,7 +25,7 @@ class MitigatedProcessTomography(BatchExperiment): - """A batched experiment to characterize readout error then perform process tomography + r"""A batched experiment to characterize readout error then perform process tomography for doing readout error mitigated process tomography. # section: overview @@ -50,6 +50,49 @@ class MitigatedProcessTomography(BatchExperiment): * :py:class:`qiskit_experiments.library.tomography.ProcessTomography` * :py:class:`qiskit_experiments.library.characterization.LocalReadoutError` + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_aer import AerSimulator + from qiskit_ibm_runtime.fake_provider import FakePerth + + backend = AerSimulator.from_backend(FakePerth()) + + ..jupyter-execute:: + + import numpy as np + from qiskit import QuantumCircuit + from qiskit_experiments.library import MitigatedProcessTomography + + num_qubits = 2 + qc_ghz = QuantumCircuit(num_qubits) + qc_ghz.h(0) + qc_ghz.s(0) + + for i in range(1, num_qubits): + qc_ghz.cx(0, i) + + mitqptexp = MitigatedProcessTomography(qc_ghz) + mitqptdata = mitqptexp.run(backend=backend, shots=1000, seed_simulator=100).block_for_results() + mitigated_choi_out = mitqptdata.analysis_results("state").value + + # extracting a densitymatrix from mitigated_choi_out + from qiskit.visualization import plot_state_city + import qiskit.quantum_info as qinfo + + _rho_exp_00 = np.array([[None, None, None, None], + [None, None, None, None], + [None, None, None, None], + [None, None, None, None]]) + + for i in range(4): + for j in range(4): + _rho_exp_00[i][j] = mitigated_choi_out.data[i][j] + + mitigated_rho_exp_00 = qinfo.DensityMatrix(_rho_exp_00) + display(plot_state_city(mitigated_rho_exp_00, title="mitigated Density Matrix")) """ def __init__( From fea22e902006c5fbd88286944ee7390802f1a33b Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Tue, 29 Oct 2024 04:53:52 +0900 Subject: [PATCH 15/22] Update mit_qpt_experiment.py update MitigatedProcessTomography --- qiskit_experiments/library/tomography/mit_qpt_experiment.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit_experiments/library/tomography/mit_qpt_experiment.py b/qiskit_experiments/library/tomography/mit_qpt_experiment.py index 0d31d79c06..4c8825a930 100644 --- a/qiskit_experiments/library/tomography/mit_qpt_experiment.py +++ b/qiskit_experiments/library/tomography/mit_qpt_experiment.py @@ -60,7 +60,7 @@ class MitigatedProcessTomography(BatchExperiment): backend = AerSimulator.from_backend(FakePerth()) - ..jupyter-execute:: + .. jupyter-execute:: import numpy as np from qiskit import QuantumCircuit From a252cc83e42a412f08d15b08df7980fcae8d10c6 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Tue, 29 Oct 2024 05:52:36 +0900 Subject: [PATCH 16/22] Update qv_experiment.py update QuantumVolume --- .../library/quantum_volume/qv_experiment.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/quantum_volume/qv_experiment.py b/qiskit_experiments/library/quantum_volume/qv_experiment.py index 5d64b37377..694ad2fe03 100644 --- a/qiskit_experiments/library/quantum_volume/qv_experiment.py +++ b/qiskit_experiments/library/quantum_volume/qv_experiment.py @@ -28,7 +28,7 @@ class QuantumVolume(BaseExperiment): - """An experiment to measure the largest random square circuit that can be run on a processor. + r"""An experiment to measure the largest random square circuit that can be run on a processor. # section: overview Quantum Volume (QV) is a single-number metric that can be measured using a concrete protocol @@ -66,6 +66,31 @@ class QuantumVolume(BaseExperiment): .. ref_arxiv:: 1 1811.12926 .. ref_arxiv:: 2 2008.08571 + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_aer import AerSimulator + from qiskit_ibm_runtime.fake_provider import FakeSydneyV2 + backend = AerSimulator.from_backend(FakeSydneyV2()) + + .. jupyter-execute:: + + from qiskit_experiments.framework import BatchExperiment + from qiskit_experiments.library import QuantumVolume + + qubits = tuple(range(4)) # Can use specific qubits. for example [2, 4, 7, 10] + qv_exp = QuantumVolume(qubits, seed=42) + qv_exp.set_transpile_options(optimization_level=3) + qv_exp.set_run_options(shots=1000) + + expdata = qv_exp.run(backend).block_for_results() + + display(expdata.figure(0)) + + for result in expdata.analysis_results(): + print(result) """ def __init__( From 2fc0ee3ee764315d546030d53b4a2345458010ec Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Tue, 29 Oct 2024 09:17:27 +0900 Subject: [PATCH 17/22] Update standard_rb.py update StandardRB --- .../randomized_benchmarking/standard_rb.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/qiskit_experiments/library/randomized_benchmarking/standard_rb.py b/qiskit_experiments/library/randomized_benchmarking/standard_rb.py index 43c77bb8c1..1ab7b71350 100644 --- a/qiskit_experiments/library/randomized_benchmarking/standard_rb.py +++ b/qiskit_experiments/library/randomized_benchmarking/standard_rb.py @@ -84,6 +84,51 @@ class StandardRB(BaseExperiment, RestlessMixin): # section: reference .. ref_arxiv:: 1 1009.3639 .. ref_arxiv:: 2 1109.6887 + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_aer import AerSimulator + from qiskit_ibm_runtime.fake_provider import FakePerth + + backend = AerSimulator.from_backend(FakePerth()) + print(backend.coupling_map) + + .. jupyter-execute:: + + import numpy as np + from qiskit_experiments.library import StandardRB, InterleavedRB + from qiskit_experiments.framework import ParallelExperiment, BatchExperiment + import qiskit.circuit.library as circuits + + lengths_2_qubit = np.arange(1, 200, 30) + lengths_1_qubit = np.arange(1, 800, 200) + num_samples = 10 + seed = 1010 + qubits = (1, 2) + + # Run a 1-qubit RB experiment on qubits 1, 2 to determine the error-per-gate of 1-qubit gates + single_exps = BatchExperiment( + [ + StandardRB((qubit,), lengths_1_qubit, num_samples=num_samples, seed=seed) + for qubit in qubits + ] + ) + expdata_1q = single_exps.run(backend).block_for_results() + + exp_2q = StandardRB(qubits, lengths_2_qubit, num_samples=num_samples, seed=seed) + + # Use the EPG data of the 1-qubit runs to ensure correct 2-qubit EPG computation + exp_2q.analysis.set_options(epg_1_qubit=expdata_1q.analysis_results()) + + expdata_2q = exp_2q.run(backend).block_for_results() + + print("Gate error ratio: %s" % expdata_2q.experiment.analysis.options.gate_error_ratio) + display(expdata_2q.figure(0)) + for result in expdata_2q.analysis_results(): + print(result) """ def __init__( From b4a81fe6c64d9731e9ecbece522fe19932d71ba4 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Tue, 29 Oct 2024 09:18:12 +0900 Subject: [PATCH 18/22] Update standard_rb.py update StandardRB --- .../library/randomized_benchmarking/standard_rb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qiskit_experiments/library/randomized_benchmarking/standard_rb.py b/qiskit_experiments/library/randomized_benchmarking/standard_rb.py index 1ab7b71350..6a6855bafe 100644 --- a/qiskit_experiments/library/randomized_benchmarking/standard_rb.py +++ b/qiskit_experiments/library/randomized_benchmarking/standard_rb.py @@ -54,7 +54,7 @@ class StandardRB(BaseExperiment, RestlessMixin): - """An experiment to characterize the error rate of a gate set on a device. + r"""An experiment to characterize the error rate of a gate set on a device. # section: overview From 8d41d011dd1731ffacbeb1428c6a0ec714157025 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Tue, 29 Oct 2024 09:24:25 +0900 Subject: [PATCH 19/22] Update interleaved_rb_experiment.py update InterleavedRB --- .../interleaved_rb_experiment.py | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/qiskit_experiments/library/randomized_benchmarking/interleaved_rb_experiment.py b/qiskit_experiments/library/randomized_benchmarking/interleaved_rb_experiment.py index 114f23b8a5..9d77725a4f 100644 --- a/qiskit_experiments/library/randomized_benchmarking/interleaved_rb_experiment.py +++ b/qiskit_experiments/library/randomized_benchmarking/interleaved_rb_experiment.py @@ -32,7 +32,7 @@ class InterleavedRB(StandardRB): - """An experiment to characterize the error rate of a specific gate on a device. + r"""An experiment to characterize the error rate of a specific gate on a device. # section: overview Interleaved Randomized Benchmarking (RB) is a method @@ -53,6 +53,37 @@ class InterleavedRB(StandardRB): # section: reference .. ref_arxiv:: 1 1203.4550 + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_aer import AerSimulator + from qiskit_ibm_runtime.fake_provider import FakePerth + + backend = AerSimulator.from_backend(FakePerth()) + + .. jupyter-execute:: + + import numpy as np + from qiskit_experiments.library import StandardRB, InterleavedRB + from qiskit_experiments.framework import ParallelExperiment, BatchExperiment + import qiskit.circuit.library as circuits + + lengths = np.arange(1, 200, 30) + num_samples = 10 + seed = 1010 + qubits = (1, 2) + + int_exp2 = InterleavedRB( + circuits.CXGate(), qubits, lengths, num_samples=num_samples, seed=seed) + + int_expdata2 = int_exp2.run(backend).block_for_results() + int_results2 = int_expdata2.analysis_results() + + display(int_expdata2.figure(0)) + for result in int_results2: + print(result) """ def __init__( From 8faa9e8559d3923ef4f02d32ecf1d3805d671fb3 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Tue, 29 Oct 2024 09:34:33 +0900 Subject: [PATCH 20/22] Update layer_fidelity.py update LayerFidelity --- .../randomized_benchmarking/layer_fidelity.py | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/qiskit_experiments/library/randomized_benchmarking/layer_fidelity.py b/qiskit_experiments/library/randomized_benchmarking/layer_fidelity.py index 40c5247f87..5c36822304 100644 --- a/qiskit_experiments/library/randomized_benchmarking/layer_fidelity.py +++ b/qiskit_experiments/library/randomized_benchmarking/layer_fidelity.py @@ -76,6 +76,52 @@ class LayerFidelity(BaseExperiment, RestlessMixin): # section: reference .. ref_arxiv:: 1 2311.05933 + + # section: example + .. jupyter-execute:: + :hide-code: + + # backend + from qiskit_aer import AerSimulator + from qiskit_ibm_runtime.fake_provider import FakePerth + backend = AerSimulator.from_backend(FakePerth()) + + print(backend.coupling_map) + + .. jupyter-execute:: + + import numpy as np + from qiskit_experiments.library import StandardRB + from qiskit_experiments.library.randomized_benchmarking import LayerFidelity + + lengths = np.arange(1, 800, 200) + two_qubit_layers=[[(0, 1), (3, 5)], [(1, 3), (5, 6)]] + + for qpair in two_qubit_layers: + for qpair_ in backend.coupling_map: + if qpair_ == qpair: + pass + + num_samples = 6 + seed = 1010 + + exp = LayerFidelity( + physical_qubits=[0, 1, 3, 5, 6], + two_qubit_layers=two_qubit_layers, + lengths=lengths, + backend=backend, + num_samples=num_samples, + seed=seed, + two_qubit_gate=None, + one_qubit_basis_gates=None, + ) + + exp.set_run_options(shots=5000) + expdata = exp.run().block_for_results() + results = expdata.analysis_results() + + for i in range(4): + display(expdata.figure(i)) """ def __init__( From ccfd09b438ceadbe5a170e6df8ffb334fe8b9c8f Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:37:51 +0900 Subject: [PATCH 21/22] Update rabi.py update EFRabi --- .../library/characterization/rabi.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/qiskit_experiments/library/characterization/rabi.py b/qiskit_experiments/library/characterization/rabi.py index 7306ce23f5..cdf26e8c40 100644 --- a/qiskit_experiments/library/characterization/rabi.py +++ b/qiskit_experiments/library/characterization/rabi.py @@ -256,8 +256,8 @@ class EFRabi(Rabi): ) # backend - from qiskit_experiments.test.pulse_backend import SingleTransmonTestBackend - backend = SingleTransmonTestBackend(5.2e9, -0.25e9, 1e9, 0.8e9, 1e4, noise=True, seed=198) + from qiskit_experiments.test import SingleTransmonTestBackend + backend = SingleTransmonTestBackend(5e9, -0.25e9, 1e9, 0.8e9, 1e4, noise=True) .. jupyter-execute:: @@ -267,12 +267,16 @@ class EFRabi(Rabi): from qiskit_experiments.library import EFRabi with pulse.build() as build_sched: - pulse.play(pulse.Gaussian(160, Parameter("amp"), sigma=40), pulse.DriveChannel(0)) + with pulse.align_left(): + pulse.shift_frequency(-0.25e9, pulse.DriveChannel(0)) + pulse.play(pulse.Gaussian(160, Parameter("amp"), 40), pulse.DriveChannel(0)) exp = EFRabi(physical_qubits=(0,), - backend=backend, schedule=build_sched, - amplitudes=np.linspace(-0.1, 0.1, 21),) + amplitudes=np.linspace(-0.1, 0.1, 21), + backend=backend,) + + display(exp.circuits()[1].draw()) exp_data = exp.run().block_for_results() display(exp_data.figure(0)) From a2648597843a365eb2665aceac6244ee5feb7686 Mon Sep 17 00:00:00 2001 From: Naohito Nakazawa <117684192+Naohnakazawa@users.noreply.github.com> Date: Tue, 29 Oct 2024 10:42:55 +0900 Subject: [PATCH 22/22] Update ef_spectroscopy.py update EFSpectroscopy --- .../library/characterization/ef_spectroscopy.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/qiskit_experiments/library/characterization/ef_spectroscopy.py b/qiskit_experiments/library/characterization/ef_spectroscopy.py index 0b28c6636f..51107e47cb 100644 --- a/qiskit_experiments/library/characterization/ef_spectroscopy.py +++ b/qiskit_experiments/library/characterization/ef_spectroscopy.py @@ -22,7 +22,7 @@ class EFSpectroscopy(QubitSpectroscopy): - """A spectroscopy experiment to obtain a frequency sweep of the qubit's e-f transition. + r"""A spectroscopy experiment to obtain a frequency sweep of the qubit's e-f transition. # section: overview The circuits produced by spectroscopy, i.e. @@ -49,12 +49,15 @@ class EFSpectroscopy(QubitSpectroscopy): qubit = 0 freq01_estimate = backend.defaults().qubit_freq_est[qubit] - frequencies = np.linspace(freq01_estimate-15e6, freq01_estimate+15e6, 51) - - exp = EFSpectroscopy(physical_qubits = (0,), - frequencies = frequencies, - backend = backend, - ) + freq12_estimate = freq01_estimate + (-.25e9) + frequencies = np.linspace(freq12_estimate-15e6, freq12_estimate+15e6, 51) + + exp = EFSpectroscopy( + physical_qubits = (0,), + frequencies = frequencies, + backend = backend, + absolute = True, + ) exp.set_experiment_options(amp=0.005) exp_data = exp.run().block_for_results()