Skip to content

Commit 6984ff4

Browse files
Leonardo RanzaniLeonardo Ranzani
Leonardo Ranzani
authored and
Leonardo Ranzani
committed
Pass generic entangling sequence function
1 parent 9292d7a commit 6984ff4

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

QGL/BasicSequences/RB.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ def TwoQubitRB(q1: Channels.LogicalChannel,
261261
cliff_type: str = 'std',
262262
showPlot: bool = False,
263263
suffix: str = "",
264-
add_cals: bool = True,parametric: bool = False) -> str:
264+
add_cals: bool = True,entangling_seq = None ) -> str:
265265
"""
266266
Two qubit randomized benchmarking using 90 and 180 single qubit generators
267267
and ZX90.
@@ -303,7 +303,7 @@ def TwoQubitRB(q1: Channels.LogicalChannel,
303303
seqsBis = []
304304
for seq in seqs:
305305
seqsBis.append(reduce(operator.add,
306-
[TwoQubitClifford(q2, q1, c, kind=cliff_type,parametric)
306+
[TwoQubitClifford(q2, q1, c, kind=cliff_type,entangling_seq)
307307
for c in seq]))
308308

309309
#Add the measurement to all sequences

QGL/Cliffords.py

+21-17
Original file line numberDiff line numberDiff line change
@@ -376,36 +376,40 @@ def Cx2(c1, c2, q1, q2, kind='std'):
376376
#Create the pulse block
377377
return seq1 * seq2
378378

379-
def entangling_seq(gate, q1, q2,parametric=False):
379+
def entangling_seq(gate, q1, q2):
380380
"""
381381
Helper function to create the entangling gate sequence
382382
"""
383-
if parametric==False:
384-
if gate == "CNOT":
385-
return ZX90_CR(q2, q1)
386-
elif gate == "iSWAP":
387-
return [ZX90_CR(q2, q1) , Y90m(q1) * Y90m(q2), ZX90_CR(q2, q1)]
388-
elif gate == "SWAP":
389-
return [ZX90_CR(q2, q1), Y90m(q1) * Y90m(q2), ZX90_CR(
383+
if gate == "CNOT":
384+
return ZX90_CR(q2, q1)
385+
elif gate == "iSWAP":
386+
return [ZX90_CR(q2, q1) , Y90m(q1) * Y90m(q2), ZX90_CR(q2, q1)]
387+
elif gate == "SWAP":
388+
return [ZX90_CR(q2, q1), Y90m(q1) * Y90m(q2), ZX90_CR(
390389
q2, q1), (X90(q1) + Y90m(q1)) * X90(q2), ZX90_CR(q2, q1)]
391-
else:
392-
if gate == "CNOT":
393-
return [X90(q1),Z90(q1)*Z90m(q2),iSWAP(q1,q2),X90(q2),iSWAP(q1,q2),Z90(q1)]
394-
elif gate == "iSWAP":
395-
return [iSWAP(q1,q2)]
396-
elif gate == "SWAP":
397-
return [X90(q1),Z90(q1) * Z90m(q2),iSWAP(q1,q2),X90(q2),iSWAP(q1,q2),Z90(q1),
390+
391+
def entangling_seq2(gate, q1, q2):
392+
393+
if gate == "CNOT":
394+
return [X90(q1),Z90(q1)*Z90m(q2),iSWAP(q1,q2),X90(q2),iSWAP(q1,q2),Z90(q1)]
395+
elif gate == "iSWAP":
396+
return [iSWAP(q1,q2)]
397+
elif gate == "SWAP":
398+
return [X90(q1),Z90(q1) * Z90m(q2),iSWAP(q1,q2),X90(q2),iSWAP(q1,q2),Z90(q1),
398399
Y90(q2),X(q2),Z90m(q1) * Z90m(q2),iSWAP(q1,q2),Y90(q1),X(q1)]
399400

400-
def TwoQubitClifford(q1, q2, cliffNum, kind='std',parametric=False):
401+
def TwoQubitClifford(q1, q2, cliffNum, kind='std',entangling_sequence = None):
401402

402403
if kind.upper() not in clifford_map.keys():
403404
raise ValueError(f"Unknown clifford type: must be one of {clifford.map.keys()}.")
404405

406+
if entangling_sequence == None:
407+
entangling_sequence = entangling_seq
408+
405409
c = C2Seqs[cliffNum]
406410
seq = [Cx2(c[0][0], c[0][1], q1, q2, kind=kind)]
407411
if c[1]:
408-
seq += entangling_seq(c[1], q1, q2,parametric)
412+
seq += entangling_sequence(c[1], q1, q2)
409413
if c[2]:
410414
seq += [Cx2(c[2][0], c[2][1], q1, q2, kind=kind)]
411415
return seq

0 commit comments

Comments
 (0)