InstructionToSignals#
- class InstructionToSignals(dt, carriers=None, channels=None)[source]#
Bases:
object
Converts pulse instructions to signals to be used in models.
The
InstructionsToSignals
class converts a pulse schedule to a list of signals that can be given to a model. This conversion is done by calling theget_signals()
method on a schedule. The converter applies to instances ofSchedule
. Instances ofScheduleBlock
must first be converted toSchedule
using theblock_to_schedule()
function in Qiskit Pulse.The converter can be initialized with the optional arguments
carriers
andchannels
. Whenchannels
is given, only the signals specified by name inchannels
are returned. Thecarriers
dictionary specifies the analog carrier frequency of each channel. Here, the keys are the channel name, e.g.d12
for drive channel number12
, and the values are the corresponding frequency. If a channel is not present incarriers
it is assumed that the analog carrier frequency is zero.See the
get_signals()
method documentation for a detailed description of how pulse schedules are interpreted and translated intoDiscreteSignal
objects.Initialize pulse schedule to signals converter.
- Parameters:
dt (
float
) – Length of the samples. This is required by the converter as pulse schedule are specified in units of dt and typically do not carry the value of dt with them.carriers (
Optional
[Dict
[str
,float
]]) – A dict of analog carrier frequencies. The keys are the names of the channels and the values are the corresponding carrier frequency.channels (
Optional
[List
[str
]]) – A list of channels that theget_signals()
method should return. This argument will causeget_signals()
to return the signals in the same order as the channels. Channels present in the schedule but absent from channels will not be included in the returned object. If None is given (the default) then all channels present in the pulse schedule are returned.
Methods
- static get_awg_signals(signals, if_modulation)[source]#
Create signals that correspond to the output ports of an Arbitrary Waveform Generator to be used with IQ mixers. For each signal in the list the number of signals is double to create the I and Q components. The I and Q signals represent the real and imaginary parts, respectively, of
\[\Omega(t) e^{i \omega_{if} t}\]where \(\Omega\) is the complex-valued pulse envelope and \(\omega_{if}\) is the intermediate frequency.
- Parameters:
signals (
List
[DiscreteSignal
]) – A list of signals for which to create I and Q.if_modulation (
float
) – The intermediate frequency with which the AWG modulates the pulse envelopes.
- Returns:
- A list of signals which is twice as long as the input list of signals. For
each input signal get_awg_signals returns two
- Return type:
iq signals
- get_signals(schedule)[source]#
Convert a schedule to a corresponding list of DiscreteSignal instances.
Which channels are converted, and the order they are returned, is controlled by the
channels
argument at instantiation. Thecarriers
instantiation argument sets the analog carrier frequency for each channel, which is fixed for the full duration. For a given channel, the \(k^{th}\) envelope sample for the correspondingDiscreteSignal
is determined according to the following formula:\[f(k) \exp(i(2\pi \Delta\nu(k) k dt + \phi(k) + 2 \pi \phi_a(k))),\]where:
\(f(k)\) is the waveform value at the \(k^{th}\) time step as specified by
Play
instructions.\(\Delta\nu(k)\) is the frequency deviation at time step \(k\) from the analog carrier as the result of
SetFrequency
andShiftFrequency
instructions. As evident by the formula, carrier frequency deviations as a result of these instructions are handled digitally, with the analog carrier frequency being fixed for the entirety of the schedule.\(dt\) is the sample rate as specified by the
dt
instantiation argument.\(\phi(k)\) is the channel phase at time step \(k\), as determined by
ShiftPhase
andSetPhase
instructions.\(\phi_a(k)\) is the phase correction term at time step \(k\), impacted by
SetFrequency
andShiftFrequency
instructions, described below.
In detail, the sample array for the output signal for each channel is generated by iterating over each instruction in the schedule in temporal order. New samples are appended with every
Play
instruction on the given channel, using the waveform values and the current value of the tracked parameters \(\Delta\nu\), \(\phi\), and \(\phi_a\), which are initialized to \(0\). Explicitly, each instruction is interpreted as follows:Play
instructions add new samples to the sample array, according to the above formula, using the waveform specified in the instruction and the current values of \(\Delta\nu\), \(\phi\), and \(\phi_a\).ShiftPhase
, with a phase value \(\psi\), updates \(\phi \mapsto \phi + \psi\).SetPhase
, with a phase value \(\psi\), updates \(\phi \mapsto \psi\).ShiftFrequency
, with a frequency value \(\mu\) at time-step \(k\), updates \(\phi_a \mapsto \phi_a - \mu k dt\) and \(\Delta\nu \mapsto \Delta\nu + \mu\). The simultaneous shifting of both \(\Delta\nu\) and \(\phi_a\) ensures that the carrier wave, as a combination of the analog and digital components, is continuous acrossShiftFrequency
instructions (up to the sampling rate \(dt\)).SetFrequency
, with a frequency value \(\mu\) at time-step \(k\), updates \(\phi_a \mapsto \phi_a - (\mu - (\Delta\nu + \nu)) k dt\) and \(\Delta\nu \mapsto \mu - \nu\), where \(\nu\) is the analog carrier frequency. Similarly toShiftFrequency
, the shift rule for \(\phi_a\) is defined to maintain carrier wave continuity.
If, at any sample point \(k\), \(\Delta\nu(k)\) is larger than the Nyquist sampling rate given by
dt
, a warning will be raised.- Parameters:
schedule (
Schedule
) – The schedule to represent in terms of signals. Instances ofScheduleBlock
must first be converted toSchedule
using theblock_to_schedule()
function in Qiskit Pulse.- Return type:
List
[DiscreteSignal
]- Returns:
A list of
DiscreteSignal
instances.