cirq-core 1.7.0.dev20250925223930__py3-none-any.whl → 1.7.0.dev20250926201022__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 CHANGED
@@ -28,4 +28,4 @@ if sys.version_info < (3, 11, 0): # pragma: no cover
28
28
  'of Cirq (e.g. "python -m pip install cirq==1.5.0")'
29
29
  )
30
30
 
31
- __version__ = "1.7.0.dev20250925223930"
31
+ __version__ = "1.7.0.dev20250926201022"
cirq/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq
3
3
 
4
4
 
5
5
  def test_version() -> None:
6
- assert cirq.__version__ == "1.7.0.dev20250925223930"
6
+ assert cirq.__version__ == "1.7.0.dev20250926201022"
@@ -21,8 +21,26 @@ from cirq.contrib.paulistring.clifford_target_gateset import CliffordTargetGates
21
21
 
22
22
 
23
23
  def clifford_optimized_circuit(circuit: circuits.Circuit, atol: float = 1e-8) -> circuits.Circuit:
24
- # Convert to a circuit with SingleQubitCliffordGates,
25
- # CZs and other ignored gates
24
+ """Optimizes a circuit composed of Clifford and CZ gates.
25
+
26
+ This function attempts to simplify a circuit by finding local optimizations.
27
+ It works in two stages:
28
+ 1. It converts the circuit to a target gateset consisting of
29
+ `cirq.SingleQubitCliffordGate` and `cirq.CZPowGate` gates.
30
+ 2. It then iterates through the circuit, applying the following rules:
31
+ - Merges adjacent single-qubit Clifford gates.
32
+ - Commutes single-qubit Clifford gates past CZ gates, attempting to
33
+ merge them with other single-qubit Clifford gates.
34
+ - Cancels pairs of identical CZ gates.
35
+
36
+ Args:
37
+ circuit: The circuit to optimize.
38
+ atol: A limit on the amount of absolute error introduced by the decomposition.
39
+
40
+ Returns:
41
+ The optimized circuit.
42
+ """
43
+ # Convert to a circuit with SingleQubitCliffordGates, CZs and other ignored gates.
26
44
  c_cliff = transformers.optimize_for_target_gateset(
27
45
  circuit, gateset=CliffordTargetGateset(atol=atol)
28
46
  )
cirq/ops/wait_gate.py CHANGED
@@ -16,6 +16,8 @@ from __future__ import annotations
16
16
 
17
17
  from typing import AbstractSet, Any, TYPE_CHECKING
18
18
 
19
+ import sympy
20
+
19
21
  from cirq import protocols, value
20
22
  from cirq.ops import raw_types
21
23
 
@@ -51,8 +53,11 @@ class WaitGate(raw_types.Gate):
51
53
  ValueError: If the `qid_shape` provided is empty or `num_qubits` contradicts
52
54
  `qid_shape`.
53
55
  """
54
- self._duration = value.Duration(duration)
55
- if not protocols.is_parameterized(self.duration) and self.duration < 0:
56
+ self._duration = (
57
+ duration if isinstance(duration, value.Duration) else value.Duration(duration)
58
+ )
59
+ total_picos = self.duration.total_picos()
60
+ if not isinstance(total_picos, sympy.Basic) and total_picos < 0:
56
61
  raise ValueError('duration < 0')
57
62
  if qid_shape is None:
58
63
  if num_qubits is None:
cirq/value/duration.py CHANGED
@@ -84,19 +84,19 @@ class Duration:
84
84
  """
85
85
  self._time_vals: list[_NUMERIC_INPUT_TYPE] = [0, 0, 0, 0]
86
86
  self._multipliers = [1, 1000, 1000_000, 1000_000_000]
87
- if value is not None and value != 0:
87
+ if value is not None:
88
88
  if isinstance(value, datetime.timedelta):
89
89
  # timedelta has microsecond resolution.
90
90
  self._time_vals[2] = int(value / datetime.timedelta(microseconds=1))
91
91
  elif isinstance(value, Duration):
92
92
  self._time_vals = value._time_vals
93
- else:
93
+ elif value != 0:
94
94
  raise TypeError(f'Not a `cirq.DURATION_LIKE`: {repr(value)}.')
95
95
  input_vals = [picos, nanos, micros, millis]
96
96
  self._time_vals = _add_time_vals(self._time_vals, input_vals)
97
97
 
98
98
  def _is_parameterized_(self) -> bool:
99
- return protocols.is_parameterized(self._time_vals)
99
+ return any(isinstance(val, sympy.Basic) for val in self._time_vals)
100
100
 
101
101
  def _parameter_names_(self) -> AbstractSet[str]:
102
102
  return protocols.parameter_names(self._time_vals)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.7.0.dev20250925223930
3
+ Version: 1.7.0.dev20250926201022
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
@@ -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=AyP-jMhCZv_doo5pZ3O-KjdOP8Z_Cxx8QHomagnS1Zo,1206
8
- cirq/_version_test.py,sha256=n9bB5uKZnc7YbY1pmlqMyhfKJ5iaqM6QOAbIDskSx9s,155
7
+ cirq/_version.py,sha256=fjaZ2di0NR7whUNcwGkmF3IOgPG3Wu6l1eD3zeQbTVA,1206
8
+ cirq/_version_test.py,sha256=wnUqgraEp8DfxNmFHlL6yecd_SRp3Y3LL-Az55wGXo4,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
@@ -100,7 +100,7 @@ cirq/contrib/noise_models/__init__.py,sha256=O3wvaQ6kyNZzwsCnMMZvr2EyS76LpO9xnVZ
100
100
  cirq/contrib/noise_models/noise_models.py,sha256=CJcvVQTaah5t6AC2nFTbaiSL-nTR1jtYV3ftO7nTbyo,11404
