Skip to content

Commit eed160f

Browse files
Leonardo RanzaniLeonardo Ranzani
Leonardo Ranzani
authored and
Leonardo Ranzani
committed
Added ability to select native swap entangling gates for RB
1 parent 6cf1e51 commit eed160f

File tree

2 files changed

+33
-33
lines changed

2 files changed

+33
-33
lines changed

QGL/BasicSequences/RB.py

+31-31
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ def create_RB_seqs(numQubits: int,
9191

9292
return seqs
9393

94-
def SingleQubitRB(qubit: Channels.LogicalChannel,
95-
seqs: List[List[int]],
94+
def SingleQubitRB(qubit: Channels.LogicalChannel,
95+
seqs: List[List[int]],
9696
cliff_type: str = 'std',
9797
purity: bool = False,
9898
showPlot: bool = False,
@@ -166,10 +166,10 @@ def SingleQubitRB(qubit: Channels.LogicalChannel,
166166
plot_pulse_files(metafile)
167167
return metafile
168168

169-
def SingleQubitLeakageRB(qubit: Channels.LogicalChannel,
169+
def SingleQubitLeakageRB(qubit: Channels.LogicalChannel,
170170
seqs: List[List[int]],
171-
pi2args: Mapping[int, str],
172-
cliff_type: str = 'std',
171+
pi2args: Mapping[int, str],
172+
cliff_type: str = 'std',
173173
showPlot: bool = False) -> str:
174174
"""
175175
Single qubit randomized benchmarking using 90 and 180 generators to
@@ -254,14 +254,14 @@ def SingleQubitLeakageRB(qubit: Channels.LogicalChannel,
254254

255255

256256

257-
def TwoQubitRB(q1: Channels.LogicalChannel,
258-
q2: Channels.LogicalChannel,
259-
seqs: List[List[int]],
257+
def TwoQubitRB(q1: Channels.LogicalChannel,
258+
q2: Channels.LogicalChannel,
259+
seqs: List[List[int]],
260260
meas_qubits: Iterable[Channels.LogicalChannel] = None,
261261
cliff_type: str = 'std',
262262
showPlot: bool = False,
263263
suffix: str = "",
264-
add_cals: bool = True) -> str:
264+
add_cals: bool = True,swap: bool = False) -> 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)
306+
[TwoQubitClifford(q2, q1, c, kind=cliff_type,swap)
307307
for c in seq]))
308308

309309
#Add the measurement to all sequences
@@ -324,22 +324,22 @@ def TwoQubitRB(q1: Channels.LogicalChannel,
324324
seqsBis += create_cal_seqs((q1, q2), 2, measChans = meas_qubits)
325325
axis_descriptor.append(cal_descriptor((q1, q2), 2))
326326

327-
metafile = compile_to_hardware(seqsBis, 'RB/RB',
328-
axis_descriptor = axis_descriptor,
329-
suffix = suffix,
327+
metafile = compile_to_hardware(seqsBis, 'RB/RB',
328+
axis_descriptor = axis_descriptor,
329+
suffix = suffix,
330330
extra_meta = {'sequences':seqs})
331331

332332
if showPlot:
333333
plot_pulse_files(metafile)
334334
return metafile
335335

336-
def TwoQubitLeakageRB(q1: Channels.LogicalChannel,
337-
q2: Channels.LogicalChannel,
338-
meas_qubit: Iterable[Channels.LogicalChannel],
339-
seqs: List[List[int]],
340-
pi2args: Mapping[int, str],
341-
cliff_type: str = 'std',
342-
showPlot: bool = False) -> str:
336+
def TwoQubitLeakageRB(q1: Channels.LogicalChannel,
337+
q2: Channels.LogicalChannel,
338+
meas_qubit: Iterable[Channels.LogicalChannel],
339+
seqs: List[List[int]],
340+
pi2args: Mapping[int, str],
341+
cliff_type: str = 'std',
342+
showPlot: bool = False,swap: bool = False) -> str:
343343
"""
344344
Two qubit randomized benchmarking using 90 and 180 single qubit generators
345345
and ZX90 to measure leakage outside the qubit subspace. See https://
@@ -381,7 +381,7 @@ def TwoQubitLeakageRB(q1: Channels.LogicalChannel,
381381
seqsBis = []
382382
for seq in seqs:
383383
combined_seq = reduce(operator.add,
384-
[TwoQubitClifford(q2, q1, c, kind=cliff_type)
384+
[TwoQubitClifford(q2, q1, c, kind=cliff_type,swap)
385385
for c in seq])
386386

387387
# Append sequence with tomography ids and measurement
@@ -391,11 +391,11 @@ def TwoQubitLeakageRB(q1: Channels.LogicalChannel,
391391
seqsBis.append(combined_seq + [X90(meas_qubit), X90(meas_qubit), MEAS(meas_qubit)])
392392

393393
# Add the calibration sequences
394-
seqsBis.append([Id(meas_qubit), Id(meas_qubit), Id(meas_qubit),
394+
seqsBis.append([Id(meas_qubit), Id(meas_qubit), Id(meas_qubit),
395395
Id(meas_qubit), MEAS(meas_qubit)])
396-
seqsBis.append([X90(meas_qubit), X90(meas_qubit), Id(meas_qubit),
396+
seqsBis.append([X90(meas_qubit), X90(meas_qubit), Id(meas_qubit),
397397
Id(meas_qubit), MEAS(meas_qubit)])
398-
seqsBis.append([X90(meas_qubit), X90(meas_qubit), X90(meas_qubit, **pi2args),
398+
seqsBis.append([X90(meas_qubit), X90(meas_qubit), X90(meas_qubit, **pi2args),
399399
X90(meas_qubit, **pi2args), MEAS(meas_qubit)])
400400

401401
axis_descriptor = [
@@ -421,10 +421,10 @@ def TwoQubitLeakageRB(q1: Channels.LogicalChannel,
421421
plot_pulse_files(metafile)
422422
return metafile
423423

424-
def SimultaneousRB(qubits: Iterable[Channels.LogicalChannel],
425-
seqs: List[List[int]],
426-
showPlot: bool = False,
427-
cliff_type: str = 'std',
424+
def SimultaneousRB(qubits: Iterable[Channels.LogicalChannel],
425+
seqs: List[List[int]],
426+
showPlot: bool = False,
427+
cliff_type: str = 'std',
428428
add_cals: bool = True) -> str:
429429
"""
430430
Simultaneous randomized benchmarking on multiple qubits.
@@ -493,7 +493,7 @@ def SimultaneousRB(qubits: Iterable[Channels.LogicalChannel],
493493
######################### Depricated ##########################################
494494
###############################################################################
495495

496-
# from stackoverflow:
496+
# from stackoverflow:
497497
# https://stackoverflow.com/questions/287871/how-to-print-colored-text-in-python
498498
class bcolors:
499499
HEADER = '\033[95m'
@@ -687,7 +687,7 @@ def SingleQubitIRB_AC(qubit, seqFile, showPlot=False):
687687
>>> mf
688688
'/path/to/exp/exp-meta.json'
689689
"""
690-
690+
691691
# warn the user
692692
deprication(unmaintained_str)
693693

@@ -755,7 +755,7 @@ def SingleQubitRBT(qubit,
755755
to compiled machine files
756756
"""
757757
#Setup a pulse library
758-
758+
759759
# warn the user
760760
deprication(unmaintained_str)
761761

QGL/Cliffords.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,15 @@ def entangling_seq(gate, q1, q2,swap=False):
397397
return [X90(q1),Z90(q1) * Z90m(q2),iSWAP(q1,q2),X90(q2),iSWAP(q1,q2),Z90(q1),
398398
Y90(q2),X(q2),Z90m(q1) * Z90m(q2),iSWAP(q1,q2),Y90(q1),X(q1)]
399399

400-
def TwoQubitClifford(q1, q2, cliffNum, kind='std'):
400+
def TwoQubitClifford(q1, q2, cliffNum, kind='std',swap=False):
401401

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

405405
c = C2Seqs[cliffNum]
406406
seq = [Cx2(c[0][0], c[0][1], q1, q2, kind=kind)]
407407
if c[1]:
408-
seq += entangling_seq(c[1], q1, q2)
408+
seq += entangling_seq(c[1], q1, q2,swap)
409409
if c[2]:
410410
seq += [Cx2(c[2][0], c[2][1], q1, q2, kind=kind)]
411411
return seq

0 commit comments

Comments
 (0)