Skip to content

Commit 7b81e72

Browse files
fix xgate in to_quirk (#1760)
xgate should be always X regardless of the value of `allow_global_phase`
1 parent fa5a8ec commit 7b81e72

2 files changed

Lines changed: 7 additions & 14 deletions

File tree

qualtran/rotation_synthesis/channels/channel.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -308,10 +308,7 @@ def to_quirk(self, fmt: str = "xz", allow_global_phase: bool = True) -> str:
308308
raise ValueError(f"to_quirk is not supported for correction of type {type(correction)}")
309309
rot = ctr.to_quirk(self.rotation.to_matrix(), fmt, allow_global_phase)
310310
cor = ctr.to_quirk(correction.to_matrix(), fmt, allow_global_phase)
311-
if allow_global_phase:
312-
xgate = '"X"'
313-
else:
314-
xgate = '{"id":"Rzft","arg":"-pi"}'
311+
xgate = '"X"'
315312
first_row = []
316313
second_row = []
317314
# CNOT

qualtran/rotation_synthesis/matrix/clifford_t_repr.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,11 @@ def _xz_sequence(
6161
if use_hs:
6262
cliffords.append(su2_ct.HSqrt2)
6363
cliffords.append(su2_ct.HSqrt2 @ su2_ct.SSqrt2)
64-
candidates = []
6564
pref = prv.removesuffix('*')
66-
for name, t in _T_list:
67-
if name.startswith(pref):
68-
continue
69-
for c in cliffords:
65+
for c in cliffords:
66+
for name, t in _T_list:
67+
if name.startswith(pref):
68+
continue
7069
new = c.adjoint() @ matrix
7170
new = t.adjoint() @ new
7271
new = new.scale_down()
@@ -76,11 +75,8 @@ def _xz_sequence(
7675
if seq is None:
7776
continue
7877
gates = cast(tuple[str, ...], c.gates)
79-
candidates.append(seq + (name,) + gates)
80-
break
81-
if not candidates:
82-
return None
83-
return min(candidates, key=len)
78+
return seq + (name,) + gates
79+
return None
8480

8581

8682
def to_sequence(matrix: su2_ct.SU2CliffordT, fmt: str = 'xyz') -> tuple[str, ...]:

0 commit comments

Comments
 (0)