stimcirq 1.15.dev1741048818__tar.gz → 1.15.dev1741126803__tar.gz

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.
Files changed (33) hide show
  1. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/PKG-INFO +1 -1
  2. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/setup.py +1 -1
  3. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/__init__.py +1 -1
  4. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_cirq_to_stim.py +14 -10
  5. stimcirq-1.15.dev1741126803/stimcirq/_ii_gate.py +40 -0
  6. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_stim_to_cirq.py +31 -0
  7. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq.egg-info/PKG-INFO +1 -1
  8. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq.egg-info/SOURCES.txt +1 -0
  9. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/README.md +0 -0
  10. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/setup.cfg +0 -0
  11. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_cirq_to_stim_test.py +0 -0
  12. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_cx_swap_gate.py +0 -0
  13. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_cx_swap_test.py +0 -0
  14. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_cz_swap_gate.py +0 -0
  15. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_cz_swap_test.py +0 -0
  16. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_det_annotation.py +0 -0
  17. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_det_annotation_test.py +0 -0
  18. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_measure_and_or_reset_gate.py +0 -0
  19. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_measure_and_or_reset_gate_test.py +0 -0
  20. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_obs_annotation.py +0 -0
  21. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_obs_annotation_test.py +0 -0
  22. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_shift_coords_annotation.py +0 -0
  23. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_shift_coords_annotation_test.py +0 -0
  24. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_stim_sampler.py +0 -0
  25. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_stim_sampler_test.py +0 -0
  26. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_stim_to_cirq_test.py +0 -0
  27. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_sweep_pauli.py +0 -0
  28. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_sweep_pauli_test.py +0 -0
  29. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_two_qubit_asymmetric_depolarize.py +0 -0
  30. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq/_two_qubit_asymmetric_depolarize_test.py +0 -0
  31. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq.egg-info/dependency_links.txt +0 -0
  32. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq.egg-info/requires.txt +0 -0
  33. {stimcirq-1.15.dev1741048818 → stimcirq-1.15.dev1741126803}/stimcirq.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: stimcirq
3
- Version: 1.15.dev1741048818
3
+ Version: 1.15.dev1741126803
4
4
  Summary: Implements a cirq.Sampler backed by stim.
5
5
  Home-page: https://github.com/quantumlib/stim
6
6
  Author: Craig Gidney
@@ -17,7 +17,7 @@ from setuptools import setup
17
17
  with open('README.md', encoding='UTF-8') as f:
18
18
  long_description = f.read()
19
19
 
20
- __version__ = '1.15.dev1741048818'
20
+ __version__ = '1.15.dev1741126803'
21
21
 
