Skip to content

Commit

Permalink
Merge pull request #176 from BBN-Q/feature/CR-tomo
Browse files Browse the repository at this point in the history
CR tomography and cancellation pulse
  • Loading branch information
matthewware committed Oct 1, 2018
2 parents a1e0249 + 996789c commit aebb371
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 9 deletions.
47 changes: 40 additions & 7 deletions QGL/BasicSequences/CR.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from ..PulseSequencePlotter import plot_pulse_files
from .helpers import create_cal_seqs, delay_descriptor, cal_descriptor
import numpy as np
from itertools import product

def PiRabi(controlQ,
targetQ,
Expand Down Expand Up @@ -56,7 +57,7 @@ def EchoCRLen(controlQ,
amp=1,
phase=0,
calRepeats=2,
showPlot=False):
showPlot=False, canc_amp=0, canc_phase=np.pi/2):
"""
Variable length CX experiment, with echo pulse sandwiched between two CR opposite-phase pulses.
Expand All @@ -72,14 +73,14 @@ def EchoCRLen(controlQ,
showPlot : whether to plot (boolean)
"""
seqs = [[Id(controlQ),
echoCR(controlQ, targetQ, length=l, phase=phase, amp=amp, riseFall=riseFall),
echoCR(controlQ, targetQ, length=l, phase=phase, amp=amp, riseFall=riseFall, canc_amp=canc_amp, canc_phase=canc_phase),
Id(controlQ),
MEAS(targetQ)*MEAS(controlQ)] for l in lengths] + \
[[X(controlQ),
echoCR(controlQ, targetQ, length=l, phase= phase, amp=amp, riseFall=riseFall),
echoCR(controlQ, targetQ, length=l, phase= phase, amp=amp, riseFall=riseFall, canc_amp=canc_amp, canc_phase=canc_phase),
X(controlQ),
MEAS(targetQ)*MEAS(controlQ)] for l in lengths] + \
create_cal_seqs((targetQ,controlQ), calRepeats, measChans=(targetQ,controlQ))
create_cal_seqs((targetQ,controlQ), calRepeats, measChans=(targetQ, controlQ))

metafile = compile_to_hardware(seqs, 'EchoCR/EchoCR',
axis_descriptor=[
Expand All @@ -100,7 +101,9 @@ def EchoCRPhase(controlQ,
amp=1,
length=100e-9,
calRepeats=2,
showPlot=False):
showPlot=False,
canc_amp=0,
canc_phase=np.pi/2):
"""
Variable phase CX experiment, with echo pulse sandwiched between two CR opposite-phase pulses.
Expand All @@ -116,11 +119,11 @@ def EchoCRPhase(controlQ,
showPlot : whether to plot (boolean)
"""
seqs = [[Id(controlQ),
echoCR(controlQ, targetQ, length=length, phase=ph, amp=amp, riseFall=riseFall),
echoCR(controlQ, targetQ, length=length, phase=ph, amp=amp, riseFall=riseFall, canc_amp=canc_amp, canc_phase=canc_phase),
X90(targetQ)*Id(controlQ),
MEAS(targetQ)*MEAS(controlQ)] for ph in phases] + \
[[X(controlQ),
echoCR(controlQ, targetQ, length=length, phase= ph, amp=amp, riseFall = riseFall),
echoCR(controlQ, targetQ, length=length, phase= ph, amp=amp, riseFall = riseFall, canc_amp=canc_amp, canc_phase=canc_phase),
X90(targetQ)*X(controlQ),
MEAS(targetQ)*MEAS(controlQ)] for ph in phases] + \
create_cal_seqs((targetQ,controlQ), calRepeats, measChans=(targetQ,controlQ))
Expand Down Expand Up @@ -192,3 +195,33 @@ def EchoCRAmp(controlQ,
plot_pulse_files(metafile)

return metafile

def CRtomo_seq(controlQ, targetQ, lengths, ph, amp=0.8, riseFall=20e-9):
"""
Variable length CX experiment, for Hamiltonian tomography.
Parameters
----------
controlQ : logical channel for the control qubit (LogicalChannel)
targetQ: logical channel for the target qubit (LogicalChannel)
lengths : pulse lengths of the CR pulse to sweep over (iterable)
riseFall : rise/fall time of the CR pulse (s)
ph : phase of the CR pulse (rad)
"""
CRchan = ChannelLibraries.EdgeFactory(controlQ, targetQ)
tomo_pulses = [Y90m, X90, Id]
seqs = [[Id(controlQ),
flat_top_gaussian(CRchan, amp=amp, riseFall=riseFall, length=l, phase=ph, label="CR"),
Id(controlQ)*tomo_pulse(targetQ),
MEAS(targetQ)] for l,tomo_pulse in product(lengths, tomo_pulses)] + \
[[X(controlQ),
flat_top_gaussian(CRchan, amp=amp, riseFall=riseFall, length=l, phase=ph, label="CR"),
X(controlQ)*tomo_pulse(targetQ),
MEAS(targetQ)] for l,tomo_pulse in product(lengths, tomo_pulses)] + \
create_cal_seqs((targetQ,), 2,)
metafile = compile_to_hardware(seqs, 'CR/CR',
axis_descriptor=[
delay_descriptor(np.concatenate((np.repeat(lengths,3), np.repeat(lengths,3)))),
cal_descriptor((targetQ,), 2)
])
return metafile
21 changes: 19 additions & 2 deletions QGL/PulsePrimitives.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ def echoCR(controlQ,
phase=0,
length=200e-9,
riseFall=20e-9,
lastPi=True):
lastPi=True, canc_amp = 0.0, canc_phase=np.pi/2):
"""
An echoed CR pulse. Used for calibration of CR gate
"""
Expand All @@ -668,6 +668,19 @@ def echoCR(controlQ,
length=length,
phase=phase + np.pi,
label="echoCR_second_half")]
if canc_amp != 0:
seq[0]*=flat_top_gaussian(targetQ,
amp=canc_amp,
riseFall=riseFall,
length=length,
phase=canc_phase,
label="cancCR_first_half")
seq[2]*=flat_top_gaussian(targetQ,
amp=canc_amp,
riseFall=riseFall,
length=length,
phase=canc_phase + np.pi,
label="cancCR_second_half")
if lastPi:
seq += [X(controlQ)]
return CompoundGate(seq)
Expand All @@ -679,12 +692,16 @@ def ZX90_CR(controlQ, targetQ, **kwargs):
"""
CRchan = ChannelLibraries.EdgeFactory(controlQ, targetQ)
params = overrideDefaults(CRchan, kwargs)
canc_amp = params['canc_amp'] if 'canc_amp' in params else 0
canc_phase = params['canc_phase'] if 'canc_phase' in params else 0
return echoCR(controlQ,
targetQ,
amp=params['amp'],
phase=params['phase'],
length=params['length'],
riseFall=params['riseFall'])
riseFall=params['riseFall'],
canc_phase=canc_phase,
canc_amp=canc_amp)


def CNOT_CR(controlQ, targetQ, **kwargs):
Expand Down

0 comments on commit aebb371

Please sign in to comment.