Experiments
The experiments
subpackage includes convenience classes to implement common quantum
protocols.
A class enabling convenient execution of programs on hardware and analysis of the results. |
|
A class enabling the calibration of an operation specified in the calibration set. |
|
Initializes a Cross Resonance pulse calibration experiment. |
|
Initializes an experiment to determine the dispersive shift of the resonant frequencies of the readout resonators associated with qubits. |
|
A class representing a dynamical decoupling experiment on single qubits. |
|
Initializes a Hahn echo experiment to characterize the decoherence time of the system. |
|
Initializes an Error Amplification experiment, which consists of a sequence of pairs of X gates, with varying amplitude between sweeps. |
|
A class enabling convenient execution of programs on hardware and analysis of the results. |
|
Initializes an IQ Distribution experiment to measure the ground and excited states by preparing each in turn. |
|
Initializes a qubit spectroscopy experiment to measure the resonant frequencies of qubits. |
|
Initializes a Rabi experiment to measure the Rabi oscillations between ground and excited state populations by varying the amplitude of the drive signal. |
|
Initializes a Ramsey experiment to measure the relaxation time of a qubit. |
|
Initializes an experiment to measure the resonant frequencies of the readout cavities associated with qubits. |
|
Initializes an experiment to measure the resonant frequencies of the readout resonators associated with qubits while varying the amplitude of the readout pulse. |
|
Initializes an experiment to measure the relaxation time of a qubit system. |
|
Returns a CalibrationSet that is compatible with pre-defined Experiments. |
Experiments
- class keysight.qcs.experiments.BaseExperiment(backend: keysight.qcs.channels.channel_mapper.ChannelMapper | keysight.qcs.executor.hcl_backend.HclBackend | pathlib.Path | str, calibration_set: keysight.qcs.programs.calibration.CalibrationSet | pathlib.Path | str, name: Optional[str] = None, save_path: Optional[Union[str, Path]] = None)
Bases:
Serializable
A class enabling convenient execution of programs on hardware and analysis of the results.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
name – The name of the experiment.
save_path – The path to save the experiment to.
- property backend: HclBackend
The backend to run the experiment on.
- property calibration_set: CalibrationSet
The calibration of the system.
- property history: list[str]
A list of the time stamps at which the experiment has been run.
- property name: str
Name of the experiment.
- property save_path: pathlib.Path | None
The folder experiments are saved in.
- class keysight.qcs.experiments.CalibrationExperiment(backend: keysight.qcs.channels.channel_mapper.ChannelMapper | keysight.qcs.executor.hcl_backend.HclBackend | pathlib.Path | str, calibration_set: keysight.qcs.programs.calibration.CalibrationSet | pathlib.Path | str, qudits: keysight.qcs.quantum.qudits.Qudits | keysight.qcs.quantum.qudits.MultiQudits, program: Program, operation: str, fitter: Optional[BaseFitter] = None, pre_processor: Optional[Preprocessor] = None, name: Optional[str] = None, save_path: Optional[Union[str, Path]] = None)
Bases:
Experiment
A class enabling the calibration of an operation specified in the calibration set.
In addition to sweeping variables on the program, this class allows for and handles sweeping and indexing variables contained on the
ParameterizedLinker
for the given operation.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qudits – A subset of the calibration_set’s targets to calibrate the operation on.
program – The program to run.
operation – The operation to calibrate, specified as a string. A linker with the same name must exist in the calibration_set to compile this operation.
fitter – The fitter to fit the experimental data to.
pre_processor – A
Preprocessor
to apply to the data before fitting.name – The name of the experiment.
save_path – The path to save the experiment to.
- Raises:
ValueError – If the specified operation does not exist in the calibration_set.
- property idx: int | list[int]
The index of the targets in this experiment.
- property linker: BaseLinker
The linker to calibrate.
- get_updated_calibration_values(timestamp: Optional[Union[str, int]] = None) dict[str, float | collections.abc.Iterable[float]]
Calculates the new values for the calibration variable(s) of this experiment.
- Parameters:
timestamp – The timestamp of the program to use in fitting. By default, fits the most recent program.
- set_updated_calibration_values(values: Optional[dict[str, float | collections.abc.Iterable[float]]] = None, timestamp: Optional[Union[str, int]] = None)
Update the calibration set with new values.
- Parameters:
values – The new values to update the calibration set with. The dictionary keys need to match the names of actual variables in the calibration set, and the idx attribute of this class determines which values get updated.
- class keysight.qcs.experiments.CrossResonance(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits | MultiQudits, cr_amplitudes: Iterable[float] | Array[float] | np.ndarray | None = None, fitter: None = None, n_shots: int = 100, operation: str = 'CR', cr_amplitude_name: str = 'cr_gate_amplitude', name: str | None = 'CrossResonance', save_path: str | Path | None = None)
Bases:
CalibrationExperiment
Initializes a Cross Resonance pulse calibration experiment.
This experiment measures Rabi oscillations in the target qubits by varying the amplitude of the drive signal applied to the control qubits.
The program consists of two scenarios:
1. An X gate is applied to the control qubits before the Cross Resonance pulse, initializing them in the excited state.
2. No gate is applied before the Cross Resonance pulse, leaving the control qubits in the ground state.
In both scenarios, the amplitude of the Cross Resonance pulse is swept. A measurement is performed afterwards to observe how the Rabi oscillation frequencies of the target qubits differ depending on whether the control qubits were initialized with an X gate.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
cr_amplitudes – The amplitudes to sweep the Cross Resonance pulse over.
fitter – The fitter model for post-processing.
n_shots – The number of times to repeat the program.
cr_amplitude_name – The name of the Cross Resonance pulse amplitude variable on linker to sweep.
name – The name of the experiment.
save_path – The path to save the experiment to.
- configure_repetitions(cr_amplitudes: Iterable[float] | Array[float] | np.ndarray, n_shots: int = 100, hw_sweep: bool = False, cr_amplitude_name: str = 'cr_gate_amplitude')
Configures the repetitions of this experiment.
- Parameters:
cr_amplitudes – The amplitudes to sweep over for the CR pulse.
amplitudes – The amplitude variable of the applied X gate.
n_shots – The number of times to repeat the program.
hw_sweep – Whether to perform the sweep on hardware.
cr_amplitude_name – The name of the amplitude variable on the linker to sweep.
- class keysight.qcs.experiments.DispersiveShift(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits, frequencies: Iterable[float] | Array[float] | np.ndarray | None = None, fitter: BaseFitter | None = None, n_shots: int = 500, frequency_name: str = 'readout_frequencies', name: str | None = 'DispersiveShift', save_path: str | Path | None = None)
Bases:
Experiment
Initializes an experiment to determine the dispersive shift of the resonant frequencies of the readout resonators associated with qubits.
The program in this experiment consists of two scenarios. Either an X gate is applied to initialize the qubit in the excited state, shifting the readout resonator frequency, or no pulse is applied. In both cases a measurement is applied subsequently with varying readout frequency to perform a spectroscopy.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
frequencies – The frequencies to sweep over.
n_shots – The number of times to repeat the program.
fitter – The fitter model for post-processing.
frequency_name – The name of the frequency variable on linker to sweep.
name – The name of the experiment.
save_path – The path to save the experiment to.
- configure_repetitions(x_amplitudes: Array[float], frequencies: Iterable[float] | Array[float] | np.ndarray, n_shots: int = 100, hw_sweep: int = 1, frequency_name: str = 'readout_frequencies')
Configures the repetitions of this experiment.
- Parameters:
frequencies – The frequencies to sweep over.
x_amplitudes – The amplitude of the applied X gate.
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode.
frequency_name – The name of the frequency variable on the measurement linker to sweep.
- class keysight.qcs.experiments.DynamicalDecouplingExperiment(backend: keysight.qcs.channels.channel_mapper.ChannelMapper | keysight.qcs.executor.hcl_backend.HclBackend | pathlib.Path | str, calibration_set: keysight.qcs.programs.calibration.CalibrationSet | pathlib.Path | str, qubits: Qudits, total_duration: float | keysight.qcs.variables.variable.Variable, sequence_type: SequenceType = SequenceType.CPMG, number_of_pulses: Optional[int] = None, pulse_interval: Optional[Union[float, Variable]] = None, pulse_operation: keysight.qcs.operations.base_operation.BaseOperation | collections.abc.Iterable[keysight.qcs.operations.base_operation.BaseOperation] = Gate(matrix=[[0j, 1 + 0j], [1 + 0j, 0j]], name=X), enforce_even_pulse_number: bool = True, n_shots: int = 100, name: str = 'DecouplingExperiment', save_path: Optional[Union[str, Path]] = None)
Bases:
Experiment
A class representing a dynamical decoupling experiment on single qubits.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
total_duration – The total duration of the decoupling sequence in seconds.
sequence_type – The type of dynamical decoupling sequence to use.
number_of_pulses – The number of pulses to insert into the sequence if applicable. Note that only even numbers of pulses will result in preservation of the original qubit state.
pulse_interval – The delay in seconds to insert between pulses.
pulse_operation – Which operations to perform as decoupling pulses.
n_shots – The number of times to repeat the program.
name – The name of the experiment. Defaults to
DecouplingExperiment
.save_path – The path to save the experiment to.
- Qubits:
The qubits to perform the experiment on.
- class keysight.qcs.experiments.EchoExperiment(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits, delays: Iterable[float] | Array[float] | np.ndarray | None = None, n_shots: int = 500, fitter: BaseFitter | None = <keysight.qcs.analysis.fitter.Exponential object>, name: str | None = 'EchoExperiment', save_path: str | Path | None = None)
Bases:
Experiment
Initializes a Hahn echo experiment to characterize the decoherence time of the system.
The program in this experiment consists of three pulses spaced out equally by a variable delay time. The first X90 gate initializes the system in the equator of the Bloch sphere, where it starts dephasing. An X gate is applied in order to refocus the system back to its initial state, if it has not decayed yet. A final X90 gate is applied, followed by a measurement.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
delays – The time delay between pulses to sweep over.
n_shots – The number of times to repeat the program.
fitter – The fitter model for post-processing.
name – The name of the experiment.
save_path – The path to save the experiment to.
- configure_repetitions(delays: Iterable[float] | Array[float] | np.ndarray, n_shots: int = 500, hw_sweep: int = 1) None
Configures the repetitions of this experiment.
- Parameters:
delays – The time delay between pulses to sweep over.
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode.
- class keysight.qcs.experiments.ErrorAmplification(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits, amplitudes: Iterable[float] | Array[float] | np.ndarray | None = None, amplitude_name: str = 'x180_pulse_amplitudes', n_amplifications: int = 5, n_shots: int = 100, fitter: BaseFitter | None = None, name: str | None = 'ErrorAmplification', save_path: str | Path | None = None)
Bases:
Experiment
Initializes an Error Amplification experiment, which consists of a sequence of pairs of X gates, with varying amplitude between sweeps.
When the amplitude is not precise, the rotation is not perfect and a pair of pulses does not get the system back to its initial state. Increasing the number of pairs accumulates the errors and increases the deviation, making it more prominent to the user.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
amplitudes – The pulse amplitudes to sweep over.
amplitude_name – The name in the calibration set of the amplitude variable of the operation to sweep.
n_amplifications – The maximum number of pairs of drive signals sent.
n_shots – The number of times to repeat the program.
fitter – The fitter model for post-processing.
name – The name of the experiment.
save_path – The path to save the experiment to.
- amplitude_to_angle(amplitudes: Iterable[float] | Array[float] | np.ndarray, amplitude_name: str = 'x180_pulse_amplitudes')
Converts input amplitude array into angles before intializing the X rotation gates. This is required as
PAULIS.rx
only takes angles in its definition inmake_calibration_set()
.
- Parameters:
amplitude – The amplitudes to sweep over.
amplitude_name – The name in the calibration set of the amplitude variable of the operation to sweep.
- configure_repetitions(amplitudes: Iterable[float] | Array[float] | np.ndarray, amplitude_name: str = 'x180_pulse_amplitudes', n_shots: int = 100, hw_sweep: int = 2) None
Configures the repetitions of this experiment.
- Parameters:
amplitudes – The amplitudes to sweep over.
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode.
- generate_pulse_sequence_matrix() Array[int]
Generates an array containing the sequences of pairs of pi pulses to sweep over.
For instance, with
n_amplifications
= 3, this returns\[\begin{split}\begin{bmatrix} 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1 & 1 \\ 0 & 0 & 1 & 1 & 1 & 1 \\ 1 & 1 & 1 & 1 & 1 & 1 \end{bmatrix}\end{split}\]where 0 and 1 represent whether a pulse is sent or not.
- class keysight.qcs.experiments.Experiment(backend: keysight.qcs.channels.channel_mapper.ChannelMapper | keysight.qcs.executor.hcl_backend.HclBackend | pathlib.Path | str, calibration_set: keysight.qcs.programs.calibration.CalibrationSet | pathlib.Path | str, targets: Targets, program: Program, fitter: Optional[BaseFitter] = None, pre_processor: Optional[Preprocessor] = None, name: Optional[str] = None, save_path: Optional[Union[str, Path]] = None, mock_data: Optional[dict] = None)
Bases:
BaseExperiment
A class enabling convenient execution of programs on hardware and analysis of the results.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
targets – The targets of the experiment.
program – The program to run.
fitter – The fitter to fit the experimental data to.
pre_processor – A
Preprocessor
to apply to the data before fitting.name – The name of the experiment.
save_path – The path to save the experiment to.
mock_data – IQ/trace data that is compatible with the provided program and backend (channel_mapper)
- property accession_ids: dict[str, str]
A dictionary of timestamps to accession ids.
- property fitter: keysight.qcs.analysis.fitter.BaseFitter | None
The fitter for the experimental data.
- property fitted_parameters: EstimateCollection
The fitted parameters for the experimental data.
- property pre_processor: keysight.qcs.analysis.fitter.Preprocessor | None
The pre-processor for the experimental data, to be applied before fitting.
- property idx: int | list[int]
The index of the targets in this experiment.
- configure_repetitions(n_shots: int, hw_sweep: int, reset_rep: bool = True, **kwargs) None
Configures the repetitions of this experiment.
This method supports the following sweep configurations to be passed in the keyword arguments.
1D Sweeps
Pass the sweep as keyword arguments.
readout_frequencies=readout_frequencies
Nested Sweeps
Specify multiple sweeps using a dictionary.
readout_frequencies=frequency_scan, readout_pulse_amplitude=amplitude_scan
Zipped Sweeps
Provide variables and their corresponding values in a zipped structure.
variables = ["x180_pulse_amplitudes", "xy_pulse_frequencies"], values = [amp_scan_values, freq_scan_values]]
- Parameters:
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode. The max number of dimensions capable by the hardware is eight.
reset_rep – Whether to reset the repetitions before configuring repetitions.
kwargs – Keyword arguments representing a variable and its sweep.
- draw(filename: str = 'qcs_program.html', display: bool = True) None
Creates a HTML representation of this Program and saves it to a file.
- Parameters:
filename – The filename to write the HTML to (if executing in a script).
display – Whether to display the HTML. When set to False, this will only save the file to the specified filename.
- execute(hw_demod: Optional[bool] = None, auto_save: bool = False) None
Execute the program on hardware.
- Parameters:
hw_demod – Whether or not to demodulate trace data directly in hardware. If set, it will temporarily override the value of
self.backend.hw_demod
.auto_save – Whether to save the experiment as a .qcs file.
- Raises:
ValueError – If auto_save is True but no save_path has been set.
- get_classified(channels: Optional[Union[Channels, Qudits]] = None, avg: bool | int = False, stack_channels: bool = False, classifier: Optional[Union[Classifier, MinimumDistanceClassifier]] = None, integration_filter: Optional[IntegrationFilter] = None, timestamp: Optional[Union[str, int]] = None, acq_index: int = -1) DataFrame
Get the classified data for specified channels or qudits.
- Parameters:
channels – The channels or qudits to get the data for.
avg – Whether to average the data or the axis to average it over. Setting
avg=True
will average over the last axis.stack_channels – Whether to stack the channel index as rows.
classifier – An optional classifier to classify the IQ data.
integration_filter – An optional integration filter to generate IQ data from trace data.
timestamp – The timestamp created when the program was run, or an integer referring to a timestamp index in the experiment’s history.
acq_index – The index of the acquisition to get. Default -1 returns the last acquisition, None returns all acquisitions.
- Raises:
TypeError – If
stack_channels
isTrue
but the installed pandas version is below 2.1.
- fit(x_values: ndarray, channels: Optional[Union[Channels, Qudits]] = None, avg: bool | int = True, timestamp: Optional[Union[str, int]] = None, data_type: str = 'iq') EstimateCollection
Fits the data from the experiment.
- Parameters:
x_values – The independent data for the fit.
channels – The channels or qudits to pull the data from.
avg – Whether to average the data.
timestamp – The timestamp of the program to use in fitting. By default, fits the most recent program.
data_type – What type of data to fit. Valid options are classified, iq, or trace.
- Raises:
ValueError – If this experiment has no fitter.
ValueError – If data_type is not one of classified, iq, or trace.
ValueError – If x_values and the data are incompatible shapes.
- plot(x_values: ndarray, channels: Optional[Union[Channels, Qudits]] = None, avg: bool | int = True, timestamp: Optional[Union[str, int]] = None, data_type: str = 'iq', x_axis_label: Optional[str] = None, y_axis_label: Optional[str] = None) Figure
Plots the Experiment’s data and fit (if applicable). Defaults to plotting I/Q data if no Preprocessor or Fitter has been defined, and to trace data if no I/Q data exists.
- Parameters:
x_values – The independent data for the fit.
channels – The channels or qudits to pull the data from.
avg – Whether to average the data.
timestamp – The timestamp of the program to use in fitting. By default, fits the most recent program.
data_type – What type of data to fit. Valid options are classified, iq, or trace.
- Raises:
ValueError – If data_type is not one of classified, iq, or trace.
- get_iq(channels: Optional[Union[Channels, Qudits]] = None, avg: bool | int = False, stack_channels: bool = False, integration_filter: Optional[IntegrationFilter] = None, timestamp: Optional[Union[str, int]] = None, acq_index: int = -1) DataFrame
Get the IQ data.
- Parameters:
channels – The channels or qudits to get the data for.
avg – Whether to average the data or the axis to average it over. Setting
avg=True
will average over the last axis.stack_channels – Whether to stack the channel index as rows.
integration_filter – An optional integration filter to generate IQ data from trace data.
timestamp – The timestamp created when the program was run, or an integer referring to a timestamp index in the experiment’s history.
acq_index – The index of the acquisition to get. Default -1 returns the last acquisition, None returns all acquisitions.
- get_spectrum(channels: Optional[Union[Channels, Qudits]] = None, avg: bool | int = False, window: Union[None, Callable[[int], ndarray], ndarray, Iterable[ndarray]] = None, pad: Optional[int] = None, timestamp: Optional[Union[str, int]] = None) DataFrame
Get the power spectrum of the trace data for specified channels or qudits using the discrete Fourier transform.
- Parameters:
channels – The channels or qudits to get the data for.
avg – Whether to average the data or the axis to average it over. Setting
avg=True
will average over the last axis.window – An optional window function to multiply the trace data with before calculating the Fourier transfrom.
pad – Whether to pad the traces with zeros before taking the Fourier transform. If an integer
n
is passed, the traces will be cropped or extended (with zeros) to lengthn
depending on the length of the traces.timestamp – The timestamp created when the program was run, or an integer referring to a timestamp index in the experiment’s history.
- Raises:
ValueError – If program was executed with hardware demodulation.
- get_trace(channels: Optional[Union[Channels, Qudits]] = None, avg: bool | int = False, timestamp: Optional[Union[str, int]] = None) DataFrame
Get the trace data for specified channels or qudits.
- Parameters:
channels – The channels or qudits to get the data for.
avg – Whether to average the data or the axis to average it over. Setting
avg=True
will average over the last axis.timestamp – The timestamp created when the program was run, or an integer referring to a timestamp index in the experiment’s history.
- Raises:
ValueError – If program was executed with hardware demodulation.
- plot_iq(channel_subplots: bool = True, avg: bool | int = True, plot_type: str = 'linear', plot_axis: int = 0, group_scatter: bool = True, channels: Optional[Channels] = None, timestamp: Optional[Union[str, int]] = None) Figure
Plots the IQ data.
- Parameters:
channel_subplots – Whether to generate subplots for different channels.
avg – Whether to average the data or the axis to average it over. Setting
avg=True
will average over the last axis.plot_type – Whether to plot the I/Q data as a linear plot or a scatter plot.
plot_axis – The axis of the dataframe over which to plot the IQ data.
group_scatter – Groups scatter points using the same color and markers.
channels – Which channels to plot. Defaults to all channels.
timestamp – The timestamp created when the program was run, or an integer referring to a timestamp index in the experiment’s history.
- Raises:
ValueError – When the plot_axis is out of bounds.
- plot_spectrum(channel_subplots: bool = True, avg: bool | int = True, window: Union[None, Callable[[int], ndarray], ndarray, Iterable[ndarray]] = None, pad_zeros: bool | int | collections.abc.Iterable[int] = True, channels: Optional[Channels] = None, timestamp: Optional[Union[str, int]] = None) Figure
Plots the power spectrum of the trace data.
- Parameters:
channel_subplots – Whether to generate subplots for different channels.
avg – Whether to average the data or the axis to average it over. Setting
avg=True
will average over the last axis.window – An optional window function to multiply the trace data with before calculating the Fourier transfrom.
pad_zeros – Whether to pad the traces with zeros to interpolate the spectrum. The default value
True
will pad each trace to 5x the trace length. If an integer or a list of integers is passed, each trace will be padded (or truncated) to that number.channels – Which channels to plot. Defaults to all channels.
timestamp – The timestamp created when the program was run, or an integer referring to a timestamp index in the experiment’s history.
- plot_trace(channel_subplots: bool = True, avg: bool | int = True, channels: Optional[Channels] = None, timestamp: Optional[Union[str, int]] = None) Figure
Plots the trace data.
- Parameters:
channel_subplots – Whether to generate subplots for different channels.
avg – Whether to average the data or the axis to average it over. Setting
avg=True
will average over the last axis.channels – Which channels to plot. Defaults to all channels.
timestamp – The timestamp created when the program was run, or an integer referring to a timestamp index in the experiment’s history.
- plot_classified(acq_index: int = -1, channel_subplots: bool = True, channels: Optional[Channels] = None, sweep_index: Optional[Union[int, tuple[int]]] = None, timestamp: Optional[str] = None) Figure
Plots the Classified data.
- Parameters:
acq_index – The index of the acquisition to get. Default -1 returns the last acquisition.
channel_subplots – Whether to generate subplots for different channels.
channels – Which channels to plot. Defaults to all channels.
sweep_index – The sweep point to plot. For nested sweeps, provide the index as a tuple where the leftmost index is the outermost sweep.
timestamp – The timestamp created when the program was run.
- render(channel_subplots: bool = True, channels: Optional[Union[Channels, Iterable[Channels]]] = None, lo_frequency: float = 0.0, sample_rate: float = 1000000000.0, plot_imaginary: bool = False, sweep_index: Optional[Union[int, tuple[int]]] = None) Figure
Renders the waveforms in this program with the current values of variables or, if this program has sweeps, the value at the sweep point specified by
sweep_idx
, with a value ofNone
corresponding to the first sweep point their values at the first sweep point.
- Parameters:
channel_subplots – Whether to split each channel into its own subplot.
channels – The channels to include when rendering waveforms. If
None
, all channels on the program are included.lo_frequency – The LO frequency used to render, in case the given mapper does not specify one for the channels being plotted.
sample_rate – The sample rate used to render, in case the given mapper does not specify one for the channels being plotted.
plot_imaginary – Whether to render the imaginary part of the waveforms. This option is included because the imaginary portion is often zero and omitting it reduces the time required to render by half.
sweep_index – The sweep point to render. For nested sweeps, provide the index as a tuple where the leftmost index is the outermost sweep.
- Raises:
ValueError – If the
sweep_index
is out of bounds for this program’s repetitions.
- set_mock_data(mock_data: dict) None
Sets and generates relevant variables/objects for the user-provided data. :param mock_data: IQ/trace data that is compatible with the provided program and backend (channel_mapper)
- class keysight.qcs.experiments.IQDistributionExperiment(backend: keysight.qcs.channels.channel_mapper.ChannelMapper | keysight.qcs.executor.hcl_backend.HclBackend | pathlib.Path | str, calibration_set: keysight.qcs.programs.calibration.CalibrationSet | pathlib.Path | str, qubits: Qudits, n_shots: int = 100, name: str = 'IQDistribution', save_path: Optional[Union[str, Path]] = None)
Bases:
Experiment
Initializes an IQ Distribution experiment to measure the ground and excited states by preparing each in turn.
The program in this class consists of a parametric sequence consisting of a X(angle) pulse followed by a measurement. The program is executed for angle values of 0 and 180 degrees.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
n_shots – The number of times to repeat the program.
name – The name of the experiment. Defaults to
IQDistribution
.save_path – The path to save the experiment to.
- check_target_qubits(target_qubits)
Checks whether target qubits are provided in a proper format and whether an IQ distribution experiment has been conducted on all of them.
- Parameters:
target_qubits – The target qubits provided by the user when initializing the kernel optimization.
- configure_repetitions(n_shots: int = 100, hw_sweep: int = 1) None
Configures the repetitions (sweeps and shots) of this experiment.
- Parameters:
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode.
- get_optimized_parameters(format='flat') ndarray
Returns the optimized parameters for the integration filter for each selected qubit.
- Parameters:
format – The format of the array returned. flat is a one-dimensional array, reshape is (number of qubits, 3)-dimensional.
- kernel_optimization(target_qubits: np.ndarray | int | Iterable[int] | Qudits | None = None, initial_guess: Array[float] | np.ndarray | None = None, lower_bound: Array[float] | np.ndarray | None = None, upper_bound: Array[float] | np.ndarray | None = None, acquisition_duration_name: str = 'acquisition_duration', readout_frequencies_name: str = 'readout_frequencies', timestamp: str | int | None = None, update_measurement: bool = False, operation_name: str = 'measurement', new_operation_name: str = 'optimized_measurement') None
Provides the user the possibility of optimizing their filter design in order to improve qubit readout fidelity.
For every target qubit, we demodulate the time-domain data from its respective IQ blob experiment using the integration envelope. We compute the average distance between the ground state and the excitated blobs, which we will be maximized to get maximal qubit readout fidelity.
The filter envelope consists of two parts: a rising gaussian and a decaying exponential. The gaussian rise accounts for the ring-up time of the readout resonator placing small weight to the first samples. The decaying term confers less weight to the last samples acquired as the qubit decoheres during readout.
The method will create a new optimized measurement linker if update_measurement is set to True.
- Parameters:
target_qubits – The qudits to get the data for. If input is None, every qudit for which the experiment was conducted is considered a target.
initial_guess – Initial guess for the filter parameters for every qubit.
lower_bound – Lower bounds for the filter parameters.
upper_bound – Upper bounds for the filter parameters.
acquisition_duration_name – Name of the duration of the measurement variable in the calibration set.
readout_frequencies_name – Name of the frequency variable of the readout pulse in the calibration set.
timestamp – The timestamp of the executed program get data from for optimization. By default, refers to the most recent program.
update_measurement – Whether measurement operation is updated when calling the kernel_optimization method.
operation_name – Name of the operation in the calibration set corresponding to the measurement.
new_operation_name – Name given to the new measurement operation created with optimized integration filter shapes.
- update_measurement_operation(operation_name: str = 'measurement', new_operation_name: str = 'optimized_measurement') None
Updates the integration filter for the target qubits with the optimized values.
- Parameters:
operation_name – Name of the operation in the calibration set corresponding to the measurement.
new_operation_name – Name given to the new measurement operation created with optimized integration filter shapes.
- class keysight.qcs.experiments.QubitSpectroscopy(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits, frequencies: Iterable[float] | Array[float] | np.ndarray | None = None, n_shots: int = 100, operation: str = 'x', frequency_name: str = 'xy_pulse_frequencies', name: str | None = 'QubitSpectroscopy', save_path: str | Path | None = None)
Bases:
CalibrationExperiment
Initializes a qubit spectroscopy experiment to measure the resonant frequencies of qubits.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
frequencies – The frequencies to sweep over.
operation – The operation to calibrate, specified as a string. A linker with the same name must exist in the calibration_set to compile this operation.
frequency_name – The name of the frequency variable on the operation to sweep.
name – The name of the experiment.
save_path – The path to save the experiment to.
- configure_repetitions(frequencies: Iterable[float] | Array[float] | ndarray, n_shots: int = 100, hw_sweep: int = 1, frequency_name: str = 'xy_pulse_frequencies')
Configures the repetitions of this experiment.
- Parameters:
frequencies – The frequencies to sweep over.
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode.
frequency_name – The name of the frequency variable on the operation to sweep.
- fit(x_values: Optional[ndarray] = None, qudits: Optional[Qudits] = None, timestamp: Optional[Union[str, int]] = None) EstimateCollection
Fits the Qubit spectroscopy experiment data.
- Parameters:
qudits – The qudits to pull the data from.
timestamp – The timestamp of the program to use in fitting. By default, fits the most recent program.
- get_updated_calibration_values(timestamp: Optional[Union[str, int]] = None) dict[str, float | collections.abc.Iterable[float]]
Calculates the new values for the calibration variable(s) of this experiment.
- Parameters:
timestamp – The timestamp of the program to use in fitting. By default, fits the most recent program.
- class keysight.qcs.experiments.RabiExperiment(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits, amplitudes: Iterable[float] | Array[float] | ndarray | None = None, n_shots: int = 100, operation: str = 'x', amplitude_name: str = 'x180_pulse_amplitudes', name: str | None = 'RabiExperiment', save_path: str | Path | None = None)
Bases:
CalibrationExperiment
Initializes a Rabi experiment to measure the Rabi oscillations between ground and excited state populations by varying the amplitude of the drive signal.
The program in this experiment consists of a variable amplitude X pulse followed by a measurement.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
amplitudes – The amplitudes to sweep over.
n_shots – The number of times to repeat the program.
operation – The operation to calibrate, specified as a string. A linker with the same name must exist in the calibration_set to compile this operation.
amplitude_name – The name of the amplitude variable in the calibration_set that is used by the specified operation.
name – The name of the experiment.
save_path – The path to save the experiment to.
- configure_repetitions(amplitudes: Iterable[float] | Array[float] | ndarray, n_shots: int = 100, amplitude_name: str = 'x180_pulse_amplitudes', hw_sweep: int = 1) None
Configures the repetitions of this experiment.
- Parameters:
amplitudes – The amplitudes to sweep over.
n_shots – The number of times to repeat the program.
amplitude_name – The name of the amplitude variable on the operation to sweep.
hw_sweep – The number of sweeps to run in hardware mode.
- fit(x_values: Optional[ndarray] = None, qudits: Optional[Qudits] = None, timestamp: Optional[Union[str, int]] = None) EstimateCollection
Fits the Rabi experiment data.
- Parameters:
qudits – The qudits to pull the data from.
timestamp – The timestamp of the program to use in fitting. By default, fits the most recent program.
- get_updated_calibration_values(timestamp: Optional[Union[str, int]] = None) dict[str, float | collections.abc.Iterable[float]]
Calculates the new values for the calibration variable(s) of this experiment.
- Parameters:
timestamp – The timestamp of the program to use in fitting. By default, fits the most recent program.
- class keysight.qcs.experiments.RamseyExperiment(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits, delays: Iterable[float] | Array[float] | np.ndarray | None = None, n_shots: int = 100, name: str | None = 'RamseyExperiment', save_path: str | Path | None = None)
Bases:
Experiment
Initializes a Ramsey experiment to measure the relaxation time of a qubit.
The program in this class consists of two X90 gates separated by a variable delay.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
delays – The delays to sweep over.
n_shots – The number of times to repeat the program.
name – The name of the experiment.
save_path – The path to save the experiment to.
- configure_repetitions(delays: Iterable[float] | Array[float] | np.ndarray, n_shots: int = 100, hw_sweep: int = 1) None
Configures the repetitions of this experiment.
- Parameters:
delays – The delays to sweep over.
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode.
- class keysight.qcs.experiments.ResonatorSpectroscopy(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits, frequencies: Iterable[float] | Array[float] | ndarray | None = None, n_shots: int = 100, operation: str = 'measurement', frequency_name: str = 'readout_frequencies', name: str | None = 'ReadoutSpectroscopy', save_path: str | Path | None = None)
Bases:
CalibrationExperiment
Initializes an experiment to measure the resonant frequencies of the readout cavities associated with qubits.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
frequencies – The frequencies to sweep over.
n_shots – The number of times to repeat the program.
operation – The operation to calibrate, specified as a string. A linker with the same name must exist in the calibration_set to compile this operation.
frequency_name – The name of the frequency variable on the operation to sweep.
name – The name of the experiment.
save_path – The path to save the experiment to.
- configure_repetitions(frequencies: Iterable[float] | Array[float] | ndarray, n_shots: int = 100, hw_sweep: int = 0, frequency_name: str = 'readout_frequencies')
Configures the repetitions of this experiment.
- Parameters:
frequencies – The frequencies to sweep over.
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode.
frequency_name – The name of the frequency variable on the measurement to sweep.
- fit(x_values: Optional[ndarray] = None, qudits: Optional[Qudits] = None, timestamp: Optional[Union[str, int]] = None) EstimateCollection
Fits the Resonator spectroscopy experiment data.
- Parameters:
qudits – The qudits to pull the data from.
timestamp – The timestamp of the program to use in fitting. By default, fits the most recent program.
- get_updated_calibration_values(timestamp: Optional[Union[str, int]] = None) dict[str, float | collections.abc.Iterable[float]]
Calculates the new values for the calibration variable(s) of this experiment.
- Parameters:
timestamp – The timestamp of the program to use in fitting. By default, fits the most recent program.
- class keysight.qcs.experiments.ResonatorSpectroscopy2D(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits, frequencies: Iterable[float] | Array[float] | ndarray | None = None, amplitudes: Iterable[float] | Array[float] | ndarray | None = None, n_shots: int = 100, operation: str = 'measurement', frequency_name: str = 'readout_frequencies', amplitude_name: str = 'readout_pulse_amplitudes', name: str | None = 'ReadoutSpectroscopy2D', save_path: str | Path | None = None)
Bases:
CalibrationExperiment
Initializes an experiment to measure the resonant frequencies of the readout resonators associated with qubits while varying the amplitude of the readout pulse.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
frequencies – The resonator frequencies to sweep over.
amplitudes – The readout pulse amplitudes to sweep over.
n_shots – The number of times to repeat the program.
operation – The operation to calibrate, specified as a string. A linker with the same name must exist in the calibration_set to compile this operation.
frequency_name – The name of the frequency variable on the operation to sweep.
amplitude_name – The name of the amplitude variable on the operation to sweep.
name – The name of the experiment.
save_path – The path to save the experiment to.
- configure_repetitions(frequencies: Iterable[float] | Array[float] | ndarray, amplitudes: Iterable[float] | Array[float] | ndarray, n_shots: int = 100, hw_sweep: int = 0, frequency_name: str = 'readout_frequencies', amplitude_name: str = 'readout_pulse_amplitudes')
Configures the repetitions of this experiment.
- Parameters:
frequencies – The frequencies to sweep over.
amplitudes – The amplitudes to sweep over.
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode.
frequency_name – The name of the frequency variable on the measurement to sweep.
amplitude_name – The name of the amplitude variable on the measurement to sweep.
- class keysight.qcs.experiments.T1Experiment(backend: ChannelMapper | HclBackend | Path | str, calibration_set: CalibrationSet | Path | str, qubits: Qudits, delays: Iterable[float] | Array[float] | np.ndarray | None = None, n_shots: int = 100, fitter: BaseFitter = <keysight.qcs.analysis.fitter.Exponential object>, name: str | None = 'T1Experiment', save_path: str | Path | None = None)
Bases:
Experiment
Initializes an experiment to measure the relaxation time of a qubit system.
- Parameters:
backend – The backend to run the experiment on, or a channel mapper used to construct the backend.
calibration_set – The calibration of the system.
qubits – The qubits to perform the experiment on.
delays – The delays to sweep over.
n_shots – The number of times to repeat the program.
name – The name of the experiment.
save_path – The path to save the experiment to.
- configure_repetitions(delays: Iterable[float] | Array[float] | np.ndarray, n_shots: int = 100, hw_sweep: int = 1) None
Configures the repetitions of this experiment.
- Parameters:
delays – The delays to sweep over.
n_shots – The number of times to repeat the program.
hw_sweep – The number of sweeps to run in hardware mode.
- keysight.qcs.experiments.make_calibration_set(qubits: int | collections.abc.Iterable[int] | keysight.qcs.quantum.qudits.Qudits = 10, edge_list: Optional[Array] = None)
Returns a CalibrationSet that is compatible with pre-defined Experiments.
- Parameters:
qubits – The number of qubits to generate a calibration set for.