Skip to content

Commit

Permalink
WIP: updating API docs. -MW
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewware committed Apr 3, 2020
1 parent 52955cc commit 43cabe2
Show file tree
Hide file tree
Showing 5 changed files with 276 additions and 101 deletions.
4 changes: 2 additions & 2 deletions QGL/BasicSequences/Decoupling.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def HahnEcho(qubit, pulseSpacings, periods=0, calRepeats=2, showPlot=False):
Parameters
----------
qubit : LogicalChannel
qubit : Channels.LogicalChannel
Logical channel to implement sequence
pulseSpacings : int iterable
Pulse spacings to sweep over; the t in 90-t-180-t-180 (iterable)
Expand Down Expand Up @@ -61,7 +61,7 @@ def CPMG(qubit, numPulses, pulseSpacing, calRepeats=2, showPlot=False):
Parameters
----------
qubit : LogicalChannel
qubit : Channels.LogicalChannel
Logical channel to implement sequence
numPulses : int iterable
Number of 180 pulses; should be even
Expand Down
39 changes: 26 additions & 13 deletions QGL/BasicSequences/FlipFlop.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,32 @@

def FlipFlop(qubit, dragParamSweep, maxNumFFs=10, showPlot=False):
"""
Flip-flop sequence (X90-X90m)**n to determine off-resonance or DRAG parameter optimization.
Parameters
----------
qubit : logical channel to implement sequence (LogicalChannel)
dragParamSweep : drag parameter values to sweep over (iterable)
maxNumFFs : maximum number of flip-flop pairs to do
showPlot : whether to plot (boolean)
Returns
-------
metafile : path to a json metafile with details about the sequences and paths to compiled machine files
Flip-flop sequence (X90-X90m)**n to determine off-resonance or DRAG
parameter optimization.
Parameters
----------
qubit : Channels.LogicalChannel
Logical channel to implement sequence
dragParamSweep : float iterable
Array-like drag parameter values to sweep over
maxNumFFs : int, optional
Maximum number of flip-flop pairs (default 10)
showPlot : bool, optional
Whether to plot (boolean)
Returns
-------
metafile : string
Path to a json metafile with details about the sequences and paths
to compiled machine files
Examples
--------
>>> mf = FlipFlop(q2, np.linspace(0.1,0.9))
Compiled 551 sequences.
>>> mf
'/path/to/exp/exp-meta.json'
"""

def flipflop_seqs(drag_scaling):
Expand Down
233 changes: 173 additions & 60 deletions QGL/BasicSequences/Rabi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,31 @@

def RabiAmp(qubit, amps, phase=0, showPlot=False):
"""
Variable amplitude Rabi nutation experiment.
Parameters
----------
qubit : logical channel to implement sequence (LogicalChannel)
amps : pulse amplitudes to sweep over (iterable)
phase : phase of the pulse (radians)
showPlot : whether to plot (boolean)
Returns
-------
metafile : path to a json metafile with details about the sequences and paths to compiled machine files
Variable amplitude Rabi nutation experiment.
Parameters
----------
qubit : Channels.LogicalChannel
Logical channel to implement sequence
amps : int/float iterable
Array-like iterable of amplitudes to sweep over. [-1, 1]
phase : float, optional
Phase of the Rabi pulse (radians). Default = 0
showPlot : boolean, optional
Whether to plot
Returns
-------
metafile : string
Path to a json metafile with details about the sequences and paths
to compiled machine files
Examples
--------
>>> mf = RabiAmp(q1, np.linspace(-1.0, 1.0, 101));
Compiled 101 sequences.
>>> mf
'/path/to/exp/exp-meta.json'
"""
seqs = [[Utheta(qubit, amp=amp, phase=phase), MEAS(qubit)] for amp in amps]

Expand All @@ -31,7 +43,9 @@ def RabiAmp(qubit, amps, phase=0, showPlot=False):
'partition': 1
}]

metafile = compile_to_hardware(seqs, 'Rabi/Rabi', axis_descriptor=axis_descriptor)
metafile = compile_to_hardware(seqs,
'Rabi/Rabi',
axis_descriptor=axis_descriptor)