22
22
  setup(
23
23
  name='stimcirq',
@@ -1,4 +1,4 @@
1
- __version__ = '1.15.dev1741048818'
1
+ __version__ = '1.15.dev1741126803'
2
2
  from ._cirq_to_stim import cirq_circuit_to_stim_circuit
3
3
  from ._cx_swap_gate import CXSwapGate
4
4
  from ._cz_swap_gate import CZSwapGate
@@ -6,6 +6,8 @@ from typing import Callable, cast, Dict, Iterable, List, Optional, Sequence, Tup
6
6
  import cirq
7
7
  import stim
8
8
 
9
+ from ._ii_gate import IIGate
10
+
9
11
 
10
12
  def _forward_single_str_tag(op: cirq.CircuitOperation) -> str:
11
13
  tags = [tag for tag in op.tags if isinstance(tag, str)]
@@ -219,27 +221,27 @@ def gate_to_stim_append_func() -> Dict[cirq.Gate, Callable[[stim.Circuit, List[i
219
221
  sqcg(x, y): use("SQRT_X_DAG"),
220
222
  sqcg(x, ny): use("SQRT_X"),
221
223
  sqcg(nx, y): use("H_YZ"),
222
- sqcg(nx, ny): use("H_YZ", "X"),
224
+ sqcg(nx, ny): use("H_NYZ"),
223
225
  sqcg(x, z): do_nothing,
224
226
  sqcg(x, nz): use("X"),
225
227
  sqcg(nx, z): use("Z"),
226
228
  sqcg(nx, nz): use("Y"),
227
229
  sqcg(y, x): use("C_XYZ"),
228
- sqcg(y, nx): use("S", "SQRT_Y_DAG"),
229
- sqcg(ny, x): use("S_DAG", "SQRT_Y"),
230
- sqcg(ny, nx): use("S_DAG", "SQRT_Y_DAG"),
230
+ sqcg(y, nx): use("C_XYNZ"),
231
+ sqcg(ny, x): use("C_XNYZ"),
232
+ sqcg(ny, nx): use("C_NXYZ"),
231
233
  sqcg(y, z): use("S"),
232
234
  sqcg(y, nz): use("H_XY"),
233
235
  sqcg(ny, z): use("S_DAG"),
234
- sqcg(ny, nz): use("H_XY", "Z"),
236
+ sqcg(ny, nz): use("H_NXY"),
235
237
  sqcg(z, x): use("H"),
236
238
  sqcg(z, nx): use("SQRT_Y_DAG"),
237
239
  sqcg(nz, x): use("SQRT_Y"),
238
- sqcg(nz, nx): use("H", "Y"),
240
+ sqcg(nz, nx): use("H_NXZ"),
239
241
  sqcg(z, y): use("C_ZYX"),
240
- sqcg(z, ny): use("SQRT_Y_DAG", "S"),
241
- sqcg(nz, y): use("SQRT_Y", "S"),
242
- sqcg(nz, ny): use("SQRT_Y", "S_DAG"),
242
+ sqcg(z, ny): use("C_ZNYX"),
243
+ sqcg(nz, y): use("C_ZYNX"),
244
+ sqcg(nz, ny): use("C_NZYX"),
243
245
  # All 36 cirq.PauliInteractionGate instances.
244
246
  **{
245
247
  cirq.PauliInteractionGate(p0, s0, p1, s1): use(
@@ -410,8 +412,10 @@ def _stim_append_controlled_gate(c: stim.Circuit, g: cirq.ControlledGate, t: Lis
410
412
 
411
413
 
412
414
  def _stim_append_random_gate_channel(c: stim.Circuit, g: cirq.RandomGateChannel, t: List[int], tag: str):
413
- if g.sub_gate in [cirq.X, cirq.Y, cirq.Z]:
415
+ if g.sub_gate in [cirq.X, cirq.Y, cirq.Z, cirq.I]:
414
416
  c.append(f"{g.sub_gate}_ERROR", t, g.probability, tag=tag)
417
+ elif isinstance(g.sub_gate, IIGate):
418
+ c.append(f"II_ERROR", t, g.probability, tag=tag)
415
419
  elif isinstance(g.sub_gate, cirq.DensePauliString):
416
420
  target_p = [None, stim.target_x, stim.target_y, stim.target_z]
417
421
  pauli_targets = [target_p[p](t) for t, p in zip(t, g.sub_gate.pauli_mask) if p]
@@ -0,0 +1,40 @@
1
+ from typing import Any, Dict, List
2
+
3
+ import cirq
4
+ import stim
5
+
6
+
7
+ @cirq.value_equality
8
+ class IIGate(cirq.Gate):
9
+ """Handles explaining stim's II gate to cirq."""
10
+
11
+ def _num_qubits_(self) -> int:
12
+ return 2
13
+
14
+ def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> List[str]:
15
+ return ['II', 'II']
16
+
17
+ def _value_equality_values_(self):
18
+ return ()
19
+
20
+ def _decompose_(self, qubits):
21
+ pass
22
+
23
+ def _stim_conversion_(self, edit_circuit: stim.Circuit, targets: List[int], tag: str, **kwargs):
24
+ edit_circuit.append('II', targets, tag=tag)
25
+
26
+ def __pow__(self, power: int) -> 'IIGate':
27
+ return self
28
+
29
+ def __str__(self) -> str:
30
+ return 'II'
31
+
32
+ def __repr__(self):
33
+ return f'stimcirq.IIGate()'
34
+
35
+ @staticmethod
36
+ def _json_namespace_() -> str:
37
+ return ''
38
+
39
+ def _json_dict_(self) -> Dict[str, Any]:
40
+ return {}
@@ -18,6 +18,7 @@ import stim
18
18
  from ._cx_swap_gate import CXSwapGate
19
19
  from ._cz_swap_gate import CZSwapGate
20
20
  from ._det_annotation import DetAnnotation
21
+ from ._ii_gate import IIGate
21
22
  from ._measure_and_or_reset_gate import MeasureAndOrResetGate
22
23
  from ._obs_annotation import CumulativeObservableAnnotation
23
24
  from ._shift_coords_annotation import ShiftCoordsAnnotation
@@ -499,6 +500,7 @@ class CircuitTranslationTracker:
499
500
  ),
500
501
  "RZ": gate(cirq.ResetChannel()),
501
502
  "I": gate(cirq.I),
503
+ "II": gate(IIGate()),
502
504
  "X": gate(cirq.X),
503
505
  "Y": gate(cirq.Y),
504
506
  "Z": gate(cirq.Z),
@@ -507,9 +509,18 @@ class CircuitTranslationTracker:
507
509
  ),
508
510
  "H": gate(cirq.H),
509
511
  "H_XZ": gate(cirq.H),
512
+ "H_NXZ": gate(
513
+ cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Z, True), z_to=(cirq.X, True))
514
+ ),
510
515
  "H_YZ": gate(
511
516
  cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.X, True), z_to=(cirq.Y, False))
512
517
  ),
518
+ "H_NXY": gate(
519
+ cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Y, True), z_to=(cirq.Z, True))
520
+ ),
521
+ "H_NYZ": gate(
522
+ cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.X, True), z_to=(cirq.Y, True))
523
+ ),
513
524
  "SQRT_X": gate(cirq.X ** 0.5),
