Skip to content

Commit

Permalink
Fix decoupling with simultaneous CNOTs
Browse files Browse the repository at this point in the history
Keeping track of changes in this branch, more needs to be updated before
merging to develop
  • Loading branch information
Diego Ristè committed Jun 21, 2019
1 parent f9d00a4 commit 454c69b
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions QGL/PatternUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@
import hashlib, collections
import pickle
from copy import copy
from functools import reduce
import operator

from .PulseSequencer import Pulse, TAPulse, PulseBlock, CompositePulse, CompoundGate, align
from .PulsePrimitives import BLANK, X
from . import ControlFlow
from . import BlockLabel
from . import TdmInstructions
from . import ChannelLibraries
import QGL.drivers
from . import ChannelLibrary
from functools import reduce
import operator

def hash_pulse(shape):
return hashlib.sha1(shape.tostring()).hexdigest()
Expand Down Expand Up @@ -136,8 +137,12 @@ def apply_gating_constraints(chan, linkList):
# first pass consolidates entries
previousEntry = None
for ct,entry in enumerate(miniLL):
if isinstance(entry, (ControlFlow.ControlInstruction,
BlockLabel.BlockLabel)):
if isinstance(entry,
(ControlFlow.ControlInstruction, BlockLabel.BlockLabel,
TdmInstructions.CustomInstruction,
TdmInstructions.WriteAddrInstruction,
TdmInstructions.LoadCmpVramInstruction)):

if previousEntry:
gateSeq.append(previousEntry)
previousEntry = None
Expand Down Expand Up @@ -204,14 +209,12 @@ def add_digitizer_trigger(seqs):
trig_chan = chan.trig_chan
if not (hasattr(seq[ct], 'pulses') and
trig_chan in seq[ct].pulses.keys()):
seq[ct] *= TAPulse("TRIG", trig_chan,
trig_chan.pulse_params['length'], 1.0,
0.0, 0.0)
seq[ct] = align('left', seq[ct], TAPulse("TRIG", trig_chan, trig_chan.pulse_params['length'], 1.0, 0.0, 0.0))


def contains_measurement(entry):
"""
Determines if a LL entry contains a measurement
Determines if a LL entry contains a measurement (with a digitizer trigger)
"""
if hasattr(entry, 'label') and entry.label == "MEAS":
return True
Expand All @@ -232,10 +235,8 @@ def add_slave_trigger(seqs, slaveChan):
while ct < len(seq) - 1:
if isinstance(seq[ct], ControlFlow.Wait):
try:
seq[ct + 1] *= TAPulse("TRIG", slaveChan,
slaveChan.pulse_params['length'],
1.0, 0.0, 0.0)
except TypeError:
seq[ct + 1] = align('left', seq[ct + 1], TAPulse("TRIG", slaveChan, slaveChan.pulse_params['length'], 1.0, 0.0, 0.0))
except:
seq.insert(ct + 1, TAPulse("TRIG", slaveChan,
slaveChan.pulse_params['length'],
1.0, 0.0, 0.0))
Expand Down Expand Up @@ -354,7 +355,7 @@ def decouple_meas_pulses(seq, meas_qs, meas_decoupled_qs):
if isinstance(pulse, Pulse):
for qM in meas_qs:
#TODO: check if pulse block
if pulse.channel == ChannelLibrary.MeasFactory('M-%s' % qM.label):
if pulse.channel == ChannelLibraries.MeasFactory('M-%s' % qM.label):
#TODO: add arbitary shift of X from center
seq[k] = align(pulse *\
reduce(operator.mul, [X(q) for q in meas_decoupled_qs]))
Expand All @@ -367,5 +368,7 @@ def decouple_CR_pulses(seq, CR_qs, CR_decoupled_qs):
#for qsCR in CR_qs:
if isinstance(seq_el, CompoundGate):
for (k, pulse) in enumerate(seq_el.seq):
if any([pulse.channel == ChannelLibrary.EdgeFactory(*qsCR) for qsCR in CR_qs]):# and pulse.channel == seq_el.seq[k+2].channel:
if isinstance(pulse.channel, collections.abc.KeysView) and any([ChannelLibraries.EdgeFactory(*qsCR) in pulse.channel for qsCR in CR_qs]):
seq_el.seq[k+1] = reduce(operator.mul, [seq_el.seq[k+1]] + [X(q) for q in CR_decoupled_qs])
elif any([pulse.channel == ChannelLibraries.EdgeFactory(*qsCR) for qsCR in CR_qs]):# and pulse.channel == seq_el.seq[k+2].channel:
seq_el.seq[k+1] = reduce(operator.mul, [seq_el.seq[k+1]] + [X(q) for q in CR_decoupled_qs])

0 comments on commit 454c69b

Please sign in to comment.