Skip to content

Commit 9945db6

Browse files
Apply as_sweep for SqrtCZGauge (#6931)
Example usage: exec `parameterized_circuit, sweeps = self.gauge_transformer.as_sweep(input_circuit, N=5)` with input_circuit: ``` 0: ───H───@───────────────H───M─── │ 1: ───────@^0.5───@───────H───M─── │ 2: ───────────────@^0.5───H───M─── ``` output parameterized circuit is: ``` 0: ───H───PhXZ(a=a0,x=x0,z=z0)───@──────PhXZ(a=a2,x=x2,z=z2)────────────────────────────────────────────────────────H───M─── │ 1: ───────PhXZ(a=a1,x=x1,z=z1)───@^s0───PhXZ(a=a3,x=x3,z=z3)───PhXZ(a=a4,x=x4,z=z4)───@──────PhXZ(a=a6,x=x6,z=z6)───H───M─── │ 2: ────────────────────────────────────────────────────────────PhXZ(a=a5,x=x5,z=z5)───@^s1───PhXZ(a=a7,x=x7,z=z7)───H───M─── ``` randomly generalized sweeps ``` cirq.Points('x0', [0.0, 0.0, 0.0, 0.0, 0.0]) + cirq.Points('z0', [0.0, 0.0, 0.0, 0.0, 0.0]) + cirq.Points('a0', [0.0, 0.0, 0.0, 0.0, 0.0]) + cirq.Points('x1', [1, 0.0, 0.0, 1, 0.0]) + cirq.Points('z1', [0, 0.0, 0.0, 0, 0.0]) + cirq.Points('a1', [-1.0, 0.0, 0.0, -1.0, 0.0]) + cirq.Points('x2', [0.0, 0.0, 0.0, 0.0, 0.0]) + cirq.Points('z2', [0.5, 0.0, 0.0, 0.5, 0.0]) + cirq.Points('a2', [0.0, 0.0, 0.0, 0.0, 0.0]) + cirq.Points('x3', [1, 0.0, 0.0, 1, 0.0]) + cirq.Points('z3', [0, 0.0, 0.0, 0, 0.0]) + cirq.Points('a3', [-1.0, 0.0, 0.0, -1.0, 0.0]) + cirq.Points('x4', [1, 1, 0.0, 0.0, 0.0]) + cirq.Points('z4', [0, 0, 0.0, 0.0, 0.0]) + cirq.Points('a4', [-1.0, -1.0, 0.0, 0.0, 0.0]) + cirq.Points('x5', [0.0, 0.0, 0.0, 0.0, 1]) + cirq.Points('z5', [0.0, 0.0, 0.0, 0.0, 0]) + cirq.Points('a5', [0.0, 0.0, 0.0, 0.0, -1.0]) + cirq.Points('x6', [1, 1, 0.0, 0.0, 0.0]) + cirq.Points('z6', [0, 0, 0.0, 0.0, 0.5]) + cirq.Points('a6', [-1.0, -1.0, 0.0, 0.0, 0.0]) + cirq.Points('x7', [0.0, 0.0, 0.0, 0.0, 1]) + cirq.Points('z7', [0.5, 0.5, 0.0, 0.0, 0]) + cirq.Points('a7', [0.0, 0.0, 0.0, 0.0, -1.0]) + cirq.Points('s0', [-0.5, 0.5, 0.5, -0.5, 0.5]) + cirq.Points('s1', [-0.5, -0.5, 0.5, 0.5, -0.5]) ``` --------- Co-authored-by: Noureldin <[email protected]>
1 parent 55c592b commit 9945db6

13 files changed

+194
-221
lines changed

cirq-core/cirq/transformers/gauge_compiling/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
Gauge as Gauge,
1919
GaugeSelector as GaugeSelector,
2020
GaugeTransformer as GaugeTransformer,
21+
TwoQubitGateSymbolizer as TwoQubitGateSymbolizer,
2122
)
2223

