cirq-core 1.4.0.dev20240430181951__py3-none-any.whl → 1.4.0.dev20240503144904__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/transformers/gauge_compiling/gauge_compiling.py +37 -1
- cirq/transformers/gauge_compiling/spin_inversion_gauge.py +4 -4
- cirq/transformers/gauge_compiling/spin_inversion_gauge_test.py +16 -2
- cirq/transformers/gauge_compiling/sqrt_cz_gauge.py +42 -7
- cirq/transformers/gauge_compiling/sqrt_cz_gauge_test.py +5 -1
- {cirq_core-1.4.0.dev20240430181951.dist-info → cirq_core-1.4.0.dev20240503144904.dist-info}/METADATA +1 -1
- {cirq_core-1.4.0.dev20240430181951.dist-info → cirq_core-1.4.0.dev20240503144904.dist-info}/RECORD +11 -11
- {cirq_core-1.4.0.dev20240430181951.dist-info → cirq_core-1.4.0.dev20240503144904.dist-info}/LICENSE +0 -0
- {cirq_core-1.4.0.dev20240430181951.dist-info → cirq_core-1.4.0.dev20240503144904.dist-info}/WHEEL +0 -0
- {cirq_core-1.4.0.dev20240430181951.dist-info → cirq_core-1.4.0.dev20240503144904.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "1.4.0.
|
|
1
|
+
__version__ = "1.4.0.dev20240503144904"
|
|
@@ -71,6 +71,7 @@ class ConstantGauge(Gauge):
|
|
|
71
71
|
post_q1: Tuple[ops.Gate, ...] = field(
|
|
72
72
|
default=(), converter=lambda g: (g,) if isinstance(g, ops.Gate) else tuple(g)
|
|
73
73
|
)
|
|
74
|
+
swap_qubits: bool = False
|
|
74
75
|
|
|
75
76
|
def sample(self, gate: ops.Gate, prng: np.random.Generator) -> "ConstantGauge":
|
|
76
77
|
return self
|
|
@@ -85,6 +86,41 @@ class ConstantGauge(Gauge):
|
|
|
85
86
|
"""A tuple (ops to apply to q0, ops to apply to q1)."""
|
|
86
87
|
return self.post_q0, self.post_q1
|
|
87
88
|
|
|
89
|
+
def on(self, q0: ops.Qid, q1: ops.Qid) -> ops.Operation:
|
|
90
|
+
"""Returns the operation that replaces the two qubit gate."""
|
|
91
|
+
if self.swap_qubits:
|
|
92
|
+
return self.two_qubit_gate(q1, q0)
|
|
93
|
+
return self.two_qubit_gate(q0, q1)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
@frozen
|
|
97
|
+
class SameGateGauge(Gauge):
|
|
98
|
+
"""Same as ConstantGauge but the new two-qubit gate equals the old gate."""
|
|
99
|
+
|
|
100
|
+
pre_q0: Tuple[ops.Gate, ...] = field(
|
|
101
|
+
default=(), converter=lambda g: (g,) if isinstance(g, ops.Gate) else tuple(g)
|
|
102
|
+
)
|
|
103
|
+
pre_q1: Tuple[ops.Gate, ...] = field(
|
|
104
|
+
default=(), converter=lambda g: (g,) if isinstance(g, ops.Gate) else tuple(g)
|
|
105
|
+
)
|
|
106
|
+
post_q0: Tuple[ops.Gate, ...] = field(
|
|
107
|
+
default=(), converter=lambda g: (g,) if isinstance(g, ops.Gate) else tuple(g)
|
|
108
|
+
)
|
|
109
|
+
post_q1: Tuple[ops.Gate, ...] = field(
|
|
110
|
+
default=(), converter=lambda g: (g,) if isinstance(g, ops.Gate) else tuple(g)
|
|
111
|
+
)
|
|
112
|
+
swap_qubits: bool = False
|
|
113
|
+
|
|
114
|
+
def sample(self, gate: ops.Gate, prng: np.random.Generator) -> ConstantGauge:
|
|
115
|
+
return ConstantGauge(
|
|
116
|
+
two_qubit_gate=gate,
|
|
117
|
+
pre_q0=self.pre_q0,
|
|
118
|
+
pre_q1=self.pre_q1,
|
|
119
|
+
post_q0=self.post_q0,
|
|
120
|
+
post_q1=self.post_q1,
|
|
121
|
+
swap_qubits=self.swap_qubits,
|
|
122
|
+
)
|
|
123
|
+
|
|
88
124
|
|
|
89
125
|
def _select(choices: Sequence[Gauge], probabilites: np.ndarray, prng: np.random.Generator) -> Gauge:
|
|
90
126
|
return choices[prng.choice(len(choices), p=probabilites)]
|
|
@@ -154,7 +190,7 @@ class GaugeTransformer:
|
|
|
154
190
|
gauge = self.gauge_selector(rng).sample(op.gate, rng)
|
|
155
191
|
q0, q1 = op.qubits
|
|
156
192
|
left.extend([g(q) for g in gs] for q, gs in zip(op.qubits, gauge.pre))
|
|
157
|
-
center.append(gauge.
|
|
193
|
+
center.append(gauge.on(q0, q1))
|
|
158
194
|
right.extend([g(q) for g in gs] for q, gs in zip(op.qubits, gauge.post))
|
|
159
195
|
else:
|
|
160
196
|
center.append(op)
|
|
@@ -17,17 +17,17 @@
|
|
|
17
17
|
from cirq.transformers.gauge_compiling.gauge_compiling import (
|
|
18
18
|
GaugeTransformer,
|
|
19
19
|
GaugeSelector,
|
|
20
|
-
|
|
20
|
+
SameGateGauge,
|
|
21
21
|
)
|
|
22
22
|
from cirq import ops
|
|
23
23
|
|
|
24
24
|
SpinInversionGaugeSelector = GaugeSelector(
|
|
25
25
|
gauges=[
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
SameGateGauge(pre_q0=ops.X, post_q0=ops.X, pre_q1=ops.X, post_q1=ops.X),
|
|
27
|
+
SameGateGauge(),
|
|
28
28
|
]
|
|
29
29
|
)
|
|
30
30
|
|
|
31
31
|
SpinInversionGaugeTransformer = GaugeTransformer(
|
|
32
|
-
target=ops.
|
|
32
|
+
target=ops.GateFamily(ops.ZZPowGate), gauge_selector=SpinInversionGaugeSelector
|
|
33
33
|
)
|
|
@@ -12,12 +12,26 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
import cirq
|
|
17
16
|
from cirq.transformers.gauge_compiling import SpinInversionGaugeTransformer
|
|
18
17
|
from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTester
|
|
19
18
|
|
|
20
19
|
|
|
21
|
-
class
|
|
20
|
+
class TestSpinInversionGauge_0(GaugeTester):
|
|
22
21
|
two_qubit_gate = cirq.ZZ
|
|
23
22
|
gauge_transformer = SpinInversionGaugeTransformer
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TestSpinInversionGauge_1(GaugeTester):
|
|
26
|
+
two_qubit_gate = cirq.ZZ**0.1
|
|
27
|
+
gauge_transformer = SpinInversionGaugeTransformer
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class TestSpinInversionGauge_2(GaugeTester):
|
|
31
|
+
two_qubit_gate = cirq.ZZ**-1
|
|
32
|
+
gauge_transformer = SpinInversionGaugeTransformer
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class TestSpinInversionGauge_3(GaugeTester):
|
|
36
|
+
two_qubit_gate = cirq.ZZ**0.3
|
|
37
|
+
gauge_transformer = SpinInversionGaugeTransformer
|
|
@@ -12,18 +12,53 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
"""A Gauge transformer for CZ**0.5
|
|
15
|
+
"""A Gauge transformer for CZ**0.5 and CZ**-0.5 gates."""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
from typing import TYPE_CHECKING
|
|
19
|
+
import numpy as np
|
|
16
20
|
|
|
17
21
|
from cirq.transformers.gauge_compiling.gauge_compiling import (
|
|
18
22
|
GaugeTransformer,
|
|
19
23
|
GaugeSelector,
|
|
20
24
|
ConstantGauge,
|
|
25
|
+
Gauge,
|
|
21
26
|
)
|
|
22
|
-
from cirq.ops
|
|
23
|
-
|
|
27
|
+
from cirq.ops import CZ, S, X, Gateset
|
|
28
|
+
|
|
29
|
+
if TYPE_CHECKING:
|
|
30
|
+
import cirq
|
|
31
|
+
|
|
32
|
+
_SQRT_CZ = CZ**0.5
|
|
33
|
+
_ADJ_S = S**-1
|
|
24
34
|
|
|
25
|
-
SqrtCZGaugeSelector = GaugeSelector(
|
|
26
|
-
gauges=[ConstantGauge(pre_q0=ops.X, post_q0=ops.X, post_q1=ops.Z**0.5, two_qubit_gate=CZ**-0.5)]
|
|
27
|
-
)
|
|
28
35
|
|
|
29
|
-
|
|
36
|
+
class SqrtCZGauge(Gauge):
|
|
37
|
+
|
|
38
|
+
def weight(self) -> float:
|
|
39
|
+
return 3.0
|
|
40
|
+
|
|
41
|
+
def sample(self, gate: 'cirq.Gate', prng: np.random.Generator) -> ConstantGauge:
|
|
42
|
+
if prng.choice([True, False]):
|
|
43
|
+
return ConstantGauge(two_qubit_gate=gate)
|
|
44
|
+
swap_qubits = prng.choice([True, False])
|
|
45
|
+
if swap_qubits:
|
|
46
|
+
return ConstantGauge(
|
|
47
|
+
pre_q1=X,
|
|
48
|
+
post_q1=X,
|
|
49
|
+
post_q0=S if gate == _SQRT_CZ else _ADJ_S,
|
|
50
|
+
two_qubit_gate=gate**-1,
|
|
51
|
+
swap_qubits=True,
|
|
52
|
+
)
|
|
53
|
+
else:
|
|
54
|
+
return ConstantGauge(
|
|
55
|
+
pre_q0=X,
|
|
56
|
+
post_q0=X,
|
|
57
|
+
post_q1=S if gate == _SQRT_CZ else _ADJ_S,
|
|
58
|
+
two_qubit_gate=gate**-1,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
SqrtCZGaugeTransformer = GaugeTransformer(
|
|
63
|
+
target=Gateset(_SQRT_CZ, _SQRT_CZ**-1), gauge_selector=GaugeSelector(gauges=[SqrtCZGauge()])
|
|
64
|
+
)
|
|
@@ -12,7 +12,6 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
-
|
|
16
15
|
import cirq
|
|
17
16
|
from cirq.transformers.gauge_compiling import SqrtCZGaugeTransformer
|
|
18
17
|
from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTester
|
|
@@ -21,3 +20,8 @@ from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTe
|
|
|
21
20
|
class TestSqrtCZGauge(GaugeTester):
|
|
22
21
|
two_qubit_gate = cirq.CZ**0.5
|
|
23
22
|
gauge_transformer = SqrtCZGaugeTransformer
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class TestAdjointSqrtCZGauge(GaugeTester):
|
|
26
|
+
two_qubit_gate = cirq.CZ**-0.5
|
|
27
|
+
gauge_transformer = SqrtCZGaugeTransformer
|
{cirq_core-1.4.0.dev20240430181951.dist-info → cirq_core-1.4.0.dev20240503144904.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.4.0.
|
|
3
|
+
Version: 1.4.0.dev20240503144904
|
|
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.4.0.dev20240430181951.dist-info → cirq_core-1.4.0.dev20240503144904.dist-info}/RECORD
RENAMED
|
@@ -4,7 +4,7 @@ cirq/_compat_test.py,sha256=Qq3ZcfgD-Nb81cEppQdJqhAyrVqXKtfXZYGXT0p-Wh0,34718
|
|
|
4
4
|
cirq/_doc.py,sha256=yDyWUD_2JDS0gShfGRb-rdqRt9-WeL7DhkqX7np0Nko,2879
|
|
5
5
|
cirq/_import.py,sha256=p9gMHJscbtDDkfHOaulvd3Aer0pwUF5AXpL89XR8dNw,8402
|
|
6
6
|
cirq/_import_test.py,sha256=6K_v0riZJXOXUphHNkGA8MY-JcmGlezFaGmvrNhm3OQ,1015
|
|
7
|
-
cirq/_version.py,sha256=
|
|
7
|
+
cirq/_version.py,sha256=aRBGSolIrotnVt5Uy7_ohSdefCEVNK1cN8LfIKIi1Rs,40
|
|
8
8
|
cirq/_version_test.py,sha256=yYS6xm5-nuBRQJa9R3n41WdvFtVyY7Lb5Q8bea3VgBI,133
|
|
9
9
|
cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
|
|
10
10
|
cirq/json_resolver_cache.py,sha256=9g_JQMmfBzTuV-3s2flUbXIgcLjs4K7LjAFFgngdG1U,13204
|
|
@@ -1074,16 +1074,16 @@ cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py,sha2
|
|
|
1074
1074
|
cirq/transformers/gauge_compiling/__init__.py,sha256=dmgVx7_yfsO9TarOCMBfVuZjza_6_MmUyAfM_eo698E,1146
|
|
1075
1075
|
cirq/transformers/gauge_compiling/cz_gauge.py,sha256=TNZviXFu4j-lCF87QMGYVdb2RC_ePHLdI6FRCqh9go4,2550
|
|
1076
1076
|
cirq/transformers/gauge_compiling/cz_gauge_test.py,sha256=_2RMzwuMoqytgsVZEET2m6QsGoZ2_uWgBfSGGvhZEWo,854
|
|
1077
|
-
cirq/transformers/gauge_compiling/gauge_compiling.py,sha256=
|
|
1077
|
+
cirq/transformers/gauge_compiling/gauge_compiling.py,sha256=7jUg2MHVX2V8SzH7r27e_BUUA_p5l15-Qv8lLlhGasQ,7948
|
|
1078
1078
|
cirq/transformers/gauge_compiling/gauge_compiling_test.py,sha256=xVeoaaMuenlp_pxqmZO89kJEeBV0iapK7-JDTUuC7Lg,1565
|
|
1079
1079
|
cirq/transformers/gauge_compiling/gauge_compiling_test_utils.py,sha256=6mpF2ftcDtWQEsZNr-m16GkDOn5WBWV08JB4ZS5rf8M,3408
|
|
1080
1080
|
cirq/transformers/gauge_compiling/gauge_compiling_test_utils_test.py,sha256=HQw1xeko9OAD0PCuKcehUiy8mbxeRza4nE-6E8MGVME,1584
|
|
1081
1081
|
cirq/transformers/gauge_compiling/iswap_gauge.py,sha256=UGJ_061h65Rfgb9LWREjxC8OSt01ZqP9TGnacL8VAuk,3500
|
|
1082
1082
|
cirq/transformers/gauge_compiling/iswap_gauge_test.py,sha256=HEIIwKlX5ixau1e_etSUj5NvYOVTT-Gc3kuHcyKAeJ4,866
|
|
1083
|
-
cirq/transformers/gauge_compiling/spin_inversion_gauge.py,sha256=
|
|
1084
|
-
cirq/transformers/gauge_compiling/spin_inversion_gauge_test.py,sha256=
|
|
1085
|
-
cirq/transformers/gauge_compiling/sqrt_cz_gauge.py,sha256=
|
|
1086
|
-
cirq/transformers/gauge_compiling/sqrt_cz_gauge_test.py,sha256=
|
|
1083
|
+
cirq/transformers/gauge_compiling/spin_inversion_gauge.py,sha256=gfjSlQdo13GfBPlrkQoHPWWzouiV7yYr7JAaB85NSGY,1086
|
|
1084
|
+
cirq/transformers/gauge_compiling/spin_inversion_gauge_test.py,sha256=FJwl11VPNXkf_v0WjCg9VxNKAplZ_5bZR7guOfnK-aI,1292
|
|
1085
|
+
cirq/transformers/gauge_compiling/sqrt_cz_gauge.py,sha256=32OGTcYT3tBFEQ1GQlrssc1wtwCcSvk4ZC0I1XD1QXg,1869
|
|
1086
|
+
cirq/transformers/gauge_compiling/sqrt_cz_gauge_test.py,sha256=RwjadOOJfa2Qf7iryTIMJLPzeDMNqFkP6Tewjq68gJI,997
|
|
1087
1087
|
cirq/transformers/gauge_compiling/sqrt_iswap_gauge.py,sha256=dqQa-UWq31bE_jF3KMhU76sND5GuqTpEp9-wVuXdWVM,3126
|
|
1088
1088
|
cirq/transformers/gauge_compiling/sqrt_iswap_gauge_test.py,sha256=0CLZoLw-WK3aKEIoaKBrQZ-qvaprOVLad-dVyWFmSiU,882
|
|
1089
1089
|
cirq/transformers/heuristic_decompositions/__init__.py,sha256=2KBAUk-vsVku-HuahLbDQxp8bjEQMZUUNiBz_cvUMUw,831
|
|
@@ -1169,8 +1169,8 @@ cirq/work/sampler.py,sha256=JEAeQQRF3bqlO9AkOf4XbrTATDI5f5JgyM_FAUCNxao,19751
|
|
|
1169
1169
|
cirq/work/sampler_test.py,sha256=B2ZsuqGT854gQtBIAh8k0LiG9Vj5wSzcGvkxOUoTcW4,13217
|
|
1170
1170
|
cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
|
|
1171
1171
|
cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
|
|
1172
|
-
cirq_core-1.4.0.
|
|
1173
|
-
cirq_core-1.4.0.
|
|
1174
|
-
cirq_core-1.4.0.
|
|
1175
|
-
cirq_core-1.4.0.
|
|
1176
|
-
cirq_core-1.4.0.
|
|
1172
|
+
cirq_core-1.4.0.dev20240503144904.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1173
|
+
cirq_core-1.4.0.dev20240503144904.dist-info/METADATA,sha256=1q92xeT06NabUO28q1QHb2Hl_hyEjoHxlaC2mXXrAzk,2098
|
|
1174
|
+
cirq_core-1.4.0.dev20240503144904.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
1175
|
+
cirq_core-1.4.0.dev20240503144904.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1176
|
+
cirq_core-1.4.0.dev20240503144904.dist-info/RECORD,,
|
{cirq_core-1.4.0.dev20240430181951.dist-info → cirq_core-1.4.0.dev20240503144904.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.4.0.dev20240430181951.dist-info → cirq_core-1.4.0.dev20240503144904.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|