101
101
  cirq/contrib/noise_models/noise_models_test.py,sha256=htDTYcWeMtgtLIo_4DaTIidoHCxPMVIAKtS80R4OmDs,11472
102
102
  cirq/contrib/paulistring/__init__.py,sha256=1k2_MYLTMPn8AFoJvSgpN-F-6xgmDjKXRhb-FdDsFoQ,1761
103
- cirq/contrib/paulistring/clifford_optimize.py,sha256=VMdivMpQnPQhgqtasce6dOPGx6x6eIZ6Z4f1H666j-I,7859
103
+ cirq/contrib/paulistring/clifford_optimize.py,sha256=UDJ9aIJ-iFBFM5MV8n6ec7wsGluC6diC4UFXYSfep1g,8675
104
104
  cirq/contrib/paulistring/clifford_optimize_test.py,sha256=8FFLg9gb1HmHHMdXPa-vCr1zyxvgdlciRH8qyfTWQRw,3964
105
105
  cirq/contrib/paulistring/clifford_target_gateset.py,sha256=5QP4A1gC1rsTbWXB0L00ZuSGy2VZvYer63UyydCj1W0,6311
106
106
  cirq/contrib/paulistring/clifford_target_gateset_test.py,sha256=LUkfj_cahaclu2iByO3YsX-db-DLEWrAxZfxeKuJPdI,8792
@@ -392,7 +392,7 @@ cirq/ops/two_qubit_diagonal_gate.py,sha256=m2wnFpi0sHA9cxMa2cqwRYGQIlbyTGohMTLdV
392
392
  cirq/ops/two_qubit_diagonal_gate_test.py,sha256=pv24VMf2yQ-2gaHg_EUwWx5tAFvXo47_sKzdbdCPhRY,4100
393
393
  cirq/ops/uniform_superposition_gate.py,sha256=LiB_Aft5mQY5aVhe4S8DR4ugMREwXEFTVO1MCU1s0zU,4751
394
394
  cirq/ops/uniform_superposition_gate_test.py,sha256=Sd0Ty3-Tidsa0ANjn4oSNdNSfkLP6V1LauURBEmyR84,3612
395
- cirq/ops/wait_gate.py,sha256=CU_CdgkNZV5BjVnBKu-GEIdkyu787mqiQEV0fnjhLkc,5575
395
+ cirq/ops/wait_gate.py,sha256=zSD1ZVDXeKeZM9s0tvv2386C820-bs9hdEl6ex1QV0k,5710
396
396
  cirq/ops/wait_gate_test.py,sha256=BkRLYMTETWoTYh8LA1S9Yvh8u7wX4-YNVhXhiCOQIAo,3628
397
397
  cirq/protocols/__init__.py,sha256=SZCBRpL2YbYWMVcvJVR6FGkBv9aGv01oY2skSBvtNcg,6015
398
398
  cirq/protocols/act_on_protocol.py,sha256=MSwEUu8dccf05wrNmataAdIaPE1Qp6zdT1RjFiuOk5I,6858
@@ -1187,7 +1187,7 @@ cirq/value/condition.py,sha256=lJJcFiqG-r68DhhS01DS6HhQw0pDwbNq71bvH1Famec,11916
1187
1187
  cirq/value/condition_test.py,sha256=oEdim5nOYYY8UPU91H2xhb9MH8EC2WbMXTQ_DruHVO0,12949
1188
1188
  cirq/value/digits.py,sha256=-3HTHqEQqy5evUz8aLE6ruw0NV3ncuPrc5asRMQ-sQ4,6063
1189
1189
  cirq/value/digits_test.py,sha256=WDeUQTnDqZXh4JjWu_qEkzCFAtd8x1UlN9I2yjdDV3g,3848
1190
- cirq/value/duration.py,sha256=9zhnMe7EBicqbRp267GkPz97q1y1DcnPDXHqdEjJpts,10389
1190
+ cirq/value/duration.py,sha256=4K-eiCoFfzm2SM3K1OhV__YrW1GmzgA7QSkBpxOkTp8,10402
1191
1191
  cirq/value/duration_test.py,sha256=xQd5-dE8zZddsZru1P6ClV3PoeJncqLAQr3ivgZIXdQ,8281
1192
1192
  cirq/value/linear_dict.py,sha256=-wtYnPpg5X8MbaJq8xbkmDw48nTSItuhjj7Zdvwxp_A,12123
1193
1193
  cirq/value/linear_dict_test.py,sha256=eZatVgAMonquI2qys4WJx6ddUc2KDea440qHIOxlTfQ,20061
@@ -1236,8 +1236,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
1236
1236
  cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
1237
1237
  cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
1238
1238
  cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
1239
- cirq_core-1.7.0.dev20250925223930.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1240
- cirq_core-1.7.0.dev20250925223930.dist-info/METADATA,sha256=O9e_dgU7CNoZFdvYpels3Z5_mQUuIrivsf_xau9GE2o,4758
1241
- cirq_core-1.7.0.dev20250925223930.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1242
- cirq_core-1.7.0.dev20250925223930.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1243
- cirq_core-1.7.0.dev20250925223930.dist-info/RECORD,,
1239
+ cirq_core-1.7.0.dev20250926201022.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1240
+ cirq_core-1.7.0.dev20250926201022.dist-info/METADATA,sha256=9lwWfHkvg09FMfdzii9_T47nvQEsD_YFnEANCE33BeY,4758
1241
+ cirq_core-1.7.0.dev20250926201022.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
1242
+ cirq_core-1.7.0.dev20250926201022.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1243
+ cirq_core-1.7.0.dev20250926201022.dist-info/RECORD,,