Skip to content

Commit

Permalink
Merge branch 'issue-qiskit-community#1238-draft' of github.com:Naohna…
Browse files Browse the repository at this point in the history
…kazawa/qiskit-experiments into issue-qiskit-community#1238-draft

update local/qiskit-#1238-draft
  • Loading branch information
Naohnakazawa committed Oct 29, 2024
2 parents 78e7f54 + a264859 commit ca04ade
Show file tree
Hide file tree
Showing 19 changed files with 838 additions and 33 deletions.
102 changes: 100 additions & 2 deletions qiskit_experiments/library/calibration/fine_amplitude.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__(
Expand Down Expand Up @@ -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],
Expand Down Expand Up @@ -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,
Expand Down
104 changes: 101 additions & 3 deletions qiskit_experiments/library/calibration/fine_drag_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
26 changes: 25 additions & 1 deletion qiskit_experiments/library/calibration/fine_frequency_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 25 additions & 1 deletion qiskit_experiments/library/calibration/frequency_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
35 changes: 34 additions & 1 deletion qiskit_experiments/library/calibration/half_angle_cal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit ca04ade

Please sign in to comment.