514
525
  "SQRT_X_DAG": gate(cirq.X ** -0.5),
515
526
  "SQRT_Y": gate(cirq.Y ** 0.5),
@@ -517,9 +528,27 @@ class CircuitTranslationTracker:
517
528
  "C_XYZ": gate(
518
529
  cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Y, False), z_to=(cirq.X, False))
519
530
  ),
531
+ "C_NXYZ": gate(
532
+ cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Y, True), z_to=(cirq.X, True))
533
+ ),
534
+ "C_XNYZ": gate(
535
+ cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Y, True), z_to=(cirq.X, False))
536
+ ),
537
+ "C_XYNZ": gate(
538
+ cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Y, False), z_to=(cirq.X, True))
539
+ ),
520
540
  "C_ZYX": gate(
521
541
  cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Z, False), z_to=(cirq.Y, False))
522
542
  ),
543
+ "C_NZYX": gate(
544
+ cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Z, True), z_to=(cirq.Y, True))
545
+ ),
546
+ "C_ZNYX": gate(
547
+ cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Z, False), z_to=(cirq.Y, True))
548
+ ),
549
+ "C_ZYNX": gate(
550
+ cirq.SingleQubitCliffordGate.from_xz_map(x_to=(cirq.Z, True), z_to=(cirq.Y, False))
551
+ ),
523
552
  "SQRT_XX": gate(cirq.XX ** 0.5),
524
553
  "SQRT_YY": gate(cirq.YY ** 0.5),
525
554
  "SQRT_ZZ": gate(cirq.ZZ ** 0.5),
@@ -551,6 +580,8 @@ class CircuitTranslationTracker:
551
580
  "X_ERROR": noise(cirq.X.with_probability),
552
581
  "Y_ERROR": noise(cirq.Y.with_probability),
553
582
  "Z_ERROR": noise(cirq.Z.with_probability),
583
+ "I_ERROR": noise(cirq.I.with_probability),
584
+ "II_ERROR": noise(IIGate().with_probability),
554
585
  "PAULI_CHANNEL_1": CircuitTranslationTracker.process_pauli_channel_1,
555
586
  "PAULI_CHANNEL_2": CircuitTranslationTracker.process_pauli_channel_2,
556
587
  "ELSE_CORRELATED_ERROR": not_impl(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: stimcirq
3
- Version: 1.15.dev1741048818
3
+ Version: 1.15.dev1741126803
4
4
  Summary: Implements a cirq.Sampler backed by stim.
5
5
  Home-page: https://github.com/quantumlib/stim
6
6
  Author: Craig Gidney
@@ -9,6 +9,7 @@ stimcirq/_cz_swap_gate.py
9
9
  stimcirq/_cz_swap_test.py
10
10
  stimcirq/_det_annotation.py
11
11
  stimcirq/_det_annotation_test.py
12
+ stimcirq/_ii_gate.py
12
13
  stimcirq/_measure_and_or_reset_gate.py
13
14
  stimcirq/_measure_and_or_reset_gate_test.py
14
15
  stimcirq/_obs_annotation.py