Deprecated code suggestions#
See also
Download the notebook: deprecated.ipynb
Target |
Depr |
Remv |
Alternatives |
---|---|---|---|
|
0.20.1 |
0.23 |
|
|
0.20.1 |
0.23 |
|
|
0.17 |
0.18 |
|
|
0.15 |
- |
See plot_kwargs parameter in ScheduleBase.plot_pulse_diagram() |
|
0.15 |
0.18 |
See repetitions parameter in ScheduleGettable.process_acquired_data() |
|
0.13 |
0.18 |
|
Qblox |
0.13 |
0.18 |
|
Qblox |
0.13 |
0.17 |
|
|
0.12 |
0.15 |
|
0.10 |
0.13 |
See acq_channel |
|
|
0.10 |
0.13 |
|
The |
0.9 |
0.15 |
- |
Old Qblox hardware configuration |
0.8 |
0.13 |
|
|
0.7 |
0.13 |
|
|
0.6 |
0.13 |
See add_pulse_information_transmon() => compile_circuit_to_device() |
|
0.6 |
0.9 |
|
|
0.6 |
0.9 |
As of quantify-scheduler==0.10.0
, deprecation warnings are shown by default (as FutureWarning
).
Compilation Setup#
Set up an InstrumentCoordinator, MeasurementControl and a Cluster
from quantify_core.data import handling as dh
from quantify_core.measurement.control import MeasurementControl
from quantify_scheduler.instrument_coordinator import InstrumentCoordinator
from quantify_scheduler.instrument_coordinator.components.qblox import ClusterComponent
from qblox_instruments import Cluster, ClusterType
from qcodes import Instrument
dh.set_datadir(dh.default_datadir())
Instrument.close_all()
meas_ctrl = MeasurementControl("meas_ctrl")
ic = InstrumentCoordinator("ic")
cluster = Cluster(
"cluster",
dummy_cfg={
1: ClusterType.CLUSTER_QRM_RF,
},
)
ic_cluster = ClusterComponent(cluster)
ic.add_component(ic_cluster)
# Always picks the first module of a certain type, and ignores the others of same type!
qcm_rf, qrm_rf, qcm, qrm = [None] * 4
for module in cluster.modules:
try:
if module.is_rf_type:
if module.is_qcm_type:
if qcm_rf is None:
qcm_rf = module
else:
if qrm_rf is None:
qrm_rf = module
else:
if module.is_qcm_type:
if qcm is None:
qcm = module
else:
if qrm is None:
qrm = module
except KeyError:
continue
print(f"qcm => {qcm}\nqrm => {qrm}\nqcm_rf => {qcm_rf}\nqrm_rf => {qrm_rf}")
Data will be saved in:
/root/quantify-data
qcm => None
qrm => None
qcm_rf => None
qrm_rf => <Module: cluster_module1 of Cluster: cluster>
Set up a QuantumDevice with one BasicTransmonElement
from quantify_scheduler.device_under_test.quantum_device import QuantumDevice
from quantify_scheduler.device_under_test.transmon_element import BasicTransmonElement
q0 = BasicTransmonElement("q0")
quantum_device = QuantumDevice("quantum_device")
quantum_device.add_element(q0)
quantum_device.instr_measurement_control(meas_ctrl.name)
quantum_device.instr_instrument_coordinator(ic.name)
q0.clock_freqs.f01(7.3e9)
q0.clock_freqs.f12(7.0e9)
q0.clock_freqs.readout(8.2e9)
q0.measure.acq_delay(100e-9)
q0.measure.acq_channel(0)
q0.measure.pulse_amp(0.2)
device_cfg = quantum_device.generate_device_config()
Provide the hardware configuration
hardware_cfg = {
"backend": "quantify_scheduler.backends.qblox_backend.hardware_compile",
"cluster": {
"ref": "internal",
"instrument_type": "Cluster",
f"cluster_module{qrm_rf.slot_idx}": {
"instrument_type": "QRM_RF",
"complex_output_0": {
"lo_freq": 2e9,
"portclock_configs": [
{
"port": "q0:mw",
"clock": "q0.01",
},
{
"port": "q0:res",
"clock": "q0.ro",
},
],
},
},
},
}
Define a simple schedule function
from quantify_scheduler import Schedule
from quantify_scheduler.operations.gate_library import Measure, Reset
from quantify_scheduler.operations.pulse_library import DRAGPulse
from quantify_scheduler.resources import ClockResource
def simple_trace_sched(
repetitions: int,
pulse_amp: float = 0.2,
) -> Schedule:
sched = Schedule("Simple trace schedule", repetitions)
port = "q0:res"
clock = "q0.ro"
sched.add(Reset("q0"))
sched.add(Measure("q0", acq_index=0, acq_protocol="Trace"))
sched.add(
DRAGPulse(
G_amp=pulse_amp,
D_amp=0,
phase=0,
duration=160e-9,
port=port,
clock=clock,
)
)
return sched
sched = simple_trace_sched(repetitions=1)
New control flow interface#
This is an example for the loop control flow. For other control flow types, please use the respective operation classes in the same way.
# Old way:
from quantify_scheduler.operations.control_flow_library import Loop
schedule_with_loop = Schedule("Schedule with loop")
subschedule = Schedule("Subschedule")
subschedule.add(X("q0"))
schedule_with_loop.add(subschedule, control_flow=Loop(3))
# New way:
from quantify_scheduler.operations.control_flow_library import LoopOperation
from quantify_scheduler.operations.gate_library import X
schedule_with_loop = Schedule("Schedule with loop")
subschedule = Schedule("Subschedule")
subschedule.add(X("q0"))
loop_operation = LoopOperation(body=subschedule, repetitions=3)
schedule_with_loop.add(loop_operation)
DistortionCorrection => SoftwareDistortionCorrection#
To prepare for distortion corrections performed by hardware, distortion corrections will now come in two flavors: SoftwareDistortionCorrection
and HardwareDistortionCorrection
.
In the hardware configuration, the following needs to be replaced:
hardware_configuration = {
...
hardware_options : {
...
distortion_corrections = {
- "q0:fl-cl0.baseband": DistortionCorrection(
+ "q0:fl-cl0.baseband": SoftwareDistortionCorrection(
filter_func="scipy.signal.lfilter",
input_var_name="x",
kwargs={
"b": [0, 0.25, 0.5],
"a": [1]
},
clipping_values=[-2.5, 2.5]
)
}
}
}
qcompile() => SerialCompiler#
The qcompile()
, device_compile()
and hardware_compile()
compilation functions have been replaced by the SerialCompiler
. For step-by-step guides on how to perform compilation to the device level and hardware, please see Compiling to Hardware and Operations and Qubits. A brief example is shown below.
First, run Compilation Setup.
# Old way:
# from quantify_scheduler.compilation import qcompile
# compiled_schedule = qcompile(sched, device_cfg, hardware_cfg)
from quantify_scheduler.backends.graph_compilation import SerialCompiler
quantum_device.hardware_config(hardware_cfg)
compiler = SerialCompiler(name="compiler")
compiled_schedule = compiler.compile(
schedule=sched, config=quantum_device.generate_compilation_config()
)
/usr/local/lib/python3.9/site-packages/quantify_scheduler/backends/qblox/helpers.py:1421: FutureWarning: The hardware configuration dictionary is deprecated and will not be supported in quantify-scheduler >= 1.0.0. Please use a `HardwareCompilationConfig` instead. For more information on how to migrate from old- to new-style hardware specification, please visit https://quantify-os.org/docs/quantify-scheduler/dev/examples/hardware_config_migration.html in the documentation.
warnings.warn(
compiled_schedule.timing_table
waveform_op_id | port | clock | abs_time | duration | is_acquisition | operation | wf_idx | operation_hash | |
---|---|---|---|---|---|---|---|---|---|
0 | Reset('q0')_acq_0 | None | cl0.baseband | 0.0 ns | 200,000.0 ns | False | Reset('q0') | 0 | 1182162100816613305 |
1 | ResetClockPhase(clock='q0.ro',t0=0)_acq_0 | None | q0.ro | 200,000.0 ns | 0.0 ns | False | ResetClockPhase(clock='q0.ro',t0=0) | 0 | -9154256341553766103 |
2 | SquarePulse(amp=0.2,duration=3e-07,port='q0:res',clock='q0.ro',reference_magnitude=None,t0=0)_acq_0 | q0:res | q0.ro | 200,000.0 ns | 300.0 ns | False | SquarePulse(amp=0.2,duration=3e-07,port='q0:res',clock='q0.ro',reference_magnitude=None,t0=0) | 0 | -8296145970981113017 |
3 | Trace(duration=1e-06,port='q0:res',clock='q0.ro',acq_channel=0,acq_index=0,bin_mode='average',t0=1e-07)_acq_0 | q0:res | q0.ro | 200,100.0 ns | 1,000.0 ns | True | Trace(duration=1e-06,port='q0:res',clock='q0.ro',acq_channel=0,acq_index=0,bin_mode='average',t0=1e-07) | 0 | 644093113277042821 |
4 | DRAGPulse(G_amp=0.2,D_amp=0,phase=0,duration=1.6e-07,port='q0:res',clock='q0.ro',reference_magnitude=None,sigma=None,t0=0)_acq_0 | q0:res | q0.ro | 201,100.0 ns | 160.0 ns | False | DRAGPulse(G_amp=0.2,D_amp=0,phase=0,duration=1.6e-07,port='q0:res',clock='q0.ro',reference_magnitude=None,sigma=None,t0=0) | 0 | -8938848356965653937 |
ScheduleGettable.generate_diagnostics_report()#
In version 0.17, the ScheduleGettable.generate_diagnostics_report
method received a major update. This method should no longer be called directly. Instead, the experiment should be run via the ScheduleGettable.initialize_and_get_with_report()
method, which executes the experiment and generates a diagnostics report for debugging.
plot_kwargs parameter in ScheduleBase.plot_pulse_diagram()#
In version 0.15, the plot_kwargs
parameter of the ScheduleBase.plot_pulse_diagram()
method was replaced by variable keyword arguments (**kwargs
). This means that the dictionary provided to plot_kwargs
can be unpacked and passed to the method directly. For example,
schedule.plot_pulse_diagram(plot_kwargs={"x_range": (201e-6, 201.5e-6)})
can now be written as
compiled_schedule.plot_pulse_diagram(x_range=(201e-6, 201.5e-6))
(<Figure size 640x480 with 1 Axes>,
<Axes: title={'center': 'Simple trace schedule'}, xlabel='Time [ns]', ylabel='Amplitude [mV]'>)
repetitions parameter in ScheduleGettable.process_acquired_data()#
In version 0.15, the repetitions
parameter of the ScheduleGettable.process_acquired_data()
method was deprecated. This parameter has no effect, and can simply be omitted. The Repetitions section of Tutorial: ScheduleGettable contains more information on how to set the number of repetitions in an experiment.
t parameter in NumericalWeightedIntegrationComplex#
In version 0.13.0, the t
parameter in the NumericalWeightedIntegrationComplex
initializer was replaced by the weights_sampling_rate
parameter, which takes a sampling rate in Hz.
This means that creating a class instance as
NumericalWeightedIntegrationComplex(
weights_a=[0.1, 0.2, 0.3],
weight_b=[0.4, 0.5, 0.6],
t=[0.0, 1e-9, 2e-9],
port="some_port",
clock="some_clock",
# other args
)
should now be done as
from quantify_scheduler.operations.acquisition_library import NumericalWeightedIntegrationComplex
NumericalWeightedIntegrationComplex(
weights_a=[0.1, 0.2, 0.3],
weights_b=[0.4, 0.5, 0.6],
weights_sampling_rate=1e9,
port="some_port",
clock="some_clock",
# other args
)
/usr/local/lib/python3.9/site-packages/quantify_scheduler/operations/acquisition_library.py:591: FutureWarning: NumericalWeightedIntegrationComplex is deprecated and will be removed in quantify-scheduler>=0.20.0. Use NumericalSeparatedWeightedIntegration instead.
warnings.warn(
NumericalSeparatedWeightedIntegration(weights_a=[0.1, 0.2, 0.3], weights_b=[0.4, 0.5, 0.6], weights_sampling_rate=999999999.9999999, port='some_port', clock='some_clock', interpolation='linear', acq_channel=0, acq_index=0, bin_mode='append', phase=0, t0=0)
Circuit diagrams and pulse diagrams#
The functions to plot circuit and pulse diagrams have moved to a private module in version 0.12.0.
Instead, to plot circuit and pulse diagrams, call, directly on the schedule, plot_circuit_diagram()
and plot_pulse_diagram()
.
For example, the line
pulse_diagram_plotly(schedule)
pulse_diagram_matplotlib(schedule)
should now be written as
compiled_schedule.plot_pulse_diagram(plot_backend="plotly")
compiled_schedule.plot_pulse_diagram(plot_backend="mpl")
(<Figure size 640x480 with 1 Axes>,
<Axes: title={'center': 'Simple trace schedule'}, xlabel='Time [μs]', ylabel='Amplitude [mV]'>)
More examples can be found in the Schedules and Pulses and Operations and Qubits tutorials.
acq_channel#
In the Measure
and CRCount
classes, the acq_channel
parameter has been removed from the initializers. For gate-level operations, the acquisition channel can be set in the DeviceElement
subclasses, such as BasicTransmonElement
, instead. See, for example, q0.measure.acq_channel(0)
in the Compilation Setup.
add_pulse_information_transmon() => compile_circuit_to_device()#
The compilation step add_pulse_information_transmon
has been replaced by compile_circuit_to_device
. For steps on how to add device configuration to your compilation steps, please see Operations and Qubits.
Qblox Hardware Configuration#
In quantify-scheduler 0.8.0, the schema for the Qblox hardware configuration was revised. From version 0.13.0, old hardware configurations will no longer be automatically converted. Below is a summary of the changes.
seqx
=>portclock_configs
latency_correction
=> standalone/top-levellatency_corrections
line_gain_db
removed
Warning
The helper function convert_hw_config_to_portclock_configs_spec
has been removed in version 0.18.0.
depr_hardware_cfg = {
"backend": "quantify_scheduler.backends.qblox_backend.hardware_compile",
"cluster": {
"ref": "internal",
"instrument_type": "Cluster",
"cluster_module1": {
"instrument_type": "QRM_RF",
"complex_output_0": {
"line_gain_db": 0,
"seq0": {
"port": "q6:res",
"clock": "q6.ro",
"latency_correction": 4e-9,
},
"seq1": {
"port": "q1:res",
"clock": "q1.ro",
},
},
},
},
}
correct_hardware_cfg = {
"backend": "quantify_scheduler.backends.qblox_backend.hardware_compile",
"cluster": {
"ref": "internal",
"instrument_type": "Cluster",
"cluster_module1": {
"instrument_type": "QRM_RF",
"complex_output_0": {
"portclock_configs": [
{
"port": "q6:res",
"clock": "q6.ro"
},
{
"port": "q1:res",
"clock": "q1.ro"
}
]
}
}
},
"latency_corrections": {
"q6:res-q6.ro": 4e-09
}
}
TransmonElement => BasicTransmonElement#
In quantify-scheduler 0.7.0, the BasicTransmonElement
class was added and replaced the TransmonElement
class.
Show code cell content
from qcodes import Instrument
Instrument.close_all()
# Before:
# from quantify_scheduler.device_under_test.transmon_element import TransmonElement
# transmon = TransmonElement("transmon")
# print(f"{transmon.name}: {list(transmon.parameters.keys())}")
# After:
from quantify_scheduler.device_under_test.transmon_element import BasicTransmonElement
basic = BasicTransmonElement("basic")
print(f"{basic.name}: {list(basic.parameters.keys()) + list(basic.submodules.keys())}")
for submodule_name, submodule in basic.submodules.items():
print(f"{basic.name}.{submodule_name}: {list(submodule.parameters.keys())}")
basic: ['IDN', 'reset', 'rxy', 'measure', 'ports', 'clock_freqs']
basic.reset: ['duration']
basic.rxy: ['amp180', 'motzoi', 'duration']
basic.measure: ['pulse_type', 'pulse_amp', 'pulse_duration', 'acq_channel', 'acq_delay', 'integration_time', 'reset_clock_phase', 'acq_weights_a', 'acq_weights_b', 'acq_weights_sampling_rate', 'acq_weight_type', 'acq_rotation', 'acq_threshold', 'num_points']
basic.ports: ['microwave', 'flux', 'readout']
basic.clock_freqs: ['f01', 'f12', 'readout']
The block below shows how the attributes of the TransmonElement
(transmon
) are converted to attributes of the BasicTransmonElement
(basic
).
transmon.IDN => basic.IDN
transmon.instrument_coordinator => None
transmon.init_duration => basic.reset.duration
transmon.mw_amp180 => basic.rxy.amp180
transmon.mw_motzoi => basic.rxy.motzoi
transmon.mw_pulse_duration => basic.rxy.duration
transmon.mw_ef_amp180 => None
transmon.mw_port => basic.ports.microwave
transmon.fl_port => basic.ports.flux
transmon.ro_port => basic.ports.readout
transmon.mw_01_clock => no longer settable, always "basic.01"
transmon.mw_12_clock => no longer settable, always "basic.12"
transmon.ro_clock => no longer settable, always "basic.ro"
transmon.freq_01 => basic.clock_freqs.f01
transmon.freq_12 => basic.clock_freqs.f12
transmon.ro_freq => basic.clock_freqs.readout
transmon.ro_pulse_amp => basic.measure.pulse_amp
transmon.ro_pulse_duration => basic.measure.pulse_duration
transmon.ro_pulse_type => basic.measure.pulse_type
transmon.ro_pulse_delay => via: schedule.add(..., rel_time=...)
transmon.ro_acq_channel => basic.measure.acq_channel
transmon.ro_acq_delay => basic.measure.acq_delay
transmon.ro_acq_integration_time => basic.measure.integration_time
transmon.spec_pulse_duration => via: schedule.add(SpectroscopyOperation("basic")), not implemented for BasicTransmonElement, see BasicElectronicNVElement.spectroscopy_operation
transmon.spec_pulse_frequency => via: schedule.add(SpectroscopyOperation("basic")), not implemented for BasicTransmonElement, see BasicElectronicNVElement.spectroscopy_operation
transmon.spec_pulse_amp => via: schedule.add(SpectroscopyOperation("basic")), not implemented for BasicTransmonElement, see BasicElectronicNVElement.spectroscopy_operation
transmon.spec_pulse_clock => via: schedule.add(SpectroscopyOperation("basic")), not implemented for BasicTransmonElement, see BasicElectronicNVElement.spectroscopy_operation
transmon.acquisition => via: schedule.add(Measure("basic", acq_protocol=...))
transmon.ro_acq_weight_type => basic.measure.acq_weight_type
schedule.add(Measure("transmon", acq_channel=...)) => basic.measure.acq_channel
Both classes will generate the same device configuration.
import pprint
# device_config_transmon = transmon.generate_device_config().model_dump()
# pprint.pprint(device_config_transmon)
device_config_basic_transmon = basic.generate_device_config().model_dump()
pprint.pprint(device_config_basic_transmon)
{'clocks': {'basic.01': nan, 'basic.12': nan, 'basic.ro': nan},
'compilation_passes': [{'compilation_func': 'quantify_scheduler.backends.circuit_to_device.compile_circuit_to_device_with_config_validation',
'name': 'circuit_to_device'},
{'compilation_func': 'quantify_scheduler.backends.circuit_to_device.set_pulse_and_acquisition_clock',
'name': 'set_pulse_and_acquisition_clock'},
{'compilation_func': 'quantify_scheduler.compilation._determine_absolute_timing',
'name': 'determine_absolute_timing'}],
'edges': {},
'elements': {'basic': {'H': {'factory_func': 'quantify_scheduler.operations.composite_factories.hadamard_as_y90z',
'factory_kwargs': {'qubit': 'basic'},
'gate_info_factory_kwargs': None},
'Rxy': {'factory_func': 'quantify_scheduler.operations.pulse_factories.rxy_drag_pulse',
'factory_kwargs': {'amp180': nan,
'clock': 'basic.01',
'duration': 2e-08,
'motzoi': 0,
'port': 'basic:mw',
'reference_magnitude': None},
'gate_info_factory_kwargs': ['theta', 'phi']},
'Rz': {'factory_func': 'quantify_scheduler.operations.pulse_factories.phase_shift',
'factory_kwargs': {'clock': 'basic.01'},
'gate_info_factory_kwargs': ['theta']},
'measure': {'factory_func': 'quantify_scheduler.operations.measurement_factories.dispersive_measurement_transmon',
'factory_kwargs': {'acq_channel': 0,
'acq_delay': 0,
'acq_duration': 1e-06,
'acq_protocol_default': 'SSBIntegrationComplex',
'acq_rotation': 0,
'acq_threshold': 0,
'acq_weights_a': array([], dtype=float64),
'acq_weights_b': array([], dtype=float64),
'acq_weights_sampling_rate': None,
'clock': 'basic.ro',
'freq': None,
'num_points': None,
'port': 'basic:res',
'pulse_amp': 0.25,
'pulse_duration': 3e-07,
'pulse_type': 'SquarePulse',
'reference_magnitude': None,
'reset_clock_phase': True},
'gate_info_factory_kwargs': ['acq_channel_override',
'acq_index',
'bin_mode',
'acq_protocol',
'feedback_trigger_label']},
'reset': {'factory_func': 'quantify_scheduler.operations.pulse_library.IdlePulse',
'factory_kwargs': {'duration': 0.0002},
'gate_info_factory_kwargs': None}}},
'scheduling_strategy': 'asap'}
Instruction-generated pulses (Qblox only)#
Instead of using the instruction_generated_pulses_enabled: True
field in the port-clock configuration for generating long square and staircase pulses, you can now create long square, staircase and ramp waveforms (that would otherwise not fit in memory), by creating these operations with the following helper functions.
from quantify_scheduler.backends.qblox.operations import (
long_ramp_pulse,
long_square_pulse,
staircase_pulse,
)
ramp_pulse = long_ramp_pulse(amp=0.5, duration=1e-3, port="q0:mw")
square_pulse = long_square_pulse(amp=0.5, duration=1e-3, port="q0:mw")
staircase_pulse = staircase_pulse(
start_amp=0.0, final_amp=1.0, num_steps=20, duration=1e-4, port="q0:mw"
)
More complex long waveforms can now also be created, see section Long waveform support.