cirq-core 1.7.0.dev20250902054954__py3-none-any.whl → 1.7.0.dev20250902183331__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/sim/mux.py +33 -7
- cirq/sim/mux_test.py +14 -0
- {cirq_core-1.7.0.dev20250902054954.dist-info → cirq_core-1.7.0.dev20250902183331.dist-info}/METADATA +1 -1
- {cirq_core-1.7.0.dev20250902054954.dist-info → cirq_core-1.7.0.dev20250902183331.dist-info}/RECORD +9 -9
- {cirq_core-1.7.0.dev20250902054954.dist-info → cirq_core-1.7.0.dev20250902183331.dist-info}/WHEEL +0 -0
- {cirq_core-1.7.0.dev20250902054954.dist-info → cirq_core-1.7.0.dev20250902183331.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.7.0.dev20250902054954.dist-info → cirq_core-1.7.0.dev20250902183331.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
cirq/sim/mux.py
CHANGED
|
@@ -25,6 +25,7 @@ import numpy as np
|
|
|
25
25
|
|
|
26
26
|
from cirq import circuits, devices, ops, protocols, study, value
|
|
27
27
|
from cirq._doc import document
|
|
28
|
+
from cirq.linalg import transformations
|
|
28
29
|
from cirq.sim import density_matrix_simulator, sparse_simulator
|
|
29
30
|
from cirq.sim.clifford import clifford_simulator
|
|
30
31
|
from cirq.transformers import measurement_transformers
|
|
@@ -291,16 +292,41 @@ def final_density_matrix(
|
|
|
291
292
|
return sparse_result.density_matrix_of()
|
|
292
293
|
else:
|
|
293
294
|
# noisy case: use DensityMatrixSimulator with dephasing
|
|
295
|
+
has_classical_control = circuit_like != measurement_transformers.defer_measurements(
|
|
296
|
+
circuit_like
|
|
297
|
+
)
|
|
298
|
+
handling_classical_control = ignore_measurement_results and has_classical_control
|
|
299
|
+
|
|
300
|
+
if handling_classical_control:
|
|
301
|
+
# case 1: classical control
|
|
302
|
+
noise_applied = circuit_like.with_noise(noise) if noise is not None else circuit_like
|
|
303
|
+
defered = measurement_transformers.defer_measurements(noise_applied)
|
|
304
|
+
dephased = measurement_transformers.dephase_measurements(defered)
|
|
305
|
+
program = dephased
|
|
306
|
+
elif ignore_measurement_results:
|
|
307
|
+
# case 2: no classical control, only terminal measurement
|
|
308
|
+
program = measurement_transformers.dephase_measurements(circuit_like)
|
|
309
|
+
else:
|
|
310
|
+
# case 3: no measurement
|
|
311
|
+
program = circuit_like
|
|
312
|
+
|
|
294
313
|
density_result = density_matrix_simulator.DensityMatrixSimulator(
|
|
295
|
-
dtype=dtype, noise=noise, seed=seed
|
|
314
|
+
dtype=dtype, noise=None if handling_classical_control else noise, seed=seed
|
|
296
315
|
).simulate(
|
|
297
|
-
program
|
|
298
|
-
measurement_transformers.dephase_measurements(circuit_like)
|
|
299
|
-
if ignore_measurement_results
|
|
300
|
-
else circuit_like
|
|
301
|
-
),
|
|
316
|
+
program,
|
|
302
317
|
initial_state=initial_state,
|
|
303
318
|
qubit_order=qubit_order,
|
|
304
319
|
param_resolver=param_resolver,
|
|
305
320
|
)
|
|
306
|
-
|
|
321
|
+
result = density_result.final_density_matrix
|
|
322
|
+
|
|
323
|
+
if handling_classical_control:
|
|
324
|
+
# assuming that the ancilla qubits from the transformations are at the end
|
|
325
|
+
keep = list(range(protocols.num_qubits(circuit_like)))
|
|
326
|
+
dephased_qid_shape = protocols.qid_shape(dephased)
|
|
327
|
+
tensor_form = np.reshape(result, dephased_qid_shape + dephased_qid_shape)
|
|
328
|
+
reduced_form = transformations.partial_trace(tensor_form, keep)
|
|
329
|
+
width = np.prod(protocols.qid_shape(circuit_like))
|
|
330
|
+
result = np.reshape(reduced_form, (width, width))
|
|
331
|
+
|
|
332
|
+
return result
|
cirq/sim/mux_test.py
CHANGED
|
@@ -380,6 +380,20 @@ def test_final_density_matrix_noise():
|
|
|
380
380
|
)
|
|
381
381
|
|
|
382
382
|
|
|
383
|
+
def test_final_density_matrix_classical_control():
|
|
384
|
+
q0, q1 = cirq.LineQubit.range(2)
|
|
385
|
+
circuit = cirq.Circuit(
|
|
386
|
+
cirq.H(q0),
|
|
387
|
+
cirq.measure(q0, key='a'),
|
|
388
|
+
cirq.H(q1).with_classical_controls('a'),
|
|
389
|
+
cirq.measure(q1, key='b'),
|
|
390
|
+
)
|
|
391
|
+
np.testing.assert_allclose(
|
|
392
|
+
cirq.final_density_matrix(circuit),
|
|
393
|
+
np.diag(np.array([0.5, 0.0, 0.25, 0.25], dtype=np.complex64)),
|
|
394
|
+
)
|
|
395
|
+
|
|
396
|
+
|
|
383
397
|
def test_ps_initial_state_wfn():
|
|
384
398
|
q0, q1 = cirq.LineQubit.range(2)
|
|
385
399
|
s00 = cirq.KET_ZERO(q0) * cirq.KET_ZERO(q1)
|
{cirq_core-1.7.0.dev20250902054954.dist-info → cirq_core-1.7.0.dev20250902183331.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.dev20250902183331
|
|
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.dev20250902054954.dist-info → cirq_core-1.7.0.dev20250902183331.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=116o63psUcVtaywi4BKBuPLc45Oo3zyaatH3ugnLesI,1206
|
|
8
|
+
cirq/_version_test.py,sha256=QhGawTq9k0Q07pvkmh-qomXXBoWdozye2yuxx0O5_qY,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
|
|
@@ -940,8 +940,8 @@ cirq/sim/density_matrix_simulator.py,sha256=ZvXfKs0IxBTtu93Eq207WA9hXXv4CUfvxyAz
|
|
|
940
940
|
cirq/sim/density_matrix_simulator_test.py,sha256=X2BVzl1jZeORA3aiK3X6BKFpt1pcnXhx74NA2cL9sCg,61288
|
|
941
941
|
cirq/sim/density_matrix_utils.py,sha256=W2jUIiuBve3MEECrgxUImTKw4YtaaGiscXxQEzYdViY,10273
|
|
942
942
|
cirq/sim/density_matrix_utils_test.py,sha256=9UQO6pHnWOpTJ0JobeM1vmVJc1EIwS7zmM9y6MKdXg8,14549
|
|
943
|
-
cirq/sim/mux.py,sha256=
|
|
944
|
-
cirq/sim/mux_test.py,sha256=
|
|
943
|
+
cirq/sim/mux.py,sha256=8Kalgrs_jgRN4VDcIV-6HKF3xRXk2a3Umt88xtq0eg8,13794
|
|
944
|
+
cirq/sim/mux_test.py,sha256=eyg8yquTOJwzeRA5j_wSaZjyX_aMP7eGzs59uatT_QM,14133
|
|
945
945
|
cirq/sim/simulation_product_state.py,sha256=py-gVRPis1EfyavdCW5gLhiULocrqUOTe7ZI7OD-nws,7014
|
|
946
946
|
cirq/sim/simulation_product_state_test.py,sha256=ZZeCC9a_VIehiMzyo9QQPL4PD2G2h8XVZk80IZzD5Ok,9093
|
|
947
947
|
cirq/sim/simulation_state.py,sha256=wwKjntD1XuwyUcXJGFJYwmmolYaPK5pc8_xS05cOsQg,12522
|
|
@@ -1234,8 +1234,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
|
|
|
1234
1234
|
cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
|
|
1235
1235
|
cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
|
|
1236
1236
|
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.
|
|
1237
|
+
cirq_core-1.7.0.dev20250902183331.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1238
|
+
cirq_core-1.7.0.dev20250902183331.dist-info/METADATA,sha256=BzK6Uz_PP6C83UFNepwojQ00HCH5Vmt-VvwWY7RZt-Q,4758
|
|
1239
|
+
cirq_core-1.7.0.dev20250902183331.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
1240
|
+
cirq_core-1.7.0.dev20250902183331.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1241
|
+
cirq_core-1.7.0.dev20250902183331.dist-info/RECORD,,
|
{cirq_core-1.7.0.dev20250902054954.dist-info → cirq_core-1.7.0.dev20250902183331.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|