diff --git a/QGL/BasicSequences/CR.py b/QGL/BasicSequences/CR.py index d7e90821..e94cdda5 100644 --- a/QGL/BasicSequences/CR.py +++ b/QGL/BasicSequences/CR.py @@ -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, @@ -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. @@ -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=[ @@ -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. @@ -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)) @@ -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 diff --git a/QGL/PulsePrimitives.py b/QGL/PulsePrimitives.py index ef94fc98..59d48099 100644 --- a/QGL/PulsePrimitives.py +++ b/QGL/PulsePrimitives.py @@ -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 """ @@ -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) @@ -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):