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-draft2

update local2/issue-#1238-draft2 with origin/issue-#1238-draft
  • Loading branch information
Naohnakazawa committed Nov 14, 2024
2 parents 6c86cee + 95e8d3f commit b685974
Show file tree
Hide file tree
Showing 22 changed files with 949 additions and 33 deletions.
100 changes: 98 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})
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,7 +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,
Expand Down Expand Up @@ -204,7 +269,38 @@ 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::
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
97 changes: 94 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::
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,37 @@ 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::
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))
cal_data.analysis_results(dataframe=True)
"""

def __init__(
self,
Expand Down Expand Up @@ -178,7 +239,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::
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
27 changes: 26 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,32 @@


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
27 changes: 26 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,32 @@


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
36 changes: 35 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,41 @@


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 b685974

Please sign in to comment.