if showPlot:
plot_pulse_files(metafile)
Expand All @@ -45,29 +59,45 @@ def RabiWidth(qubit,
shape_fun=QGL.PulseShapes.tanh,
showPlot=False):
"""
Variable pulse width Rabi nutation experiment.
Parameters
----------
qubit : logical channel to implement sequence (LogicalChannel)
widths : pulse widths to sweep over (iterable)
phase : phase of the pulse (radians, default = 0)
shape_fun : shape of pulse (function, default = PulseShapes.tanh)
showPlot : whether to plot (boolean)
Returns
-------
metafile : path to a json metafile with details about the sequences and paths to compiled machine files
Variable pulse width Rabi nutation experiment.
Parameters
----------
qubit : Channels.LogicalChannel
Logical channel to implement sequence
widths : int/float iterable
Lengths of the Rabi pulse to sweep through (seconds). 4 ns minimum.
phase : float, optional
Phase of the Rabi pulse (radians). Default = 0.
shape_fun : function, optional
Pulse shape to use for the RabiWidth experiments. Some useful ones are
avaliable in QGL.PulseShapes but you can write your own. See those in
QGL.PulseShapes for examples.
showPlot : boolean, optional
Whether to plot
Returns
-------
metafile : string
Path to a json metafile with details about the sequences and paths
to compiled machine files
Examples
--------
>>> mf = Rabiwidth(q1, np.linspace(20.0e-9, 2020.0e-9, 101));
Compiled 101 sequences.
>>> mf
'/path/to/exp/exp-meta.json'
"""
seqs = [[Utheta(qubit,
length=l,
amp=amp,
phase=phase,
shape_fun=shape_fun), MEAS(qubit)] for l in widths]

metafile = compile_to_hardware(seqs, 'Rabi/Rabi',
axis_descriptor=[delay_descriptor(widths)])
metafile = compile_to_hardware(seqs,
'Rabi/Rabi',
axis_descriptor=[delay_descriptor(widths)])

if showPlot:
plot_pulse_files(metafile)
Expand All @@ -82,26 +112,48 @@ def RabiAmp_NQubits(qubits,
docals=False,
calRepeats=2):
"""
Variable amplitude Rabi nutation experiment for an arbitrary number of qubits simultaneously
Parameters
----------
qubits : tuple of logical channels to implement sequence (LogicalChannel)
amps : pulse amplitudes to sweep over for all qubits (iterable)
phase : phase of the pulses (radians)
showPlot : whether to plot (boolean)
measChans : tuble of qubits to be measured (LogicalChannel)
docals, calRepeats: enable calibration sequences, repeated calRepeats times
Returns
-------
metafile : path to a json metafile with details about the sequences and paths to compiled machine files
Variable amplitude Rabi nutation experiment for an arbitrary number of
qubits simultaneously
Parameters
----------
qubits : Channels.LogicalChannel tupple
A hashable (immutable) tupple of qubits for the Rabi experiment
amps : int/float iterable
Array-like iterable of amplitudes to sweep over. [-1, 1]
phase : float, optional
Phase of the Rabi pulse (radians). Default = 0
showPlot : boolean, optional
Whether to plot
measChans : Channels.LogicalChannel tupple, optional
A hashable (immutable) tupple of qubits to measured.
docals : boolean, optional
Whether to append calibration pulses to the end of the sequence
calRepeats : int, optional
How many times to repeat calibration scalings (default 2)
Returns
-------
metafile : string
Path to a json metafile with details about the sequences and paths
to compiled machine files
Examples
--------
>>> mf = RabiAmp_NQubits((q1,q2), np.linspace(-1.0, 1.0, 101));
Compiled 101 sequences.
>>> mf
'/path/to/exp/exp-meta.json'
"""
if measChans is None:
measChans = qubits