2324
from cirq.transformers.gauge_compiling.sqrt_cz_gauge import (

cirq-core/cirq/transformers/gauge_compiling/cz_gauge.py

Lines changed: 16 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -24,134 +24,22 @@
2424

2525
CZGaugeSelector = GaugeSelector(
2626
gauges=[
27-
ConstantGauge(
28-
two_qubit_gate=CZ,
29-
pre_q0=ops.I,
30-
pre_q1=ops.I,
31-
post_q0=ops.I,
32-
post_q1=ops.I,
33-
support_sweep=True,
34-
),
35-
ConstantGauge(
36-
two_qubit_gate=CZ,
37-
pre_q0=ops.I,
38-
pre_q1=ops.X,
39-
post_q0=ops.Z,
40-
post_q1=ops.X,
41-
support_sweep=True,
42-
),
43-
ConstantGauge(
44-
two_qubit_gate=CZ,
45-
pre_q0=ops.I,
46-
pre_q1=ops.Y,
47-
post_q0=ops.Z,
48-
post_q1=ops.Y,
49-
support_sweep=True,
50-
),
51-
ConstantGauge(
52-
two_qubit_gate=CZ,
53-
pre_q0=ops.I,
54-
pre_q1=ops.Z,
55-
post_q0=ops.I,
56-
post_q1=ops.Z,
57-
support_sweep=True,
58-
),
59-
ConstantGauge(
60-
two_qubit_gate=CZ,
61-
pre_q0=ops.X,
62-
pre_q1=ops.I,
63-
post_q0=ops.X,
64-
post_q1=ops.Z,
65-
support_sweep=True,
66-
),
67-
ConstantGauge(
68-
two_qubit_gate=CZ,
69-
pre_q0=ops.X,
70-
pre_q1=ops.X,
71-
post_q0=ops.Y,
72-
post_q1=ops.Y,
73-
support_sweep=True,
74-
),
75-
ConstantGauge(
76-
two_qubit_gate=CZ,
77-
pre_q0=ops.X,
78-
pre_q1=ops.Y,
79-
post_q0=ops.Y,
80-
post_q1=ops.X,
81-
support_sweep=True,
82-
),
83-
ConstantGauge(
84-
two_qubit_gate=CZ,
85-
pre_q0=ops.X,
86-
pre_q1=ops.Z,
87-
post_q0=ops.X,
88-
post_q1=ops.I,
89-
support_sweep=True,
90-
),
91-
ConstantGauge(
92-
two_qubit_gate=CZ,
93-
pre_q0=ops.Y,
94-
pre_q1=ops.I,
95-
post_q0=ops.Y,
96-
post_q1=ops.Z,
97-
support_sweep=True,
98-
),
99-
ConstantGauge(
100-
two_qubit_gate=CZ,
101-
pre_q0=ops.Y,
102-
pre_q1=ops.X,
103-
post_q0=ops.X,
104-
post_q1=ops.Y,
105-
support_sweep=True,
106-
),
107-
ConstantGauge(
108-
two_qubit_gate=CZ,
109-
pre_q0=ops.Y,
110-
pre_q1=ops.Y,
111-
post_q0=ops.X,
112-
post_q1=ops.X,
113-
support_sweep=True,
114-
),
115-
ConstantGauge(
116-
two_qubit_gate=CZ,
117-
pre_q0=ops.Y,
118-
pre_q1=ops.Z,
119-
post_q0=ops.Y,
120-
post_q1=ops.I,
121-
support_sweep=True,
122-
),
123-
ConstantGauge(
124-
two_qubit_gate=CZ,
125-
pre_q0=ops.Z,
126-
pre_q1=ops.I,
127-
post_q0=ops.Z,
128-
post_q1=ops.I,
129-
support_sweep=True,
130-
),
131-
ConstantGauge(
132-
two_qubit_gate=CZ,
133-
pre_q0=ops.Z,
134-
pre_q1=ops.X,
135-
post_q0=ops.I,
136-
post_q1=ops.X,
137-
support_sweep=True,
138-
),
139-
ConstantGauge(
140-
two_qubit_gate=CZ,
141-
pre_q0=ops.Z,
142-
pre_q1=ops.Y,
143-
post_q0=ops.I,
144-
post_q1=ops.Y,
145-
support_sweep=True,
146-
),
147-
ConstantGauge(
148-
two_qubit_gate=CZ,
149-
pre_q0=ops.Z,
150-
pre_q1=ops.Z,
151-
post_q0=ops.Z,
152-
post_q1=ops.Z,
153-
support_sweep=True,
154-
),
27+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.I, pre_q1=ops.I, post_q0=ops.I, post_q1=ops.I),
28+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.I, pre_q1=ops.X, post_q0=ops.Z, post_q1=ops.X),
29+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.I, pre_q1=ops.Y, post_q0=ops.Z, post_q1=ops.Y),
30+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.I, pre_q1=ops.Z, post_q0=ops.I, post_q1=ops.Z),
31+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.X, pre_q1=ops.I, post_q0=ops.X, post_q1=ops.Z),
32+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.X, pre_q1=ops.X, post_q0=ops.Y, post_q1=ops.Y),
33+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.X, pre_q1=ops.Y, post_q0=ops.Y, post_q1=ops.X),
34+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.X, pre_q1=ops.Z, post_q0=ops.X, post_q1=ops.I),
35+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.Y, pre_q1=ops.I, post_q0=ops.Y, post_q1=ops.Z),
36+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.Y, pre_q1=ops.X, post_q0=ops.X, post_q1=ops.Y),
37+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.Y, pre_q1=ops.Y, post_q0=ops.X, post_q1=ops.X),
38+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.Y, pre_q1=ops.Z, post_q0=ops.Y, post_q1=ops.I),
39+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.Z, pre_q1=ops.I, post_q0=ops.Z, post_q1=ops.I),
40+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.Z, pre_q1=ops.X, post_q0=ops.I, post_q1=ops.X),
41+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.Z, pre_q1=ops.Y, post_q0=ops.I, post_q1=ops.Y),
42+
ConstantGauge(two_qubit_gate=CZ, pre_q0=ops.Z, pre_q1=ops.Z, post_q0=ops.Z, post_q1=ops.Z),
15543
]
15644
)
15745

0 commit comments

Comments
 (0)