cirq-core 1.7.0.dev20250917002151__py3-none-any.whl → 1.7.0.dev20250917023732__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cirq-core might be problematic. Click here for more details.
- cirq/_version.py +1 -1
- cirq/_version_test.py +1 -1
- cirq/transformers/gauge_compiling/__init__.py +5 -0
- cirq/transformers/gauge_compiling/idle_moments_gauge.py +222 -0
- cirq/transformers/gauge_compiling/idle_moments_gauge_test.py +193 -0
- {cirq_core-1.7.0.dev20250917002151.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/METADATA +1 -1
- {cirq_core-1.7.0.dev20250917002151.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/RECORD +10 -8
- {cirq_core-1.7.0.dev20250917002151.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/WHEEL +0 -0
- {cirq_core-1.7.0.dev20250917002151.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.7.0.dev20250917002151.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
|
@@ -42,3 +42,8 @@ from cirq.transformers.gauge_compiling.sqrt_iswap_gauge import (
|
|
|
42
42
|
from cirq.transformers.gauge_compiling.cphase_gauge import (
|
|
43
43
|
CPhaseGaugeTransformer as CPhaseGaugeTransformer,
|
|
44
44
|
)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
from cirq.transformers.gauge_compiling.idle_moments_gauge import (
|
|
48
|
+
IdleMomentsGauge as IdleMomentsGauge,
|
|
49
|
+
)
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Copyright 2025 The Cirq Developers
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import functools
|
|
17
|
+
from typing import Hashable, Iterator, Sequence, TYPE_CHECKING
|
|
18
|
+
|
|
19
|
+
import attrs
|
|
20
|
+
import numpy as np
|
|
21
|
+
|
|
22
|
+
import cirq.circuits as circuits
|
|
23
|
+
import cirq.ops as ops
|
|
24
|
+
import cirq.protocols as protocols
|
|
25
|
+
import cirq.transformers.transformer_api as transformer_api
|
|
26
|
+
|
|
27
|
+
if TYPE_CHECKING:
|
|
28
|
+
import cirq
|
|
29
|
+
|
|
30
|
+
_PAULIS: tuple[cirq.Gate, ...] = (ops.I, ops.X, ops.Y, ops.Z) # type: ignore[has-type]
|
|
31
|
+
_CLIFFORDS = tuple(ops.SingleQubitCliffordGate.all_single_qubit_cliffords)
|
|
32
|
+
_INV_CLIFFORDS = tuple(c**-1 for c in ops.SingleQubitCliffordGate.all_single_qubit_cliffords)
|
|
33
|
+
|
|
34
|
+
_NAME_TO_GATES = {'pauli': _PAULIS, 'clifford': _CLIFFORDS, 'inv_clifford': _INV_CLIFFORDS}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def _gauges_arg_converter(gauges: str | Sequence[cirq.Gate] = 'clifford') -> tuple[cirq.Gate, ...]:
|
|
38
|
+
if isinstance(gauges, str):
|
|
39
|
+
if gauges not in _NAME_TO_GATES:
|
|
40
|
+
valid_names = tuple(_NAME_TO_GATES.keys())
|
|
41
|
+
raise ValueError(f"{gauges} is not a valid gauge name, valid names are {valid_names}")
|
|
42
|
+
return _NAME_TO_GATES[gauges]
|
|
43
|
+
return tuple(gauges)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _repr_fn(gauges: tuple[cirq.Gate, ...]) -> str:
|
|
47
|
+
if gauges is _PAULIS or gauges == _PAULIS:
|
|
48
|
+
return '"pauli"'
|
|
49
|
+
if gauges is _CLIFFORDS or gauges == _CLIFFORDS:
|
|
50
|
+
return '"clifford"'
|
|
51
|
+
if gauges is _INV_CLIFFORDS or gauges == _INV_CLIFFORDS:
|
|
52
|
+
return '"inv_clifford"'
|
|
53
|
+
return repr(gauges)
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
def _get_structure(
|
|
57
|
+
active: list[tuple[int, bool]],
|
|
58
|
+
min_length: int,
|
|
59
|
+
n: int,
|
|
60
|
+
gauge_beginning: bool,
|
|
61
|
+
gauge_ending: bool,
|
|
62
|
+
) -> Iterator[tuple[int, int]]:
|
|
63
|
+
if gauge_beginning:
|
|
64
|
+
stop, is_mergable = active[0]
|
|
65
|
+
if min_length <= stop:
|
|
66
|
+
if is_mergable:
|
|
67
|
+
yield (0, stop)
|
|
68
|
+
else:
|
|
69
|
+
yield (0, stop - 1)
|
|
70
|
+
|
|
71
|
+
for i in range(len(active) - 1):
|
|
72
|
+
left_pos, left_is_mergable = active[i]
|
|
73
|
+
right_pos, right_is_mergable = active[i + 1]
|
|
74
|
+
if right_pos - left_pos - 1 >= min_length:
|
|
75
|
+
yield (left_pos + 1 - left_is_mergable, right_pos - 1 + right_is_mergable)
|
|
76
|
+
|
|
77
|
+
if gauge_ending:
|
|
78
|
+
stop, is_mergable = active[-1]
|
|
79
|
+
if min_length <= n - stop - 1:
|
|
80
|
+
if is_mergable:
|
|
81
|
+
yield (stop, n - 1)
|
|
82
|
+
else:
|
|
83
|
+
yield (stop + 1, n - 1)
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def _merge(g1: cirq.Gate, g2: cirq.Gate, q: cirq.Qid, tags: Sequence[Hashable]) -> cirq.Operation:
|
|
87
|
+
u1 = protocols.unitary(g1)
|
|
88
|
+
u2 = protocols.unitary(g2)
|
|
89
|
+
return ops.PhasedXZGate.from_matrix(u2 @ u1)(q).with_tags(*tags)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
@transformer_api.transformer
|
|
93
|
+
@attrs.frozen
|
|
94
|
+
class IdleMomentsGauge:
|
|
95
|
+
r"""A transformer that inserts identity-preserving "gauge" gates around idle qubit moments.
|
|
96
|
+
|
|
97
|
+
This transformer identifies sequences of consecutive idle moments on a single qubit
|
|
98
|
+
that meet a `min_length` threshold. For each such sequence, it inserts a randomly
|
|
99
|
+
selected gate `G` from `gauges` at the start of the idle period and its inverse `G^-1`
|
|
100
|
+
at the end. This ensures the logical circuit behavior remains unchanged ($G \cdot G^{-1} = I$).
|
|
101
|
+
|
|
102
|
+
The primary goal is to introduce specific structure into idle periods, which is
|
|
103
|
+
useful for experiments.
|
|
104
|
+
|
|
105
|
+
Attributes:
|
|
106
|
+
min_length: Minimum number of consecutive idle moments for a gauge to be applied (>= 1).
|
|
107
|
+
|
|
108
|
+
gauges: A sequence of `cirq.Gate` objects to randomly select from.
|
|
109
|
+
Can be a custom tuple or a string alias:
|
|
110
|
+
- `"pauli"`: Uses single-qubit Pauli gates (I, X, Y, Z).
|
|
111
|
+
- `"clifford"`: Uses all 24 single-qubit Clifford gates.
|
|
112
|
+
|
|
113
|
+
gauge_beginning: If `True`, applies a gauge to idle moments at the circuit's start,
|
|
114
|
+
before any other qubit operation. Defaults to `False`.
|
|
115
|
+
|
|
116
|
+
gauge_ending: If `True`, applies a gauge to idle moments at the circuit's end,
|
|
117
|
+
after the last qubit operation. Defaults to `False`.
|
|
118
|
+
"""
|
|
119
|
+
|
|
120
|
+
min_length: int = attrs.field(
|
|
121
|
+
validator=(attrs.validators.instance_of(int), attrs.validators.ge(1))
|
|
122
|
+
)
|
|
123
|
+
gauges: tuple[cirq.Gate, ...] = attrs.field(
|
|
124
|
+
default='clifford', converter=_gauges_arg_converter, repr=_repr_fn
|
|
125
|
+
)
|
|
126
|
+
gauge_beginning: bool = False
|
|
127
|
+
gauge_ending: bool = False
|
|
128
|
+
|
|
129
|
+
@functools.cached_property
|
|
130
|
+
def gauges_inverse(self) -> tuple[cirq.Gate, ...]:
|
|
131
|
+
if self.gauges is _PAULIS:
|
|
132
|
+
return _PAULIS
|
|
133
|
+
if self.gauges is _CLIFFORDS:
|
|
134
|
+
return _INV_CLIFFORDS
|
|
135
|
+
if self.gauges is _INV_CLIFFORDS:
|
|
136
|
+
return _CLIFFORDS
|
|
137
|
+
return tuple(g**-1 for g in self.gauges)
|
|
138
|
+
|
|
139
|
+
def __call__(
|
|
140
|
+
self,
|
|
141
|
+
circuit: cirq.AbstractCircuit,
|
|
142
|
+
*,
|
|
143
|
+
context: transformer_api.TransformerContext | None = None,
|
|
144
|
+
rng_or_seed: np.random.Generator | int | None = None,
|
|
145
|
+
):
|
|
146
|
+
"""Apply the IdleMomentGauge transformer.
|
|
147
|
+
|
|
148
|
+
Args:
|
|
149
|
+
circuit: The circuit to process.
|
|
150
|
+
context: The TransformerContext.
|
|
151
|
+
rng_or_seed: The source of randomness.
|
|
152
|
+
|
|
153
|
+
Returns:
|
|
154
|
+
A transformed circuit.
|
|
155
|
+
|
|
156
|
+
Raises:
|
|
157
|
+
ValueError: if the TransformerContext has deep=True.
|
|
158
|
+
"""
|
|
159
|
+
rng = (
|
|
160
|
+
rng_or_seed
|
|
161
|
+
if isinstance(rng_or_seed, np.random.Generator)
|
|
162
|
+
else np.random.default_rng(rng_or_seed)
|
|
163
|
+
)
|
|
164
|
+
context = (
|
|
165
|
+
context
|
|
166
|
+
if isinstance(context, transformer_api.TransformerContext)
|
|
167
|
+
else transformer_api.TransformerContext(deep=False)
|
|
168
|
+
)
|
|
169
|
+
if context.deep:
|
|
170
|
+
raise ValueError("IdleMomentsGauge doesn't support deep TransformerContext")
|
|
171
|
+
|
|
172
|
+
tags_to_ignore = frozenset(context.tags_to_ignore)
|
|
173
|
+
all_qubits = circuit.all_qubits()
|
|
174
|
+
|
|
175
|
+
active_moments: dict[cirq.Qid, list[tuple[int, bool]]] = {q: [] for q in all_qubits}
|
|
176
|
+
for m_id, moment in enumerate(circuit):
|
|
177
|
+
if not tags_to_ignore.isdisjoint(moment.tags):
|
|
178
|
+
for q in all_qubits:
|
|
179
|
+
active_moments[q].append((m_id, False))
|
|
180
|
+
else:
|
|
181
|
+
for op in moment:
|
|
182
|
+
is_mergable = (
|
|
183
|
+
len(op.qubits) == 1
|
|
184
|
+
and tags_to_ignore.isdisjoint(op.tags)
|
|
185
|
+
and op.gate is not None
|
|
186
|
+
)
|
|
187
|
+
for q in op.qubits:
|
|
188
|
+
active_moments[q].append((m_id, is_mergable))
|
|
189
|
+
|
|
190
|
+
single_qubit_moments = [{q: op for op in m if len(op.qubits) == 1} for m in circuit]
|
|
191
|
+
non_single_qubit_moments = [[op for op in m if len(op.qubits) != 1] for m in circuit]
|
|
192
|
+
|
|
193
|
+
for q, active in active_moments.items():
|
|
194
|
+
for s, e in _get_structure(
|
|
195
|
+
active, self.min_length, len(circuit), self.gauge_beginning, self.gauge_ending
|
|
196
|
+
):
|
|
197
|
+
gate_index = rng.choice(len(self.gauges))
|
|
198
|
+
gate = self.gauges[gate_index]
|
|
199
|
+
gate_inv = self.gauges_inverse[gate_index]
|
|
200
|
+
|
|
201
|
+
if existing_op := single_qubit_moments[s].get(q, None):
|
|
202
|
+
existing_gate = existing_op.gate
|
|
203
|
+
assert existing_gate is not None
|
|
204
|
+
single_qubit_moments[s][q] = _merge(existing_gate, gate, q, existing_op.tags)
|
|
205
|
+
else:
|
|
206
|
+
single_qubit_moments[s][q] = gate(q)
|
|
207
|
+
|
|
208
|
+
if existing_op := single_qubit_moments[e].get(q, None):
|
|
209
|
+
existing_gate = existing_op.gate
|
|
210
|
+
assert existing_gate is not None
|
|
211
|
+
single_qubit_moments[e][q] = _merge(
|
|
212
|
+
gate_inv, existing_gate, q, existing_op.tags
|
|
213
|
+
)
|
|
214
|
+
else:
|
|
215
|
+
single_qubit_moments[e][q] = gate_inv(q)
|
|
216
|
+
|
|
217
|
+
return circuits.Circuit.from_moments(
|
|
218
|
+
*(
|
|
219
|
+
[op for op in sq.values()] + nsq
|
|
220
|
+
for sq, nsq in zip(single_qubit_moments, non_single_qubit_moments, strict=True)
|
|
221
|
+
)
|
|
222
|
+
)
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
# Copyright 2025 The Cirq Developers
|
|
2
|
+
#
|
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
# you may not use this file except in compliance with the License.
|
|
5
|
+
# You may obtain a copy of the License at
|
|
6
|
+
#
|
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
#
|
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
# See the License for the specific language governing permissions and
|
|
13
|
+
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import numpy as np
|
|
17
|
+
import pytest
|
|
18
|
+
|
|
19
|
+
import cirq
|
|
20
|
+
from cirq.transformers import gauge_compiling
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
class _MockRng(np.random.Generator):
|
|
24
|
+
|
|
25
|
+
def __init__(self, vals):
|
|
26
|
+
self._n_calls = 0
|
|
27
|
+
self._res = tuple(vals)
|
|
28
|
+
|
|
29
|
+
def choice(self, seq):
|
|
30
|
+
ret = self._res[self._n_calls]
|
|
31
|
+
self._n_calls += 1
|
|
32
|
+
return ret
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def test_add_gauge_merges_gates():
|
|
36
|
+
tr = gauge_compiling.IdleMomentsGauge(2, gauges='pauli')
|
|
37
|
+
|
|
38
|
+
circuit = cirq.Circuit.from_moments([], [], [], cirq.X(cirq.q(0)), [], [], cirq.X(cirq.q(0)))
|
|
39
|
+
transformed_circuit = tr(circuit, rng_or_seed=_MockRng([3]))
|
|
40
|
+
|
|
41
|
+
assert transformed_circuit == cirq.Circuit.from_moments(
|
|
42
|
+
[],
|
|
43
|
+
[],
|
|
44
|
+
[],
|
|
45
|
+
cirq.PhasedXZGate(axis_phase_exponent=0.5, x_exponent=1, z_exponent=0)(cirq.q(0)),
|
|
46
|
+
[],
|
|
47
|
+
[],
|
|
48
|
+
cirq.PhasedXZGate(axis_phase_exponent=0.5, x_exponent=1, z_exponent=0)(cirq.q(0)),
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def test_add_gauge_respects_ignore_tag():
|
|
53
|
+
tr = gauge_compiling.IdleMomentsGauge(2, gauges='pauli')
|
|
54
|
+
|
|
55
|
+
circuit = cirq.Circuit.from_moments(
|
|
56
|
+
cirq.X(cirq.q(0)), [], [], cirq.X(cirq.q(0)).with_tags('ignore')
|
|
57
|
+
)
|
|
58
|
+
transformed_circuit = tr(
|
|
59
|
+
circuit,
|
|
60
|
+
context=cirq.TransformerContext(tags_to_ignore=("ignore",)),
|
|
61
|
+
rng_or_seed=_MockRng([3]),
|
|
62
|
+
)
|
|
63
|
+
assert transformed_circuit == cirq.Circuit.from_moments(
|
|
64
|
+
cirq.PhasedXZGate(axis_phase_exponent=0.5, x_exponent=1, z_exponent=0)(cirq.q(0)),
|
|
65
|
+
[],
|
|
66
|
+
cirq.Z(cirq.q(0)),
|
|
67
|
+
cirq.X(cirq.q(0)).with_tags('ignore'),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def test_add_gauge_respects_ignore_moment():
|
|
72
|
+
tr = gauge_compiling.IdleMomentsGauge(2, gauges='pauli')
|
|
73
|
+
|
|
74
|
+
circuit = cirq.Circuit.from_moments(
|
|
75
|
+
cirq.X(cirq.q(0)), [], [], cirq.Moment(cirq.X(cirq.q(0))).with_tags('ignore')
|
|
76
|
+
)
|
|
77
|
+
transformed_circuit = tr(
|
|
78
|
+
circuit,
|
|
79
|
+
context=cirq.TransformerContext(tags_to_ignore=("ignore",)),
|
|
80
|
+
rng_or_seed=_MockRng([3]),
|
|
81
|
+
)
|
|
82
|
+
assert transformed_circuit == cirq.Circuit.from_moments(
|
|
83
|
+
cirq.PhasedXZGate(axis_phase_exponent=0.5, x_exponent=1, z_exponent=0)(cirq.q(0)),
|
|
84
|
+
[],
|
|
85
|
+
cirq.Z(cirq.q(0)),
|
|
86
|
+
cirq.Moment(cirq.X(cirq.q(0))).with_tags('ignore'),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
def test_add_gauge_on_prefix():
|
|
91
|
+
tr = gauge_compiling.IdleMomentsGauge(3, gauges='clifford', gauge_beginning=True)
|
|
92
|
+
|
|
93
|
+
circuit = cirq.Circuit.from_moments([], [], [], cirq.CNOT(cirq.q(0), cirq.q(1)))
|
|
94
|
+
transformed_circuit = tr(circuit, rng_or_seed=_MockRng([20, 15]))
|
|
95
|
+
assert transformed_circuit == cirq.Circuit.from_moments(
|
|
96
|
+
[
|
|
97
|
+
cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[20](cirq.q(0)),
|
|
98
|
+
cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[15](cirq.q(1)),
|
|
99
|
+
],
|
|
100
|
+
[],
|
|
101
|
+
[
|
|
102
|
+
cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[20](cirq.q(0)) ** -1,
|
|
103
|
+
cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[15](cirq.q(1)) ** -1,
|
|
104
|
+
],
|
|
105
|
+
cirq.CNOT(cirq.q(0), cirq.q(1)),
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def test_add_gauge_on_prefix_with_merge():
|
|
110
|
+
tr = gauge_compiling.IdleMomentsGauge(3, gauges=[cirq.Y], gauge_beginning=True)
|
|
111
|
+
|
|
112
|
+
circuit = cirq.Circuit.from_moments([], [], [], cirq.X(cirq.q(0)))
|
|
113
|
+
transformed_circuit = tr(circuit, rng_or_seed=_MockRng([0]))
|
|
114
|
+
assert transformed_circuit == cirq.Circuit.from_moments(
|
|
115
|
+
[cirq.Y(cirq.q(0))],
|
|
116
|
+
[],
|
|
117
|
+
[],
|
|
118
|
+
cirq.PhasedXZGate(axis_phase_exponent=0, x_exponent=0, z_exponent=1)(cirq.q(0)),
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def test_add_gauge_on_suffix():
|
|
123
|
+
tr = gauge_compiling.IdleMomentsGauge(3, gauges='inv_clifford', gauge_ending=True)
|
|
124
|
+
|
|
125
|
+
circuit = cirq.Circuit.from_moments(cirq.CNOT(cirq.q(0), cirq.q(1)), [], [], [])
|
|
126
|
+
transformed_circuit = tr(circuit, rng_or_seed=_MockRng([20, 15]))
|
|
127
|
+
assert transformed_circuit == cirq.Circuit.from_moments(
|
|
128
|
+
cirq.CNOT(cirq.q(0), cirq.q(1)),
|
|
129
|
+
[
|
|
130
|
+
cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[20](cirq.q(0)) ** -1,
|
|
131
|
+
cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[15](cirq.q(1)) ** -1,
|
|
132
|
+
],
|
|
133
|
+
[],
|
|
134
|
+
[
|
|
135
|
+
cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[20](cirq.q(0)),
|
|
136
|
+
cirq.SingleQubitCliffordGate.all_single_qubit_cliffords[15](cirq.q(1)),
|
|
137
|
+
],
|
|
138
|
+
)
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
def test_add_gauge_on_suffix_with_merge():
|
|
142
|
+
tr = gauge_compiling.IdleMomentsGauge(3, gauges=[cirq.Y], gauge_ending=True)
|
|
143
|
+
|
|
144
|
+
circuit = cirq.Circuit.from_moments(cirq.X(cirq.q(0)), [], [], [])
|
|
145
|
+
transformed_circuit = tr(circuit, rng_or_seed=_MockRng([0]))
|
|
146
|
+
assert transformed_circuit == cirq.Circuit.from_moments(
|
|
147
|
+
cirq.PhasedXZGate(axis_phase_exponent=0, x_exponent=0, z_exponent=1)(cirq.q(0)),
|
|
148
|
+
[],
|
|
149
|
+
[],
|
|
150
|
+
cirq.Y(cirq.q(0)),
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
def test_add_gauge_respects_min_length():
|
|
155
|
+
tr = gauge_compiling.IdleMomentsGauge(2, gauges=[cirq.X])
|
|
156
|
+
|
|
157
|
+
circuit = cirq.Circuit.from_moments(cirq.X(cirq.q(0)), [], cirq.X(cirq.q(0)))
|
|
158
|
+
transformed_circuit = tr(circuit)
|
|
159
|
+
assert transformed_circuit == circuit
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
def test_context_with_deep_raises():
|
|
163
|
+
tr = gauge_compiling.IdleMomentsGauge(2, gauges=[cirq.X])
|
|
164
|
+
|
|
165
|
+
circuit = cirq.Circuit.from_moments(cirq.X(cirq.q(0)), [], cirq.X(cirq.q(0)))
|
|
166
|
+
with pytest.raises(
|
|
167
|
+
ValueError, match="IdleMomentsGauge doesn't support deep TransformerContext"
|
|
168
|
+
):
|
|
169
|
+
_ = tr(circuit, context=cirq.TransformerContext(deep=True))
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
def test_gauge_with_invalid_name_raises():
|
|
173
|
+
with pytest.raises(ValueError, match='valid gauge'):
|
|
174
|
+
_ = gauge_compiling.IdleMomentsGauge(2, gauges='invalid')
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
def test_repr():
|
|
178
|
+
assert repr(gauge_compiling.IdleMomentsGauge(3, gauges='pauli')) == (
|
|
179
|
+
'IdleMomentsGauge(min_length=3, gauges="pauli", '
|
|
180
|
+
'gauge_beginning=False, gauge_ending=False)'
|
|
181
|
+
)
|
|
182
|
+
assert repr(gauge_compiling.IdleMomentsGauge(4, gauges='clifford')) == (
|
|
183
|
+
'IdleMomentsGauge(min_length=4, gauges="clifford", '
|
|
184
|
+
'gauge_beginning=False, gauge_ending=False)'
|
|
185
|
+
)
|
|
186
|
+
assert repr(gauge_compiling.IdleMomentsGauge(5, gauges='inv_clifford')) == (
|
|
187
|
+
'IdleMomentsGauge(min_length=5, gauges="inv_clifford", '
|
|
188
|
+
'gauge_beginning=False, gauge_ending=False)'
|
|
189
|
+
)
|
|
190
|
+
assert repr(gauge_compiling.IdleMomentsGauge(6, gauges=[cirq.X])) == (
|
|
191
|
+
'IdleMomentsGauge(min_length=6, gauges=(cirq.X,), '
|
|
192
|
+
'gauge_beginning=False, gauge_ending=False)'
|
|
193
|
+
)
|
{cirq_core-1.7.0.dev20250917002151.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.7.0.
|
|
3
|
+
Version: 1.7.0.dev20250917023732
|
|
4
4
|
Summary: A framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
|
|
5
5
|
Home-page: http://github.com/quantumlib/cirq
|
|
6
6
|
Author: The Cirq Developers
|
{cirq_core-1.7.0.dev20250917002151.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/RECORD
RENAMED
|
@@ -4,8 +4,8 @@ cirq/_compat_test.py,sha256=emXpdD5ZvwLRlFAoQB8YatmZyU3b4e9jg6FppMTUhkU,33900
|
|
|
4
4
|
cirq/_doc.py,sha256=BrnoABo1hk5RgB3Cgww4zLHUfiyFny0F1V-tOMCbdaU,2909
|
|
5
5
|
cirq/_import.py,sha256=ixBu4EyGl46Ram2cP3p5eZVEFDW5L2DS-VyTjz4N9iw,8429
|
|
6
6
|
cirq/_import_test.py,sha256=oF4izzOVZLc7NZ0aZHFcGv-r01eiFFt_JORx_x7_D4s,1089
|
|
7
|
-
cirq/_version.py,sha256=
|
|
8
|
-
cirq/_version_test.py,sha256=
|
|
7
|
+
cirq/_version.py,sha256=1yZ87mOQVmLjF6tVlRa3kqMYh9kKdQ56G2djj2_P9OM,1206
|
|
8
|
+
cirq/_version_test.py,sha256=IWBpw0Ag9-IzLZYqsnqutqalX_BrMvw5gvRo7n0TVG0,155
|
|
9
9
|
cirq/conftest.py,sha256=wSDKNdIQRDfLnXvOCWD3erheOw8JHRhdfQ53EyTUIXg,1239
|
|
10
10
|
cirq/json_resolver_cache.py,sha256=A5DIgFAY1hUNt9vai_C3-gGBv24116CJMzQxMcXOax4,13726
|
|
11
11
|
cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
|
|
@@ -1134,7 +1134,7 @@ cirq/transformers/analytical_decompositions/two_qubit_to_ms.py,sha256=dP9umZJBgN
|
|
|
1134
1134
|
cirq/transformers/analytical_decompositions/two_qubit_to_ms_test.py,sha256=Cj_GZvJykt5NfNuB8vEY30DE2tU3nJtnUztAArgnfE4,4204
|
|
1135
1135
|
cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap.py,sha256=s08m1PJODNUNzNNkn_zu2qasRSWmXJAq8Tb9cHKk-yU,25348
|
|
1136
1136
|
cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py,sha256=WfPQA_wTpRknovNenxC1LPAt9cVHqwdRhUhPZ8sLNr0,20655
|
|
1137
|
-
cirq/transformers/gauge_compiling/__init__.py,sha256=
|
|
1137
|
+
cirq/transformers/gauge_compiling/__init__.py,sha256=T1IaBKgf2GgVbozsHun7lJhdypasX9olQVh9eYhY7gk,1670
|
|
1138
1138
|
cirq/transformers/gauge_compiling/cphase_gauge.py,sha256=EoM_TKZt8mJwYFQAfv3rviitXWvGT8I5N36droPWPCE,5576
|
|
1139
1139
|
cirq/transformers/gauge_compiling/cphase_gauge_test.py,sha256=dPV2vqsyC-eUi_jmwEk6dhOKHnQLJ_A01_Emxw2j8QQ,1427
|
|
1140
1140
|
cirq/transformers/gauge_compiling/cz_gauge.py,sha256=dtcC49-qIvH_hRaQpQLBvGu-3323r4cwWpFImBnDebE,2586
|
|
@@ -1143,6 +1143,8 @@ cirq/transformers/gauge_compiling/gauge_compiling.py,sha256=bXqAEVBXHplnxRMwNA0G
|
|
|
1143
1143
|
cirq/transformers/gauge_compiling/gauge_compiling_test.py,sha256=JFG7aCe-PxPGZDPCAx82ILu6PX_laFvCDlaabwvL0Kc,5272
|
|
1144
1144
|
cirq/transformers/gauge_compiling/gauge_compiling_test_utils.py,sha256=NUbcz-tGS58QPohpsmMx0RbB4d79GMSoyVxdL3CPiZc,5060
|
|
1145
1145
|
cirq/transformers/gauge_compiling/gauge_compiling_test_utils_test.py,sha256=qPcs2BWU-1gOEz0NCLixBLO9I1PVIOLShB7wkprcQZY,1896
|
|
1146
|
+
cirq/transformers/gauge_compiling/idle_moments_gauge.py,sha256=t5vCp4iLA8Wcx7p81S_4JPhk3TaHCTNQGuvooPDF-gQ,8458
|
|
1147
|
+
cirq/transformers/gauge_compiling/idle_moments_gauge_test.py,sha256=OSb0840o0M8Qpde_Dp3-sRCGrJCO4rBgArDLnnT8D-g,6903
|
|
1146
1148
|
cirq/transformers/gauge_compiling/iswap_gauge.py,sha256=CfW3hgO6AgUB7D6tC8J2XZQw2Ge77LT44BygCzMW4Xc,3536
|
|
1147
1149
|
cirq/transformers/gauge_compiling/iswap_gauge_test.py,sha256=V6g-jyGujMKEzGtOi_OhMxX5oTznGXJi9tCNKI9Qrb8,901
|
|
1148
1150
|
cirq/transformers/gauge_compiling/spin_inversion_gauge.py,sha256=yhrF4pa1u0-iwYay47_2bZ4xfU323TOdlyazl0U9v4c,1122
|
|
@@ -1234,8 +1236,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
|
|
|
1234
1236
|
cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
|
|
1235
1237
|
cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
|
|
1236
1238
|
cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
|
|
1237
|
-
cirq_core-1.7.0.
|
|
1238
|
-
cirq_core-1.7.0.
|
|
1239
|
-
cirq_core-1.7.0.
|
|
1240
|
-
cirq_core-1.7.0.
|
|
1241
|
-
cirq_core-1.7.0.
|
|
1239
|
+
cirq_core-1.7.0.dev20250917023732.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1240
|
+
cirq_core-1.7.0.dev20250917023732.dist-info/METADATA,sha256=Lk57dj4REL284LPbZY628TWToqkmG6CvPoHdrwcklW4,4758
|
|
1241
|
+
cirq_core-1.7.0.dev20250917023732.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
1242
|
+
cirq_core-1.7.0.dev20250917023732.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1243
|
+
cirq_core-1.7.0.dev20250917023732.dist-info/RECORD,,
|
{cirq_core-1.7.0.dev20250917002151.dist-info → cirq_core-1.7.0.dev20250917023732.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|