measBlock = reduce(operator.mul, [MEAS(q) for q in measChans])
if shape_fun:
seqs = [[reduce(operator.mul,
[Utheta(q, amp=amp, phase=phase, shape_fun) for q in qubits]),
measBlock] for amp in amps]
else:
seqs = [[reduce(operator.mul,
[Utheta(q, amp=amp, phase=phase) for q in qubits]),
measBlock] for amp in amps]
Expand Down Expand Up @@ -131,19 +183,34 @@ def RabiAmp_NQubits(qubits,

def RabiAmpPi(qubit, mqubit, amps, phase=0, showPlot=False):
"""
Variable amplitude Rabi nutation experiment.
Parameters
----------
qubit : logical channel to implement sequence (LogicalChannel)
amps : pulse amplitudes to sweep over (iterable)
phase : phase of the pulse (radians)
showPlot : whether to plot (boolean)
Returns
-------
metafile : path to a json metafile with details about the sequences and paths to compiled machine files
Variable amplitude Rabi nutation experiment with the state of a second,
spectator qubit flipped for the duration of the Rabi pulse.
Parameters
----------
qubit : Channels.LogicalChannel
Logical channel for Rabi pulse
mqubit : Channels.LogicalChannel
Logical channel to invert for the Rabi pulse duration
amps : int/float iterable
Array-like iterable of amplitudes to sweep over. [-1, 1]
phase : float, optional
Phase of the Rabi pulse (radians). Default = 0
showPlot : boolean, optional
Whether to plot
Returns
-------
metafile : string
Path to a json metafile with details about the sequences and paths
to compiled machine files
Examples
--------
>>> mf = RabiAmpPi(q1, q2, np.linspace(-1.0, 1.0, 101));
Compiled 101 sequences.
>>> mf
'/path/to/exp/exp-meta.json'
"""
seqs = [[X(mqubit), Utheta(qubit, amp=amp, phase=phase), X(mqubit),
MEAS(mqubit)] for amp in amps]
Expand All @@ -155,7 +222,9 @@ def RabiAmpPi(qubit, mqubit, amps, phase=0, showPlot=False):
'partition': 1
}]

metafile = compile_to_hardware(seqs, 'Rabi/Rabi', axis_descriptor=axis_descriptor)
metafile = compile_to_hardware(seqs,
'Rabi/Rabi',
axis_descriptor=axis_descriptor)

if showPlot:
plot_pulse_files(metafile)
Expand All @@ -164,7 +233,29 @@ def RabiAmpPi(qubit, mqubit, amps, phase=0, showPlot=False):

def SingleShot(qubit, showPlot=False):
"""
2-segment sequence with qubit prepared in |0> and |1>, useful for single-shot fidelity measurements and kernel calibration
2-segment sequence with qubit prepared in |0> and |1>, useful for
single-shot fidelity measurements and kernel calibration. It produces a
simple sequence of [[Id(qubit), MEAS(qubit)], [X(qubit), MEAS(qubit)]]
Parameters
----------
qubit : Channels.LogicalChannel
Logical channel to apply single-shot sequence
showPlot : boolean, optional
Whether to plot
Returns
-------
metafile : string
Path to a json metafile with details about the sequences and paths
to compiled machine files
Examples
--------
>>> mf = SingleShot(q1);
Compiled 1 sequences.
>>> mf
'/path/to/exp/exp-meta.json'
"""
seqs = [[Id(qubit), MEAS(qubit)], [X(qubit), MEAS(qubit)]]

Expand All @@ -185,6 +276,28 @@ def SingleShot(qubit, showPlot=False):
def PulsedSpec(qubit, specOn=True, showPlot=False):
"""
Measurement preceded by a qubit pulse if specOn = True
Parameters
----------
qubit : Channels.LogicalChannel
Logical channel to apply single-shot sequence
specon : boolean, optional
Toggles the spectroscopy pulse on and off. Default = True
showPlot : boolean, optional
Whether to plot
Returns
-------
metafile : string
Path to a json metafile with details about the sequences and paths
to compiled machine files
Examples
--------
>>> mf = PulsedSpec(q1);
Compiled 1 sequences.
>>> mf
'/path/to/exp/exp-meta.json'
"""
qPulse = X(qubit) if specOn else Id(qubit)
seqs = [[qPulse, MEAS(qubit)]]
Expand Down
Loading

0 comments on commit 43cabe2

Please sign in to comment.