@@ -58,6 +58,8 @@ def _pauli_up_to_global_phase(gate: ops.Gate) -> Union[ops.Pauli, None]:
58
58
def _validate_dd_sequence (dd_sequence : Tuple [ops .Gate , ...]) -> None :
59
59
"""Validates a given dynamical decoupling sequence.
60
60
61
+ The sequence should only consists of Pauli gates and is essentially an identity gate.
62
+
61
63
Args:
62
64
dd_sequence: Input dynamical sequence to be validated.
63
65
@@ -93,7 +95,7 @@ def _parse_dd_sequence(
93
95
_validate_dd_sequence (schema )
94
96
dd_sequence = schema
95
97
96
- # Map Gate to Puali gate. This is necessary as dd sequence might contain gates like X^-1.
98
+ # Map gate to Pauli gate. This is necessary as dd sequence might contain gates like X^-1.
97
99
pauli_map : Dict [ops .Gate , ops .Pauli ] = {}
98
100
for gate in dd_sequence :
99
101
pauli_gate = _pauli_up_to_global_phase (gate )
@@ -171,19 +173,13 @@ def _try_merge_single_qubit_ops_of_two_moments(
171
173
def _calc_pulled_through (
172
174
moment : circuits .Moment , input_pauli_ops : ops .PauliString
173
175
) -> ops .PauliString :
174
- """Calculates the pulled_through such that circuit(input_puali_ops , moment.clifford_ops) is
176
+ """Calculates the pulled_through such that circuit(input_pauli_ops , moment.clifford_ops) is
175
177
equivalent to circuit(moment.clifford_ops, pulled_through).
176
178
"""
177
179
clifford_ops_in_moment : list [ops .Operation ] = [
178
180
op for op in moment .operations if _is_clifford_op (op )
179
181
]
180
- # TODO(#6946): directly pass clifford_ops_in_moment to input_pauli_ops.after() after #6946 is
181
- # fixed.
182
- affected_qubits = [q for op in clifford_ops_in_moment for q in op .qubits ]
183
- all_cliffords_in_gate : ops .CliffordGate = ops .CliffordGate .from_op_list (
184
- clifford_ops_in_moment , affected_qubits
185
- )
186
- return input_pauli_ops .after (all_cliffords_in_gate .on (* affected_qubits ))
182
+ return input_pauli_ops .after (clifford_ops_in_moment )
187
183
188
184
189
185
def _get_stop_qubits (moment : circuits .Moment ) -> set [ops .Qid ]:
@@ -197,7 +193,7 @@ def _get_stop_qubits(moment: circuits.Moment) -> set[ops.Qid]:
197
193
198
194
199
195
def _need_merge_pulled_through (op_at_q : ops .Operation , is_at_last_busy_moment : bool ) -> bool :
200
- """With a pulling through puali gate before op_at_q, need to merge with the
196
+ """With a pulling through pauli gate before op_at_q, need to merge with the
201
197
pauli in the conditions below."""
202
198
# The op must be mergable and single-qubit
203
199
if not (_is_single_qubit_operation (op_at_q ) and has_unitary (op_at_q )):
@@ -234,7 +230,7 @@ def add_dynamical_decoupling(
234
230
235
231
busy_moment_range_by_qubit = _calc_busy_moment_range_of_each_qubit (orig_circuit )
236
232
237
- # Stores all the moments of the output circuit chronically
233
+ # Stores all the moments of the output circuit chronologically.
238
234
transformed_moments : list [circuits .Moment ] = []
239
235
# A PauliString stores the result of 'pulling' Pauli gates past each operations
240
236
# right before the current moment.
@@ -247,7 +243,7 @@ def _update_pulled_through(q: ops.Qid, insert_gate: ops.Gate) -> ops.Operation:
247
243
pulled_through *= pauli_map [insert_gate ].on (q )
248
244
return insert_gate .on (q )
249
245
250
- # Insert and pull remaining Puali ops through the whole circuit.
246
+ # Insert and pull remaining Pauli ops through the whole circuit.
251
247
# General ideas are
252
248
# * Pull through Clifford gates.
253
249
# * Stop at multi-qubit non-Clifford ops (and other non-mergable ops).
0 commit comments