cirq-core 1.5.0.dev20250122193029__py3-none-any.whl → 1.5.0.dev20250123021547__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/ops/op_tree.py +1 -27
- cirq/sim/simulator.py +6 -5
- cirq/sim/simulator_test.py +11 -0
- cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py +5 -6
- {cirq_core-1.5.0.dev20250122193029.dist-info → cirq_core-1.5.0.dev20250123021547.dist-info}/METADATA +1 -1
- {cirq_core-1.5.0.dev20250122193029.dist-info → cirq_core-1.5.0.dev20250123021547.dist-info}/RECORD +11 -11
- {cirq_core-1.5.0.dev20250122193029.dist-info → cirq_core-1.5.0.dev20250123021547.dist-info}/LICENSE +0 -0
- {cirq_core-1.5.0.dev20250122193029.dist-info → cirq_core-1.5.0.dev20250123021547.dist-info}/WHEEL +0 -0
- {cirq_core-1.5.0.dev20250122193029.dist-info → cirq_core-1.5.0.dev20250123021547.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
cirq/ops/op_tree.py
CHANGED
|
@@ -16,7 +16,6 @@
|
|
|
16
16
|
"""
|
|
17
17
|
|
|
18
18
|
from typing import Callable, Iterable, Iterator, NoReturn, Union, TYPE_CHECKING
|
|
19
|
-
from typing_extensions import Protocol
|
|
20
19
|
|
|
21
20
|
from cirq._doc import document
|
|
22
21
|
from cirq._import import LazyLoader
|
|
@@ -28,32 +27,7 @@ if TYPE_CHECKING:
|
|
|
28
27
|
moment = LazyLoader("moment", globals(), "cirq.circuits.moment")
|
|
29
28
|
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
"""The recursive type consumed by circuit builder methods.
|
|
33
|
-
|
|
34
|
-
An OpTree is a type protocol, satisfied by anything that can be recursively
|
|
35
|
-
flattened into Operations. We also define the Union type OP_TREE which
|
|
36
|
-
can be an OpTree or just a single Operation.
|
|
37
|
-
|
|
38
|
-
For example:
|
|
39
|
-
- An Operation is an OP_TREE all by itself.
|
|
40
|
-
- A list of operations is an OP_TREE.
|
|
41
|
-
- A list of tuples of operations is an OP_TREE.
|
|
42
|
-
- A list with a mix of operations and lists of operations is an OP_TREE.
|
|
43
|
-
- A generator yielding operations is an OP_TREE.
|
|
44
|
-
|
|
45
|
-
Note: once mypy supports recursive types this could be defined as an alias:
|
|
46
|
-
|
|
47
|
-
OP_TREE = Union[Operation, Iterable['OP_TREE']]
|
|
48
|
-
|
|
49
|
-
See: https://github.com/python/mypy/issues/731
|
|
50
|
-
"""
|
|
51
|
-
|
|
52
|
-
def __iter__(self) -> Iterator[Union[Operation, 'OpTree']]:
|
|
53
|
-
pass
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
OP_TREE = Union[Operation, OpTree]
|
|
30
|
+
OP_TREE = Union[Operation, Iterable['OP_TREE']]
|
|
57
31
|
document(
|
|
58
32
|
OP_TREE,
|
|
59
33
|
"""An operation or nested collections of operations.
|
cirq/sim/simulator.py
CHANGED
|
@@ -973,9 +973,10 @@ def split_into_matching_protocol_then_general(
|
|
|
973
973
|
qubit A will cause later operations on A to be part of the non-matching
|
|
974
974
|
suffix, but later operations on other qubits will continue to be put into
|
|
975
975
|
the matching part (as long as those qubits have had no non-matching operation
|
|
976
|
-
up to that point).
|
|
976
|
+
up to that point). Measurement keys are handled equivalently.
|
|
977
977
|
"""
|
|
978
978
|
blocked_qubits: Set[cirq.Qid] = set()
|
|
979
|
+
blocked_keys: Set[cirq.MeasurementKey] = set()
|
|
979
980
|
matching_prefix = circuits.Circuit()
|
|
980
981
|
general_suffix = circuits.Circuit()
|
|
981
982
|
for moment in circuit:
|
|
@@ -983,12 +984,12 @@ def split_into_matching_protocol_then_general(
|
|
|
983
984
|
general_part = []
|
|
984
985
|
for op in moment:
|
|
985
986
|
qs = set(op.qubits)
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
if qs.isdisjoint(blocked_qubits):
|
|
987
|
+
keys = protocols.measurement_keys_touched(op)
|
|
988
|
+
if predicate(op) and qs.isdisjoint(blocked_qubits) and keys.isdisjoint(blocked_keys):
|
|
990
989
|
matching_part.append(op)
|
|
991
990
|
else:
|
|
991
|
+
blocked_qubits |= qs
|
|
992
|
+
blocked_keys |= keys
|
|
992
993
|
general_part.append(op)
|
|
993
994
|
if matching_part:
|
|
994
995
|
matching_prefix.append(circuits.Moment(matching_part))
|
cirq/sim/simulator_test.py
CHANGED
|
@@ -399,6 +399,17 @@ def test_sample_repeated_measurement_keys():
|
|
|
399
399
|
assert len(result.records['b'][0]) == 2
|
|
400
400
|
|
|
401
401
|
|
|
402
|
+
def test_classical_controls_go_to_suffix_if_corresponding_measurement_does():
|
|
403
|
+
subcircuit = cirq.CircuitOperation(cirq.FrozenCircuit()).with_classical_controls('a')
|
|
404
|
+
m = cirq.measure(cirq.LineQubit(0), key='a')
|
|
405
|
+
circuit = cirq.Circuit(m, subcircuit)
|
|
406
|
+
prefix, suffix = cirq.sim.simulator.split_into_matching_protocol_then_general(
|
|
407
|
+
circuit, lambda op: op != m # any op but m goes into prefix
|
|
408
|
+
)
|
|
409
|
+
assert not prefix
|
|
410
|
+
assert suffix == circuit
|
|
411
|
+
|
|
412
|
+
|
|
402
413
|
def test_simulate_with_invert_mask():
|
|
403
414
|
q0, q1, q2, q3, q4 = cirq.LineQid.for_qid_shape((2, 3, 3, 3, 4))
|
|
404
415
|
c = cirq.Circuit(
|
|
@@ -19,7 +19,7 @@ Based on:
|
|
|
19
19
|
Synthesis of Quantum Logic Circuits. Tech. rep. 2006,
|
|
20
20
|
https://arxiv.org/abs/quant-ph/0406176
|
|
21
21
|
"""
|
|
22
|
-
from typing import
|
|
22
|
+
from typing import Callable, Iterable, List, TYPE_CHECKING
|
|
23
23
|
|
|
24
24
|
from scipy.linalg import cossin
|
|
25
25
|
|
|
@@ -38,12 +38,11 @@ from cirq.circuits.frozen_circuit import FrozenCircuit
|
|
|
38
38
|
|
|
39
39
|
if TYPE_CHECKING:
|
|
40
40
|
import cirq
|
|
41
|
-
from cirq.ops import op_tree
|
|
42
41
|
|
|
43
42
|
|
|
44
43
|
def quantum_shannon_decomposition(
|
|
45
44
|
qubits: 'List[cirq.Qid]', u: np.ndarray, atol: float = 1e-8
|
|
46
|
-
) -> '
|
|
45
|
+
) -> Iterable['cirq.Operation']:
|
|
47
46
|
"""Decomposes n-qubit unitary 1-q, 2-q and GlobalPhase gates, preserving global phase.
|
|
48
47
|
|
|
49
48
|
The gates used are CX/YPow/ZPow/CNOT/GlobalPhase/CZ/PhasedXZGate/PhasedXPowGate.
|
|
@@ -141,7 +140,7 @@ def quantum_shannon_decomposition(
|
|
|
141
140
|
yield from _msb_demuxer(qubits, u1, u2)
|
|
142
141
|
|
|
143
142
|
|
|
144
|
-
def _single_qubit_decomposition(qubit: 'cirq.Qid', u: np.ndarray) -> '
|
|
143
|
+
def _single_qubit_decomposition(qubit: 'cirq.Qid', u: np.ndarray) -> Iterable['cirq.Operation']:
|
|
145
144
|
"""Decomposes single-qubit gate, and returns list of operations, keeping phase invariant.
|
|
146
145
|
|
|
147
146
|
Args:
|
|
@@ -186,7 +185,7 @@ def _single_qubit_decomposition(qubit: 'cirq.Qid', u: np.ndarray) -> 'op_tree.Op
|
|
|
186
185
|
|
|
187
186
|
def _msb_demuxer(
|
|
188
187
|
demux_qubits: 'List[cirq.Qid]', u1: np.ndarray, u2: np.ndarray
|
|
189
|
-
) -> '
|
|
188
|
+
) -> Iterable['cirq.Operation']:
|
|
190
189
|
"""Demultiplexes a unitary matrix that is multiplexed in its most-significant-qubit.
|
|
191
190
|
|
|
192
191
|
Decomposition structure:
|
|
@@ -249,7 +248,7 @@ def _nth_gray(n: int) -> int:
|
|
|
249
248
|
|
|
250
249
|
def _multiplexed_cossin(
|
|
251
250
|
cossin_qubits: 'List[cirq.Qid]', angles: List[float], rot_func: Callable = ops.ry
|
|
252
|
-
) -> '
|
|
251
|
+
) -> Iterable['cirq.Operation']:
|
|
253
252
|
"""Performs a multiplexed rotation over all qubits in this unitary matrix,
|
|
254
253
|
|
|
255
254
|
Uses ry and rz multiplexing for quantum shannon decomposition
|
{cirq_core-1.5.0.dev20250122193029.dist-info → cirq_core-1.5.0.dev20250123021547.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.5.0.
|
|
3
|
+
Version: 1.5.0.dev20250123021547
|
|
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.5.0.dev20250122193029.dist-info → cirq_core-1.5.0.dev20250123021547.dist-info}/RECORD
RENAMED
|
@@ -4,8 +4,8 @@ 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=
|
|
8
|
-
cirq/_version_test.py,sha256=
|
|
7
|
+
cirq/_version.py,sha256=u_m_cD2d_HEazuNrgNctCw4iZELrg_GWcnlaOeAL_2U,1206
|
|
8
|
+
cirq/_version_test.py,sha256=VDv1tmDBN8bYaxwNfmiKf7uPAbAP66EmrAPvGJVRtXY,147
|
|
9
9
|
cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
|
|
10
10
|
cirq/json_resolver_cache.py,sha256=p-vEOa-8GQ2cFIAdze-kd6C1un1uRvtujVPljVKaHBg,13557
|
|
11
11
|
cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
|
|
@@ -321,7 +321,7 @@ cirq/ops/mixed_unitary_channel.py,sha256=k3O4ovH3bFs1WnAZc647IgCK8thC5JnTGxsCzjB
|
|
|
321
321
|
cirq/ops/mixed_unitary_channel_test.py,sha256=x8LIAea2KcutNupnRJ_cLy1kmxhbUh3K3BkZtg3OkKQ,5058
|
|
322
322
|
cirq/ops/named_qubit.py,sha256=niAsH7m32n3lEVIcy1nnVDPkPqk6PY2qlriz7mzgZmk,10006
|
|
323
323
|
cirq/ops/named_qubit_test.py,sha256=mtJVRe4JzFSNckMQJSGCj1P0VBtpGh--6YxKbIEE3TQ,5221
|
|
324
|
-
cirq/ops/op_tree.py,sha256=
|
|
324
|
+
cirq/ops/op_tree.py,sha256=7hcyqhuK41Rg3vDPvRPkCn6G6a_shvmxEQvnYiQfbDw,5277
|
|
325
325
|
cirq/ops/op_tree_test.py,sha256=h4phqrxQwYAfyu8o4f_fLi3WP2kdVuzWqrSCWGLHo_c,5575
|
|
326
326
|
cirq/ops/parallel_gate.py,sha256=duCtDht-HRlYM3V7JmFnB_l2rx5PRqAwyRMjug9kvnM,6318
|
|
327
327
|
cirq/ops/parallel_gate_test.py,sha256=M6o3AyXFQrwyiOTtGxlYH09TbHdjtTxCuMjmn-ALnn0,6298
|
|
@@ -923,10 +923,10 @@ cirq/sim/simulation_state_base.py,sha256=1t6dWLpxJDiVvld9kl91A9OGTNY6ZkWrceaHf-q
|
|
|
923
923
|
cirq/sim/simulation_state_test.py,sha256=ubfkvFui9zPQwC6aJw9rmehd_4oDQCi6L3Pe1EVznAE,7410
|
|
924
924
|
cirq/sim/simulation_utils.py,sha256=hsR4ea2eERW3ugNPSheE0bNBYEcJl6US-a6rmu7CSOA,2598
|
|
925
925
|
cirq/sim/simulation_utils_test.py,sha256=1YCuaKFf0JfOqdEbdYE49wlNWmhmtQKUQMIij6YyiDo,1333
|
|
926
|
-
cirq/sim/simulator.py,sha256=
|
|
926
|
+
cirq/sim/simulator.py,sha256=d5EFMunjzPATr5p3O4e8x0c-Ee3Bd3XQeOfyPXBwPsQ,42046
|
|
927
927
|
cirq/sim/simulator_base.py,sha256=mAcIKPT6lsIvAJFdSC4a-cGQFU0kegqbL80K1K7mlFM,18186
|
|
928
928
|
cirq/sim/simulator_base_test.py,sha256=Ik_28QV2Pzdc4tGxYMAVnGrNG1IWMiwuKUJcaCeuG7M,14955
|
|
929
|
-
cirq/sim/simulator_test.py,sha256=
|
|
929
|
+
cirq/sim/simulator_test.py,sha256=wlJLnCfPfIHbJ2On6Lb5iJPSxkjjgMaB5GXOJvwSby8,18589
|
|
930
930
|
cirq/sim/sparse_simulator.py,sha256=OvVjqNk5Kb92DM8Nrdw1BGOB7GFlT6yiXwIPpAcLV7I,12854
|
|
931
931
|
cirq/sim/sparse_simulator_test.py,sha256=HJQ6yDqpg2BY6KN3eFg9b-i1qsr0sImxOCuTqJRbwFI,53584
|
|
932
932
|
cirq/sim/state_vector.py,sha256=N6N9EELlW66UaLTBaq62ms0XkfIK7CzN9SBM7t52dXo,13428
|
|
@@ -1086,7 +1086,7 @@ cirq/transformers/analytical_decompositions/cphase_to_fsim.py,sha256=RDg0wzYa_YX
|
|
|
1086
1086
|
cirq/transformers/analytical_decompositions/cphase_to_fsim_test.py,sha256=bwZa0BDclAd1sX3bD-GdNF2MO5DtH7mw2YLppEK0LG0,5568
|
|
1087
1087
|
cirq/transformers/analytical_decompositions/pauli_string_decomposition.py,sha256=bU9IoY0igVZTmF_wsTdTxAfqPKWyqZ14Gt2AJoK5D_4,4524
|
|
1088
1088
|
cirq/transformers/analytical_decompositions/pauli_string_decomposition_test.py,sha256=qpFODpCJrE9piYLWR1FzweTn3v80EvLCV-PP2fbHcoE,2112
|
|
1089
|
-
cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py,sha256=
|
|
1089
|
+
cirq/transformers/analytical_decompositions/quantum_shannon_decomposition.py,sha256=ZN6qKTdGs-ZLM8uIYhs3iGBQSAkj6_CjqFNiI_EZwBI,11785
|
|
1090
1090
|
cirq/transformers/analytical_decompositions/quantum_shannon_decomposition_test.py,sha256=E7NM5NzNUVwlTcgzDs18tmnybA4DUVvGl9y6_Geikss,7685
|
|
1091
1091
|
cirq/transformers/analytical_decompositions/single_qubit_decompositions.py,sha256=iAPdMwHKM1B3mJtQWH-iNjR-VkzhkUDFC23f8kjXY6M,8436
|
|
1092
1092
|
cirq/transformers/analytical_decompositions/single_qubit_decompositions_test.py,sha256=4GfU6wctBoG-OVFqFOE08xymd5dXzY-doE8ZNpsKohI,12308
|
|
@@ -1202,8 +1202,8 @@ cirq/work/sampler.py,sha256=bE5tmVkcR6cZZMLETxDfHehdsYUMbx2RvBeIBetehI4,19187
|
|
|
1202
1202
|
cirq/work/sampler_test.py,sha256=hL2UWx3dz2ukZVNxWftiKVvJcQoLplLZdQm-k1QcA40,13282
|
|
1203
1203
|
cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
|
|
1204
1204
|
cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
|
|
1205
|
-
cirq_core-1.5.0.
|
|
1206
|
-
cirq_core-1.5.0.
|
|
1207
|
-
cirq_core-1.5.0.
|
|
1208
|
-
cirq_core-1.5.0.
|
|
1209
|
-
cirq_core-1.5.0.
|
|
1205
|
+
cirq_core-1.5.0.dev20250123021547.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1206
|
+
cirq_core-1.5.0.dev20250123021547.dist-info/METADATA,sha256=kMZkbns_CNygokLXred5EMsE3Xh9osu8fFnFNxuqxQE,2105
|
|
1207
|
+
cirq_core-1.5.0.dev20250123021547.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
|
1208
|
+
cirq_core-1.5.0.dev20250123021547.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1209
|
+
cirq_core-1.5.0.dev20250123021547.dist-info/RECORD,,
|
{cirq_core-1.5.0.dev20250122193029.dist-info → cirq_core-1.5.0.dev20250123021547.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.5.0.dev20250122193029.dist-info → cirq_core-1.5.0.dev20250123021547.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|