Functions
Parameters
StringParameter
BoolParameter
IntParameter
FloatParameter
NanosecondParameter
GigahertzParameter
RadianParameter
DictParameter
ListParameter
- sequencing.parameters.ListParameter(default=None, factory=<class 'list'>, **kwargs)[source]
Adds a list parameter.
- Parameters
default (optional, list) – Default value. Default: None.
base (optional, callabe) – Factory function, e.g. list or tuple. Default: list.
Modes
sort_modes
- sequencing.modes.sort_modes(modes)[source]
Sorts a list of
Modes
based on the logic described below.Mode ordering is decided primarily by mode Hilbert space size: modes with more levels go on the right.
Among modes with the same number of levels, the ordering is decided alphanumerically from right to left.
For example, assuming all cavities have the same number of levels and all qubits have the same, smaller, number of levels: [qubit1, qubit0, cavity2, cavity1, cavity0]
Pulses
array_pulse
- sequencing.pulses.array_pulse(i_wave, q_wave=None, amp=1, phase=0, detune=0, dt=1.0, noise_sigma=0, noise_alpha=0, scale_noise=False)[source]
Takes a real or complex waveform and applies an amplitude scaling, phase offset, time-dependent phase, and additive Gaussian noise.
- Parameters
i_wave (array-like) – Real part of the waveform.
q_wave (optional, array-like) – Imaginary part of the waveform. If None, the imaginary part is set to 0. Default: None.
amp (float) – Factor by which to scale the waveform amplitude. Default: 1.
phase (optional, float) – Phase offset in radians. Default: 0.
detune (optional, float) – Software detuning/time-dependent phase to apply to the waveform, in GHz. Default: 0.
dt (optional, float) – Sample time in nanoseconds.
noise_sigma (optional, float) – Standard deviation of additive Gaussian noise applied to the pulse (see scale_noise). Default: 0.
noise_alpha (optional, float) – Exponent for the noise PSD S(f). S(f) is proportional to (1/f)**noise_alpha. noise_alpha = 0 for white noise, noise_alpha = 1 for 1/f noise, etc. Default: 0 (white noise).
scale_noise (optional, bool) – Whether to scale the noise by
amp
before adding it to the signal. If False, then noise_sigma has units of GHz. Default: False.
- Returns
Complex waveform.
- Return type
np.ndarray
pulse_factory
- sequencing.pulses.pulse_factory(cls, name=None, **kwargs)[source]
Returns a function that creates an instance if the given pulse class.
Keyword arguments are passed to
cls.__init__()
.- Parameters
- Returns
A function that takes no arguments and returns an instance of
cls
.- Return type
callable
Sequencing
ket2dm
ops2dms
get_sequence
sync
- sequencing.sequencing.sync(seq=None)[source]
Ensure that the Hamiltonian channels all align up to this point.
This means that all operations which follow the sync will be executed after all those before the sync. Sequences are constructed in terms of blocks of operations separated by sync()s. Within a block, channels are made to have equal duration by padding shorter channels to the maximum channel length.
- Parameters
seq (optional, CompiledPulseSequence) – CompiledPulseSequence on which to apply the sync. If None, a SyncOperation is appended to the global PulseSequence. Default: None.
See also
delay
- sequencing.sequencing.delay(length, sync_before=True, sync_after=True, seq=None)[source]
Adds a global delay to the sequence, delaying all channels by the same amount.
- Parameters
length (int) – Length of the delay.
sync_before (optional, bool) – Whether to insert a sync() before the delay. Default: True.
sync_after (optional, bool) – Whether to insert a sync() after the delay. Default: True.
seq (optional, CompiledPulseSequence) – CompiledPulseSequence on which to apply the delay. If None, a DelayOperation is appended to the global CompiledPulseSequence. Default: None.
See also
delay_channels
- sequencing.sequencing.delay_channels(channels, length, seq=None)[source]
Adds a delay of duration length to only the channels specified in channels.
- Parameters
channels (str | list | dict) – Either the name of a single channel, a list of channel names, or a dict of the form {channel_name: H_op}, or a dict of the form {channel_name: (H_op, C_op)}. One of the latter two is required if the channels are not yet defined in seq.channels (i.e. if no previous Operations have involved these channels).
length (int) – Duration of the delay.
seq (optional, CompiledPulseSequence) – CompiledPulseSequence on which to delay channels. If None, a DelayChannelsOperation is appended to the global CompiledPulseSequence. Default: None.
@capture_operation
- @sequencing.sequencing.capture_operation[source]
A decorator used to wrap functions that return an
Operation
, which captures theOperation
and adds it to the globalPulseSequence
.If a function that is decorated with
@capture_operation
is called with the keyword argumentcapture=False
, theOperation
returned by the wrapped function will not be captured and added to the globalPulseSequence
, but rather returned as normal.
Gates
- @sequencing.gates.single_qubit_gate[source]
A decorator used to specify that the decorated function is a single-qubit gate acting on one or more Modes.
- @sequencing.gates.pulsed_gate_exists[source]
A decorator used to specify types of Modes for which a pulse-based version of the gate exists.
If the first argument is
None
, then the gate is required to be unitary-only for all types of Modes.
Single-qubit gates
- sequencing.gates.rx(theta, *qubits, **kwargs)[source]
Rotates each mode about its x axis by a given angle.
\[R_x(\theta) = \exp(-i\theta/2 \cdot X)\]
- sequencing.gates.ry(theta, *qubits, **kwargs)[source]
Rotates each mode about its y axis by a given angle.
\[R_y(\theta) = \exp(-i\theta/2 \cdot Y)\]
- sequencing.gates.rz(phi, *qubits, **kwargs)[source]
Rotates each mode about its z axis by a given angle.
\[R_z(\phi) = \exp(-i\phi/2 \cdot Z)\]
- sequencing.gates.h(*qubits, **kwargs)[source]
Hadamard gate.
\[H = \frac{1}{\sqrt{2}}\left(X + Z\right)\]
Two-qubit gates
- sequencing.gates.cu(control, target, theta, phi, lamda)[source]
Controlled-U gate.
\[\begin{split}CU(\theta,\phi,\lambda) &= |00\rangle\langle00|\\ &+ |01\rangle\langle01|\\ &+ \cos(\theta/2)|10\rangle\langle10|\\ &+ e^{i(\phi + \lambda)}\cos(\theta/2)|11\rangle\langle11|\\ &+ e^{i\phi}\sin(\theta/2)|11\rangle\langle10|\\ &- e^{i\lambda}\sin(\theta/2)|10\rangle\langle11|\\\end{split}\]- Parameters
- Returns
The CU operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.cx(control, target)[source]
Controlled-X gate.
\[\begin{split}CX &= |00\rangle\langle00|\\ &+ |01\rangle\langle01|\\ &+ |11\rangle\langle10|\\ &+ |10\rangle\langle11|\\\end{split}\]- Parameters
- Returns
The CX operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.cy(control, target)[source]
Controlled-Y gate.
\[\begin{split}CY &= |00\rangle\langle00|\\ &+ |01\rangle\langle01|\\ &+ i|11\rangle\langle10|\\ &- i|10\rangle\langle11|\\\end{split}\]- Parameters
- Returns
The CY operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.cz(control, target)[source]
Controlled-Z gate.
\[\begin{split}CZ &= |00\rangle\langle00|\\ &+ |01\rangle\langle01|\\ &+ |10\rangle\langle10|\\ &- |11\rangle\langle11|\\\end{split}\]- Parameters
- Returns
The CZ operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.cphase(control, target, phi)[source]
Controlled-phase gate.
\[\begin{split}C_\text{phase} &= |00\rangle\langle00|\\ &+ |01\rangle\langle01|\\ &+ |10\rangle\langle10|\\ &+ e^{i\varphi}|11\rangle\langle11|\\\end{split}\]- Parameters
- Returns
The Cphase operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.swap(qubit1, qubit2)[source]
SWAP gate.
\[\begin{split}\text{SWAP} &= |00\rangle\langle00|\\ &+ |01\rangle\langle10|\\ &+ |10\rangle\langle01|\\ &+ |11\rangle\langle11|\\\end{split}\]- Parameters
- Returns
The SWAP operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.swapphi(control, target, phi)[source]
SWAPphi gate.
\[\begin{split}\text{SWAP}_\varphi &= |00\rangle\langle00|\\ &+ ie^{-i\varphi}|01\rangle\langle10|\\ &- ie^{i\varphi}|10\rangle\langle01|\\ &+ |11\rangle\langle11|\\\end{split}\]Note
SWAPphi is only a “controlled” gate for certain values of \(\varphi\). For \(\varphi = n\pi + \frac{\pi}{2}\) the gate is symmetric with respect to qubit ordering.
- Parameters
- Returns
The SWAPphi operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.iswap(qubit1, qubit2)[source]
iSWAP gate.
\[\begin{split}i\text{SWAP} &= |00\rangle\langle00|\\ &+ i|01\rangle\langle10|\\ &+ i|10\rangle\langle01|\\ &+ |11\rangle\langle11|\\\end{split}\]- Parameters
- Returns
The iSWAP operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.eswap(control, target, theta_c, phi=1.5707963267948966)[source]
eSWAP gate.
\[\begin{split}e\text{SWAP}_\varphi(\theta_c) &= \exp(-i\theta_c/2\cdot\text{SWAP}\varphi)\\ &= \cos(\theta_c/2) I - i\sin(\theta_c/2)\text{SWAP}_\varphi\end{split}\]Note
eSWAP is only a “controlled” gate for certain values of \(\varphi\). For \(\varphi = n\pi + \frac{\pi}{2}\) the gate is symmetric with respect to qubit ordering.
- Parameters
- Returns
The eSWAP operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.sqrtswap(qubit1, qubit2)[source]
SqrtSWAP gate.
\[\sqrt{\text{SWAP}}\]- Parameters
- Returns
The SqrtSWAP operator.
- Return type
qutip.Qobj
See also
- sequencing.gates.sqrtiswap(qubit1, qubit2)[source]
SqrtiSWAP gate.
\[\sqrt{i\text{SWAP}}\]- Parameters
- Returns
The SqrtiSWAP operator.
- Return type
qutip.Qobj
See also
QASM
parse_qasm_gate
- sequencing.qasm.parse_qasm_gate(qasm_str)[source]
Parses a QASM string like
'u3(pi/2,0,pi)'
into the gate name'u3'
and a tuple of float arguments(np.pi/2, 0, np.pi/2)
.
Calibration
tune_rabi
- sequencing.calibration.tune_rabi(system, init_state, e_ops=None, mode_name='qubit', pulse_name=None, amp_range=(-2, 2, 51), progbar=True, plot=True, ax=None, ylabel=None, update=True, verify=True)[source]
Tune the amplitude of a Transmon pulse using an amplitude-Rabi experiment.
- Parameters
system (System) – System containing the Transmon whose pulse you want to tune.
init_state (qutip.Qobj) – Initial state of the system.
e_ops (optional, list[qutip.Qobj]) – List of expectation operators. If none, defaults to init_state. Default: None.
mode_name (optional, str) – Name of the Transmon mode. Default: ‘qubit’.
pulse_name (optional, str) – Name of the pulse to tune. If None, will use transmon.default_pulse. Default: None.
amp_range (optional, tuple[float, float, int]) – Range over which to sweep the pulse amplitude, specified by (start, stop, num_steps). The units are such that, if the pulse is tuned up, amplitude of 1 generates a rotation by pi. Default: (-2, 2, 51).
progbar (optional, bool) – Whether to display a tqdm progress bar. Default: True.
plot (optional, bool) – Whether to plot the results: Default: True.
ax (optional, matplotlib axis) – Axis on which to plot results. If None, one is automatically created. Default: None.
ylabel (optional, str) – ylabel for the plot. Default: None.
update (optional, bool) – Whether to update the pulse amplitude based on the fit result. Default: True.
verify (optional, bool) – Whether to re-run the Rabi sequence with the newly-determined amplitude to verify correctness. Default: True.
- Returns
(fig, ax), old_amp, new_amp
- Return type
tune_drag
- sequencing.calibration.tune_drag(system, init_state, e_ops=None, mode_name='qubit', pulse_name=None, drag_range=(-5, 5, 21), progbar=True, plot=True, ax=None, ylabel=None, update=True)[source]
Tune the DRAG coefficient for a Transmon pulse by executing Rx(pi) - Ry(pi/2) and Ry(pi) - Rx(pi/2) using different DRAG values.
- Parameters
system (System) – System containing the Transmon whose pulse you want to tune.
init_state (qutip.Qobj) – Initial state of the system.
e_ops (optional, list[qutip.Qobj]) – List of expectation operators. If None, defaults to init_state. Default: None.
mode_name (optional, str) – Name of the Cavity mode. Default: ‘qubit’.
pulse_name (optional, str) – Name of the pulse to tune. If None, will use qubit.default_pulse. Default: None.
drag_range (optional, tuple[float, float, int]) – Range over which to sweep the DRAG value, specified by (start, stop, num_steps). Default: (-5, 5, 21)
progbar (optional, bool) – Whether to display a tqdm progress bar. Default: True.
plot (optional, bool) – Whether to plot the results: Default: True.
ax (optional, matplotlib axis) – Axis on which to plot results. If None, one is automatically created. Default: None.
ylabel (optional, str) – ylabel for the plot. Default: None.
update (optional, bool) – Whether to update the DRAG value based on the fit result. Default: True.
- Returns
(fig, ax), old_drag, new_drag
- Return type
tune_displacement
- sequencing.calibration.tune_displacement(system, init_state, e_ops=None, mode_name='cavity', pulse_name=None, amp_range=(0.1, 3, 51), progbar=True, plot=True, ax=None, ylabel=None, update=True, verify=True)[source]
Tune the amplitude of a Cavity pulse using a displacement experiment.
- Parameters
system (System) – System containing the Cavity whose pulse you want to tune.
init_state (qutip.Qobj) – Initial state of the system.
e_ops (optional, list[qutip.Qobj]) – List of expectation operators. If None, defaults to init_state. Default: None.
mode_name (optional, str) – Name of the Cavity mode. Default: ‘cavity’.
pulse_name (optional, str) – Name of the pulse to tune. If None, will use cavity.default_pulse. Default: None.
amp_range (optional, tuple[float, float, int]) – Range over which to sweep the pulse amplitude, specified by (start, stop, num_steps). The units are such that, if the pulse is tuned up, amplitude of 1 generates a displacement of alpha = 1. Default: (0.1, 3, 51).
progbar (optional, bool) – Whether to display a tqdm progress bar. Default: True.
plot (optional, bool) – Whether to plot the results: Default: True.
ax (optional, matplotlib axis) – Axis on which to plot results. If None, one is automatically created. Default: None.
ylabel (optional, str) – ylabel for the plot. Default: None.
update (optional, bool) – Whether to update the pulse amplitude based on the fit result. Default: True.
verify (optional, bool) – Whether to re-run the sequence with the newly-determined amplitude to verify correctness. Default: True.
- Returns
(fig, ax), old_amp, new_amp
- Return type