Skip to content

Commit 413aee6

Browse files
authored
Fix #2961: add basic docstring to clifford_optimized_circuit() (#7663)
This adds a basic documentation string to the function `clifford_optimized_circuit()` in the file `cirq-core/cirq/contrib/paulistring/clifford_optimize.py`.
1 parent cd89c1f commit 413aee6

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

cirq-core/cirq/contrib/paulistring/clifford_optimize.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,26 @@
2121

2222

2323
def clifford_optimized_circuit(circuit: circuits.Circuit, atol: float = 1e-8) -> circuits.Circuit:
24-
# Convert to a circuit with SingleQubitCliffordGates,
25-
# CZs and other ignored gates
24+
"""Optimizes a circuit composed of Clifford and CZ gates.
25+
26+
This function attempts to simplify a circuit by finding local optimizations.
27+
It works in two stages:
28+
1. It converts the circuit to a target gateset consisting of
29+
`cirq.SingleQubitCliffordGate` and `cirq.CZPowGate` gates.
30+
2. It then iterates through the circuit, applying the following rules:
31+
- Merges adjacent single-qubit Clifford gates.
32+
- Commutes single-qubit Clifford gates past CZ gates, attempting to
33+
merge them with other single-qubit Clifford gates.
34+
- Cancels pairs of identical CZ gates.
35+
36+
Args:
37+
circuit: The circuit to optimize.
38+
atol: A limit on the amount of absolute error introduced by the decomposition.
39+
40+
Returns:
41+
The optimized circuit.
42+
"""
43+
# Convert to a circuit with SingleQubitCliffordGates, CZs and other ignored gates.
2644
c_cliff = transformers.optimize_for_target_gateset(
2745
circuit, gateset=CliffordTargetGateset(atol=atol)
2846
)

0 commit comments

Comments
 (0)