cirq-core 1.6.0.dev20250505203257__py3-none-any.whl → 1.6.0.dev20250507172716__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/_compat_test.py +4 -1
- cirq/_version.py +1 -1
- cirq/_version_test.py +1 -1
- cirq/circuits/insert_strategy.py +7 -5
- cirq/contrib/acquaintance/gates_test.py +3 -1
- cirq/contrib/graph_device/hypergraph.py +3 -1
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py +9 -3
- cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation_test.py +2 -0
- cirq/contrib/paulistring/pauli_string_optimize.py +2 -0
- cirq/contrib/qasm_import/qasm.py +2 -0
- cirq/contrib/quimb/density_matrix.py +4 -1
- cirq/contrib/quimb/state_vector.py +4 -1
- cirq/contrib/quirk/quirk_gate.py +3 -1
- cirq/contrib/routing/router.py +2 -0
- cirq/contrib/shuffle_circuits/shuffle_circuits_with_readout_benchmarking.py +4 -0
- cirq/experiments/benchmarking/__init__.py +17 -0
- cirq/experiments/benchmarking/parallel_xeb.py +679 -0
- cirq/experiments/benchmarking/parallel_xeb_test.py +445 -0
- cirq/experiments/fidelity_estimation.py +11 -5
- cirq/experiments/two_qubit_xeb.py +4 -0
- cirq/linalg/combinators.py +4 -2
- cirq/linalg/predicates.py +6 -1
- cirq/linalg/tolerance.py +4 -1
- cirq/neutral_atoms/convert_to_neutral_atom_gates.py +9 -3
- cirq/ops/clifford_gate_test.py +3 -1
- cirq/ops/projector.py +13 -8
- cirq/transformers/gauge_compiling/cphase_gauge.py +2 -0
- cirq/vis/heatmap.py +1 -1
- cirq/work/sampler.py +33 -34
- cirq/work/sampler_test.py +6 -2
- cirq/work/zeros_sampler.py +3 -1
- cirq/work/zeros_sampler_test.py +3 -1
- {cirq_core-1.6.0.dev20250505203257.dist-info → cirq_core-1.6.0.dev20250507172716.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250505203257.dist-info → cirq_core-1.6.0.dev20250507172716.dist-info}/RECORD +37 -34
- {cirq_core-1.6.0.dev20250505203257.dist-info → cirq_core-1.6.0.dev20250507172716.dist-info}/WHEEL +0 -0
- {cirq_core-1.6.0.dev20250505203257.dist-info → cirq_core-1.6.0.dev20250507172716.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250505203257.dist-info → cirq_core-1.6.0.dev20250507172716.dist-info}/top_level.txt +0 -0
cirq/_compat_test.py
CHANGED
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
14
17
|
import collections
|
|
15
18
|
import dataclasses
|
|
16
19
|
import importlib.metadata
|
|
@@ -635,7 +638,7 @@ _repeated_child_deprecation_msg = [
|
|
|
635
638
|
] + _deprecation_origin
|
|
636
639
|
|
|
637
640
|
|
|
638
|
-
def _trace_unhandled_exceptions(*args, queue:
|
|
641
|
+
def _trace_unhandled_exceptions(*args, queue: multiprocessing.Queue, func: Callable):
|
|
639
642
|
try:
|
|
640
643
|
func(*args)
|
|
641
644
|
queue.put(None)
|
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
cirq/circuits/insert_strategy.py
CHANGED
|
@@ -14,16 +14,18 @@
|
|
|
14
14
|
|
|
15
15
|
"""Hard-coded options for adding multiple operations to a circuit."""
|
|
16
16
|
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
17
19
|
|
|
18
20
|
class InsertStrategy:
|
|
19
21
|
"""Indicates preferences on how to add multiple operations to a circuit."""
|
|
20
22
|
|
|
21
|
-
NEW:
|
|
22
|
-
NEW_THEN_INLINE:
|
|
23
|
-
INLINE:
|
|
24
|
-
EARLIEST:
|
|
23
|
+
NEW: InsertStrategy
|
|
24
|
+
NEW_THEN_INLINE: InsertStrategy
|
|
25
|
+
INLINE: InsertStrategy
|
|
26
|
+
EARLIEST: InsertStrategy
|
|
25
27
|
|
|
26
|
-
def __new__(cls, name: str, doc: str) ->
|
|
28
|
+
def __new__(cls, name: str, doc: str) -> InsertStrategy:
|
|
27
29
|
inst = getattr(cls, name, None)
|
|
28
30
|
if not inst or not isinstance(inst, cls):
|
|
29
31
|
inst = super().__new__(cls)
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
15
17
|
from itertools import combinations, product
|
|
16
18
|
from random import randint
|
|
17
19
|
from string import ascii_lowercase as alphabet
|
|
@@ -257,7 +259,7 @@ class OtherOperation(cirq.Operation):
|
|
|
257
259
|
def qubits(self) -> Tuple[cirq.Qid, ...]:
|
|
258
260
|
return self._qubits
|
|
259
261
|
|
|
260
|
-
def with_qubits(self, *new_qubits: cirq.Qid) ->
|
|
262
|
+
def with_qubits(self, *new_qubits: cirq.Qid) -> OtherOperation:
|
|
261
263
|
return type(self)(self._qubits)
|
|
262
264
|
|
|
263
265
|
def __eq__(self, other):
|
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
15
17
|
import itertools
|
|
16
18
|
import random
|
|
17
19
|
from typing import Any, Dict, FrozenSet, Hashable, Iterable, Mapping, Optional, Set, Tuple, Union
|
|
@@ -103,7 +105,7 @@ class UndirectedHypergraph:
|
|
|
103
105
|
@classmethod
|
|
104
106
|
def random(
|
|
105
107
|
cls, vertices: Union[int, Iterable], edge_probs: Mapping[int, float]
|
|
106
|
-
) ->
|
|
108
|
+
) -> UndirectedHypergraph:
|
|
107
109
|
"""A random hypergraph.
|
|
108
110
|
|
|
109
111
|
Every possible edge is included with probability edge_prob[len(edge)].
|
|
@@ -11,19 +11,25 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
+
|
|
14
15
|
"""Tools for measuring expectation values of Pauli strings with readout error mitigation."""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
15
19
|
import itertools
|
|
16
20
|
import time
|
|
17
|
-
from typing import cast, Dict, FrozenSet, List, Optional, Sequence, Tuple, Union
|
|
21
|
+
from typing import cast, Dict, FrozenSet, List, Optional, Sequence, Tuple, TYPE_CHECKING, Union
|
|
18
22
|
|
|
19
23
|
import attrs
|
|
20
24
|
import numpy as np
|
|
21
25
|
|
|
22
26
|
from cirq import circuits, ops, work
|
|
23
27
|
from cirq.contrib.shuffle_circuits import run_shuffled_with_readout_benchmarking
|
|
24
|
-
from cirq.experiments import SingleQubitReadoutCalibrationResult
|
|
25
28
|
from cirq.experiments.readout_confusion_matrix import TensoredConfusionMatrices
|
|
26
|
-
|
|
29
|
+
|
|
30
|
+
if TYPE_CHECKING:
|
|
31
|
+
from cirq.experiments import SingleQubitReadoutCalibrationResult
|
|
32
|
+
from cirq.study import ResultDict
|
|
27
33
|
|
|
28
34
|
|
|
29
35
|
@attrs.frozen
|
cirq/contrib/qasm_import/qasm.py
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
# pylint: disable=wrong-or-nonexistent-copyright-notice
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
2
5
|
from functools import lru_cache
|
|
3
6
|
from typing import Dict, List, Optional, Sequence, Tuple, Union
|
|
4
7
|
|
|
@@ -77,7 +80,7 @@ def _add_to_positions(
|
|
|
77
80
|
|
|
78
81
|
def circuit_to_density_matrix_tensors(
|
|
79
82
|
circuit: cirq.Circuit, qubits: Optional[Sequence[cirq.Qid]] = None
|
|
80
|
-
) -> Tuple[List[qtn.Tensor], Dict[
|
|
83
|
+
) -> Tuple[List[qtn.Tensor], Dict[cirq.Qid, int], Dict[Tuple[str, str], Tuple[float, float]]]:
|
|
81
84
|
"""Given a circuit with mixtures or channels, construct a tensor network
|
|
82
85
|
representation of the density matrix.
|
|
83
86
|
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
# pylint: disable=wrong-or-nonexistent-copyright-notice
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
2
5
|
import warnings
|
|
3
6
|
from typing import cast, Dict, List, Optional, Sequence, Tuple, Union
|
|
4
7
|
|
|
@@ -28,7 +31,7 @@ def circuit_to_tensors(
|
|
|
28
31
|
circuit: cirq.Circuit,
|
|
29
32
|
qubits: Optional[Sequence[cirq.Qid]] = None,
|
|
30
33
|
initial_state: Union[int, None] = 0,
|
|
31
|
-
) -> Tuple[List[qtn.Tensor], Dict[
|
|
34
|
+
) -> Tuple[List[qtn.Tensor], Dict[cirq.Qid, int], None]:
|
|
32
35
|
"""Given a circuit, construct a tensor network representation.
|
|
33
36
|
|
|
34
37
|
Indices are named "i{i}_q{x}" where i is a time index and x is a
|
cirq/contrib/quirk/quirk_gate.py
CHANGED
|
@@ -12,6 +12,8 @@
|
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
14
|
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
15
17
|
from typing import Any, Callable, cast, Dict, Optional, Union
|
|
16
18
|
|
|
17
19
|
import numpy as np
|
|
@@ -46,7 +48,7 @@ class QuirkOp:
|
|
|
46
48
|
self.keys = keys
|
|
47
49
|
self.can_merge = can_merge
|
|
48
50
|
|
|
49
|
-
def controlled(self, control_count: int = 1) ->
|
|
51
|
+
def controlled(self, control_count: int = 1) -> QuirkOp:
|
|
50
52
|
return QuirkOp(*['•'] * control_count, *self.keys, can_merge=False)
|
|
51
53
|
|
|
52
54
|
|
cirq/contrib/routing/router.py
CHANGED
|
@@ -11,7 +11,11 @@
|
|
|
11
11
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
12
|
# See the License for the specific language governing permissions and
|
|
13
13
|
# limitations under the License.
|
|
14
|
+
|
|
14
15
|
"""Tools for running circuits in a shuffled order with readout error benchmarking."""
|
|
16
|
+
|
|
17
|
+
from __future__ import annotations
|
|
18
|
+
|
|
15
19
|
import time
|
|
16
20
|
from typing import Dict, List, Optional, Tuple, Union
|
|
17
21
|
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
"""Tools for branchmarking NISQ circuits."""
|
|
16
|
+
|
|
17
|
+
from cirq.experiments.benchmarking.parallel_xeb import parallel_two_qubit_xeb
|