deltakit-compile 0.1.0__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 (168) hide show
  1. deltakit_compile-0.1.0/PKG-INFO +61 -0
  2. deltakit_compile-0.1.0/README.md +21 -0
  3. deltakit_compile-0.1.0/pyproject.toml +187 -0
  4. deltakit_compile-0.1.0/pyproject.toml.orig +187 -0
  5. deltakit_compile-0.1.0/src/deltakit_compile/__init__.py +2 -0
  6. deltakit_compile-0.1.0/src/deltakit_compile/cli.py +201 -0
  7. deltakit_compile-0.1.0/src/deltakit_compile/constants.py +6 -0
  8. deltakit_compile-0.1.0/src/deltakit_compile/context.py +62 -0
  9. deltakit_compile-0.1.0/src/deltakit_compile/dialects/__init__.py +0 -0
  10. deltakit_compile-0.1.0/src/deltakit_compile/dialects/arith.py +37 -0
  11. deltakit_compile-0.1.0/src/deltakit_compile/dialects/common/__init__.py +0 -0
  12. deltakit_compile-0.1.0/src/deltakit_compile/dialects/common/attributes.py +1114 -0
  13. deltakit_compile-0.1.0/src/deltakit_compile/dialects/common/constraints.py +634 -0
  14. deltakit_compile-0.1.0/src/deltakit_compile/dialects/common/traits.py +188 -0
  15. deltakit_compile-0.1.0/src/deltakit_compile/dialects/deltakit_stim.py +96 -0
  16. deltakit_compile-0.1.0/src/deltakit_compile/dialects/func.py +10 -0
  17. deltakit_compile-0.1.0/src/deltakit_compile/dialects/log_asm_api.py +608 -0
  18. deltakit_compile-0.1.0/src/deltakit_compile/dialects/logical_assembly.py +1135 -0
  19. deltakit_compile-0.1.0/src/deltakit_compile/dialects/ncstim.py +312 -0
  20. deltakit_compile-0.1.0/src/deltakit_compile/dialects/plaquette.py +708 -0
  21. deltakit_compile-0.1.0/src/deltakit_compile/dialects/qcore.py +3766 -0
  22. deltakit_compile-0.1.0/src/deltakit_compile/dialects/qec.py +426 -0
  23. deltakit_compile-0.1.0/src/deltakit_compile/dialects/qref.py +522 -0
  24. deltakit_compile-0.1.0/src/deltakit_compile/dialects/qstruct.py +503 -0
  25. deltakit_compile-0.1.0/src/deltakit_compile/dialects/scf.py +31 -0
  26. deltakit_compile-0.1.0/src/deltakit_compile/dialects/sobs.py +299 -0
  27. deltakit_compile-0.1.0/src/deltakit_compile/dialects/stabiliser.py +2387 -0
  28. deltakit_compile-0.1.0/src/deltakit_compile/dialects/stim.py +1395 -0
  29. deltakit_compile-0.1.0/src/deltakit_compile/dialects/tables.py +280 -0
  30. deltakit_compile-0.1.0/src/deltakit_compile/dialects/tensor.py +31 -0
  31. deltakit_compile-0.1.0/src/deltakit_compile/exceptions.py +102 -0
  32. deltakit_compile-0.1.0/src/deltakit_compile/frontend/__init__.py +0 -0
  33. deltakit_compile-0.1.0/src/deltakit_compile/frontend/circuit.py +47 -0
  34. deltakit_compile-0.1.0/src/deltakit_compile/frontend/circuit_builder.py +41 -0
  35. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/__init__.py +21 -0
  36. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_annotations.py +254 -0
  37. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_builder.py +875 -0
  38. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_circuit.py +1291 -0
  39. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_classical_expr.py +181 -0
  40. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_exceptions.py +99 -0
  41. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_gates.py +47 -0
  42. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_identifiers.py +62 -0
  43. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_measurements.py +273 -0
  44. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_pauli.py +147 -0
  45. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_program_builder.py +267 -0
  46. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_qubit_reg.py +600 -0
  47. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_sequence.py +43 -0
  48. deltakit_compile-0.1.0/src/deltakit_compile/frontend/common/_vector.py +149 -0
  49. deltakit_compile-0.1.0/src/deltakit_compile/frontend/deltakit_stim/__init__.py +18 -0
  50. deltakit_compile-0.1.0/src/deltakit_compile/frontend/deltakit_stim/_translator.py +506 -0
  51. deltakit_compile-0.1.0/src/deltakit_compile/frontend/deltakit_stim/io.py +90 -0
  52. deltakit_compile-0.1.0/src/deltakit_compile/frontend/logasm.py +1106 -0
  53. deltakit_compile-0.1.0/src/deltakit_compile/frontend/logical_assembler.py +206 -0
  54. deltakit_compile-0.1.0/src/deltakit_compile/noise_models/__init__.py +0 -0
  55. deltakit_compile-0.1.0/src/deltakit_compile/noise_models/gate_noise.py +242 -0
  56. deltakit_compile-0.1.0/src/deltakit_compile/noise_models/idle_noise.py +193 -0
  57. deltakit_compile-0.1.0/src/deltakit_compile/noise_models/no_noise.py +32 -0
  58. deltakit_compile-0.1.0/src/deltakit_compile/noise_models/noise_factory.py +61 -0
  59. deltakit_compile-0.1.0/src/deltakit_compile/noise_models/noise_parameters.py +420 -0
  60. deltakit_compile-0.1.0/src/deltakit_compile/noise_models/phenomenological_noise.py +179 -0
  61. deltakit_compile-0.1.0/src/deltakit_compile/noise_models/sd6_noise.py +74 -0
  62. deltakit_compile-0.1.0/src/deltakit_compile/noise_models/si1000_noise.py +301 -0
  63. deltakit_compile-0.1.0/src/deltakit_compile/pass_runner.py +244 -0
  64. deltakit_compile-0.1.0/src/deltakit_compile/passes/__init__.py +0 -0
  65. deltakit_compile-0.1.0/src/deltakit_compile/passes/_common.py +88 -0
  66. deltakit_compile-0.1.0/src/deltakit_compile/passes/_patterns.py +199 -0
  67. deltakit_compile-0.1.0/src/deltakit_compile/passes/_qubit_measurement_tracker.py +422 -0
  68. deltakit_compile-0.1.0/src/deltakit_compile/passes/_use_def_viewer.py +38 -0
  69. deltakit_compile-0.1.0/src/deltakit_compile/passes/add_heralds.py +54 -0
  70. deltakit_compile-0.1.0/src/deltakit_compile/passes/add_noise.py +499 -0
  71. deltakit_compile-0.1.0/src/deltakit_compile/passes/canonicalisation/__init__.py +0 -0
  72. deltakit_compile-0.1.0/src/deltakit_compile/passes/canonicalisation/logical_assembly.py +26 -0
  73. deltakit_compile-0.1.0/src/deltakit_compile/passes/canonicalisation/qcore.py +80 -0
  74. deltakit_compile-0.1.0/src/deltakit_compile/passes/canonicalisation/qref.py +16 -0
  75. deltakit_compile-0.1.0/src/deltakit_compile/passes/canonicalisation/qstruct.py +333 -0
  76. deltakit_compile-0.1.0/src/deltakit_compile/passes/canonicalisation/scf.py +36 -0
  77. deltakit_compile-0.1.0/src/deltakit_compile/passes/canonicalisation/stabiliser.py +212 -0
  78. deltakit_compile-0.1.0/src/deltakit_compile/passes/circuit_builder/__init__.py +0 -0
  79. deltakit_compile-0.1.0/src/deltakit_compile/passes/circuit_builder/pipeline.py +79 -0
  80. deltakit_compile-0.1.0/src/deltakit_compile/passes/collapse_adjacent_alloc.py +243 -0
  81. deltakit_compile-0.1.0/src/deltakit_compile/passes/combine_detector_rounds.py +608 -0
  82. deltakit_compile-0.1.0/src/deltakit_compile/passes/common/__init__.py +0 -0
  83. deltakit_compile-0.1.0/src/deltakit_compile/passes/common/pipeline.py +526 -0
  84. deltakit_compile-0.1.0/src/deltakit_compile/passes/convert_parallels_to_lockstep.py +242 -0
  85. deltakit_compile-0.1.0/src/deltakit_compile/passes/flatten_qubit_registers.py +612 -0
  86. deltakit_compile-0.1.0/src/deltakit_compile/passes/infer_detector_coords.py +88 -0
  87. deltakit_compile-0.1.0/src/deltakit_compile/passes/log_asm_api/__init__.py +0 -0
  88. deltakit_compile-0.1.0/src/deltakit_compile/passes/log_asm_api/inline_circuits_and_subroutines.py +226 -0
  89. deltakit_compile-0.1.0/src/deltakit_compile/passes/log_asm_api/lockstep_parallels.py +171 -0
  90. deltakit_compile-0.1.0/src/deltakit_compile/passes/log_asm_api/lower_qubit_tensors_to_qcore.py +1136 -0
  91. deltakit_compile-0.1.0/src/deltakit_compile/passes/log_asm_api/parallelise_log_asm_api.py +278 -0
  92. deltakit_compile-0.1.0/src/deltakit_compile/passes/log_asm_api/pipeline.py +79 -0
  93. deltakit_compile-0.1.0/src/deltakit_compile/passes/log_asm_api/split_measurement_tensors.py +381 -0
  94. deltakit_compile-0.1.0/src/deltakit_compile/passes/logical_assembly/__init__.py +0 -0
  95. deltakit_compile-0.1.0/src/deltakit_compile/passes/logical_assembly/pipeline.py +86 -0
  96. deltakit_compile-0.1.0/src/deltakit_compile/passes/lower_concrete_flows.py +100 -0
  97. deltakit_compile-0.1.0/src/deltakit_compile/passes/merge_gate_like_broadcast_ops.py +232 -0
  98. deltakit_compile-0.1.0/src/deltakit_compile/passes/parallelise_circuit.py +111 -0
  99. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/__init__.py +0 -0
  100. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/__init__.py +5 -0
  101. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/_constants.py +7 -0
  102. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/_placement.py +158 -0
  103. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/annotate_flows_from_plaquettes.py +253 -0
  104. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/backpropagate_observables.py +179 -0
  105. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/located_observable_to_move.py +64 -0
  106. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/lower_patch_declaration.py +119 -0
  107. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/patch_to_plaquettes.py +461 -0
  108. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/pipeline.py +182 -0
  109. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/place_observables.py +160 -0
  110. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/plaquette_to_circuit.py +167 -0
  111. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/plaquette_to_qstruct.py +173 -0
  112. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/schedule_plaquettes.py +173 -0
  113. deltakit_compile-0.1.0/src/deltakit_compile/passes/patch_lowering/rotated_surface/transversal_op_to_circuit.py +276 -0
  114. deltakit_compile-0.1.0/src/deltakit_compile/passes/qstruct_circuit_to_stab.py +464 -0
  115. deltakit_compile-0.1.0/src/deltakit_compile/passes/realign_qec_detectors.py +374 -0
  116. deltakit_compile-0.1.0/src/deltakit_compile/passes/remap_qubits.py +205 -0
  117. deltakit_compile-0.1.0/src/deltakit_compile/passes/serialise_circuit.py +50 -0
  118. deltakit_compile-0.1.0/src/deltakit_compile/passes/sobs_to_qec.py +371 -0
  119. deltakit_compile-0.1.0/src/deltakit_compile/passes/split_gate_like_broadcast_ops.py +93 -0
  120. deltakit_compile-0.1.0/src/deltakit_compile/passes/stab_circuit_to_qstruct.py +155 -0
  121. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/__init__.py +0 -0
  122. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/_common.py +2470 -0
  123. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/_existing_detectors.py +221 -0
  124. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/expand_states.py +410 -0
  125. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/find_detectors.py +601 -0
  126. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/generate_flows.py +896 -0
  127. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/merge_circuits.py +360 -0
  128. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/pipeline.py +72 -0
  129. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/remove_non_matching_flows.py +133 -0
  130. deltakit_compile-0.1.0/src/deltakit_compile/passes/stabiliser/verify_flows.py +129 -0
  131. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/__init__.py +0 -0
  132. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/_common.py +55 -0
  133. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/add_stim_ticks.py +90 -0
  134. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/gate_layer_parallelise.py +214 -0
  135. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/lower_physical_to_stim.py +758 -0
  136. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/physical_gate_rewrites.py +498 -0
  137. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/remove_stim_ticks.py +37 -0
  138. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/stim_export/__init__.py +0 -0
  139. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/stim_export/pipeline.py +63 -0
  140. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/stim_import/__init__.py +0 -0
  141. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/stim_import/pipeline.py +90 -0
  142. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/stim_tag_to_attributes.py +211 -0
  143. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/stim_to_qcore.py +94 -0
  144. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/stim_to_qec.py +1545 -0
  145. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/stim_to_qref.py +344 -0
  146. deltakit_compile-0.1.0/src/deltakit_compile/passes/stim/stim_to_qstruct.py +122 -0
  147. deltakit_compile-0.1.0/src/deltakit_compile/passes/unitaries_to_named_gates.py +122 -0
  148. deltakit_compile-0.1.0/src/deltakit_compile/py.typed +0 -0
  149. deltakit_compile-0.1.0/src/deltakit_compile/shared/__init__.py +0 -0
  150. deltakit_compile-0.1.0/src/deltakit_compile/shared/deltakit_stim/__init__.py +0 -0
  151. deltakit_compile-0.1.0/src/deltakit_compile/shared/deltakit_stim/gates.py +118 -0
  152. deltakit_compile-0.1.0/src/deltakit_compile/shared/patch/__init__.py +0 -0
  153. deltakit_compile-0.1.0/src/deltakit_compile/shared/patch/bounding_box.py +40 -0
  154. deltakit_compile-0.1.0/src/deltakit_compile/shared/patch/exceptions.py +14 -0
  155. deltakit_compile-0.1.0/src/deltakit_compile/shared/patch/rotated_planar/__init__.py +0 -0
  156. deltakit_compile-0.1.0/src/deltakit_compile/shared/patch/rotated_planar/_ascii.py +357 -0
  157. deltakit_compile-0.1.0/src/deltakit_compile/shared/patch/rotated_planar/_placement.py +333 -0
  158. deltakit_compile-0.1.0/src/deltakit_compile/shared/patch/rotated_planar/_stabilisers.py +205 -0
  159. deltakit_compile-0.1.0/src/deltakit_compile/utilities/__init__.py +0 -0
  160. deltakit_compile-0.1.0/src/deltakit_compile/utilities/base_enums.py +61 -0
  161. deltakit_compile-0.1.0/src/deltakit_compile/utilities/config_yaml.py +156 -0
  162. deltakit_compile-0.1.0/src/deltakit_compile/utilities/debug_ir.py +277 -0
  163. deltakit_compile-0.1.0/src/deltakit_compile/utilities/gatesets.py +127 -0
  164. deltakit_compile-0.1.0/src/deltakit_compile/utilities/ir_helpers.py +33 -0
  165. deltakit_compile-0.1.0/src/deltakit_compile/utilities/max_min_dict.py +60 -0
  166. deltakit_compile-0.1.0/src/deltakit_compile/utilities/ordered_set.py +105 -0
  167. deltakit_compile-0.1.0/src/deltakit_compile/utilities/ssa_scoping.py +384 -0
  168. deltakit_compile-0.1.0/src/deltakit_compile/utilities/traverse_from_ssa.py +984 -0
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.3
2
+ Name: deltakit-compile
3
+ Version: 0.1.0
4
+ Summary: A compiler toolkit for quantum error correction
5
+ Author: Deltakit Team
6
+ Author-email: Deltakit Team <deltakit@riverlane.com>
7
+ Classifier: Development Status :: 4 - Beta
8
+ Classifier: Intended Audience :: Science/Research
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3 :: Only
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering :: Quantum Computing
20
+ Classifier: Typing :: Typed
21
+ Requires-Dist: xdsl>=0.66,<0.69
22
+ Requires-Dist: typer>=0.15.4,<0.27
23
+ Requires-Dist: pyyaml>=6.0.3,<7
24
+ Requires-Dist: pydantic>=2.11.0a1,<3
25
+ Requires-Dist: pydantic>=2.12,<3 ; python_full_version >= '3.14'
26
+ Requires-Dist: pydantic-core>=2.28,<3
27
+ Requires-Dist: numpy>=1.25,<3
28
+ Requires-Dist: numpy>=1.26,<3 ; python_full_version >= '3.12'
29
+ Requires-Dist: numpy>=2.1,<3 ; python_full_version >= '3.13'
30
+ Requires-Dist: numpy>=2.3.4,<3 ; python_full_version >= '3.14'
31
+ Requires-Dist: deltakit-stim>=0.2.2,<0.3
32
+ Requires-Dist: typing-extensions>=4.15,<5
33
+ Requires-Python: >=3.10, <3.15
34
+ Project-URL: Homepage, https://github.com/Deltakit/deltakit-compile
35
+ Project-URL: Source, https://github.com/Deltakit/deltakit-compile
36
+ Project-URL: Documentation, https://deltakit.riverlane.com/
37
+ Project-URL: Issues, https://github.com/Deltakit/deltakit-compile/issues
38
+ Project-URL: Changelog, https://github.com/Deltakit/deltakit-compile/releases
39
+ Description-Content-Type: text/markdown
40
+
41
+ # Deltakit-compile
42
+
43
+ `deltakit-compile` is a compiler implementation for Quantum Error Correction.
44
+
45
+ ## Installation
46
+
47
+ ### With `pip`
48
+
49
+ ```
50
+ python -m pip install deltakit-compile
51
+ ```
52
+
53
+ ### With `uv`
54
+
55
+ ```
56
+ uv pip install deltakit-compile
57
+ ```
58
+
59
+ ## Basic usage
60
+
61
+ See the [public documentation](https://deltakit-docs.riverlane.com/en/latest/deltakit_compile/index.html)
@@ -0,0 +1,21 @@
1
+ # Deltakit-compile
2
+
3
+ `deltakit-compile` is a compiler implementation for Quantum Error Correction.
4
+
5
+ ## Installation
6
+
7
+ ### With `pip`
8
+
9
+ ```
10
+ python -m pip install deltakit-compile
11
+ ```
12
+
13
+ ### With `uv`
14
+
15
+ ```
16
+ uv pip install deltakit-compile
17
+ ```
18
+
19
+ ## Basic usage
20
+
21
+ See the [public documentation](https://deltakit-docs.riverlane.com/en/latest/deltakit_compile/index.html)
@@ -0,0 +1,187 @@
1
+ [project]
2
+ name = "deltakit-compile"
3
+ version = "0.1.0"
4
+ description = "A compiler toolkit for quantum error correction"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10,<3.15"
7
+ classifiers = [
8
+ "Development Status :: 4 - Beta",
9
+ "Intended Audience :: Science/Research",
10
+ "Intended Audience :: Developers",
11
+ "Operating System :: OS Independent",
12
+ "Programming Language :: Python",
13
+ "Programming Language :: Python :: 3",
14
+ "Programming Language :: Python :: 3 :: Only",
15
+ "Programming Language :: Python :: 3.10",
16
+ "Programming Language :: Python :: 3.11",
17
+ "Programming Language :: Python :: 3.12",
18
+ "Programming Language :: Python :: 3.13",
19
+ "Programming Language :: Python :: 3.14",
20
+ "Topic :: Scientific/Engineering :: Quantum Computing",
21
+ "Typing :: Typed",
22
+ ]
23
+ dependencies = [
24
+ "xdsl>=0.66,<0.69",
25
+ "typer>=0.15.4,<0.27",
26
+ "pyyaml >=6.0.3, <7",
27
+ "pydantic >=2.11.0a1, <3",
28
+ "pydantic >=2.12, <3; python_version >= '3.14'",
29
+ "pydantic-core >=2.28, <3",
30
+ "numpy >=1.25, <3",
31
+ "numpy >=1.26, <3; python_version >= '3.12'",
32
+ "numpy >=2.1, <3; python_version >= '3.13'",
33
+ "numpy >=2.3.4, <3; python_version >= '3.14'",
34
+ "deltakit-stim >=0.2.2, <0.3",
35
+ "typing_extensions >=4.15, <5",
36
+ ]
37
+
38
+ [[project.authors]]
39
+ name = "Deltakit Team"
40
+ email = "deltakit@riverlane.com"
41
+
42
+ [project.scripts]
43
+ deltakit_compile = "deltakit_compile.cli:app"
44
+
45
+ [project.urls]
46
+ Homepage = "https://github.com/Deltakit/deltakit-compile"
47
+ Source = "https://github.com/Deltakit/deltakit-compile"
48
+ Documentation = "https://deltakit.riverlane.com/"
49
+ Issues = "https://github.com/Deltakit/deltakit-compile/issues"
50
+ Changelog = "https://github.com/Deltakit/deltakit-compile/releases"
51
+
52
+ [dependency-groups]
53
+ examples = [
54
+ "ipykernel>=6.29.5,<8",
55
+ "stim >=1.14, <2",
56
+ "stim >=1.15, <2; python_version >= '3.13'",
57
+ "stim >=1.16, <2; python_version >= '3.14'",
58
+ ]
59
+ test = [
60
+ "pytest >=8.4.0, <10",
61
+ "pytest-cov >=4.0.0, <8",
62
+ "pytest-mock >=3.14.0, <4",
63
+ "pytest-xdist >=3.8.0, <4",
64
+ "pytest-json-report >=1.5.0, <2",
65
+ "filecheck >=1.0.3, <2",
66
+ "filecheckize >=0.2, <0.3",
67
+ "lit >=18.1.8, <19",
68
+ "nbclient>=0.10.2,<0.12",
69
+ "coverage >=7.7.0, <8",
70
+ "packaging >=25.0, <27",
71
+ { include-group = "examples" },
72
+ ]
73
+ typing = ["types-PyYAML >=5.4.2, <6"]
74
+ lint = [
75
+ { include-group = "typing" },
76
+ "mypy>=2.2.0,<3",
77
+ "types-networkx >=3.1, <4",
78
+ "ruff==0.15.19",
79
+ "typos >=1.34, <2",
80
+ "deptry>=0.23,<0.26",
81
+ "pydoclint >=0.8.6, <0.9",
82
+ ]
83
+ licences = ["pip-licenses >=3.5.3, <6"]
84
+ security = [
85
+ "bandit[toml] >=1.7.5, <2",
86
+ "pip-audit>=2.8.0, <3",
87
+ "ochrona >=2.0.2, <3",
88
+ ]
89
+ release = [
90
+ "python-semantic-release >=10.6.1, <11",
91
+ "packaging >=25.0, <27",
92
+ "requests>=2.32.0",
93
+ "tomlkit<0.16,>=0.13",
94
+ ]
95
+ dev = [
96
+ { include-group = "test" },
97
+ { include-group = "lint" },
98
+ { include-group = "security" },
99
+ "pre-commit >=4.2, <5",
100
+ "validate-pyproject >=0.24.1, <0.26.0",
101
+ ]
102
+
103
+ [tool.uv.build-backend]
104
+ module-name = "deltakit_compile"
105
+ module-root = "src"
106
+
107
+ [tool.mypy]
108
+ files = [
109
+ "src/**/*.py",
110
+ "tests/unit/**/*.py",
111
+ ]
112
+ enable_error_code = ["deprecated"]
113
+
114
+ [[tool.mypy.overrides]]
115
+ module = ["stim"]
116
+ follow_untyped_imports = true
117
+
118
+ [[tool.mypy.overrides]]
119
+ module = ["deltakit-stim"]
120
+ ignore_missing_imports = true
121
+
122
+ [[tool.mypy.overrides]]
123
+ module = ["deltakit_compile.*"]
124
+ disable_error_code = ["type-abstract"]
125
+ enable_error_code = ["explicit-override"]
126
+
127
+ [tool.typos.default]
128
+ extend-ignore-re = ['"id"\s*:\s*"[0-9a-f]{8,}"']
129
+
130
+ [tool.typos.default.extend-words]
131
+ iy = "iy"
132
+ iz = "iz"
133
+ IZ = "IZ"
134
+ anc = "anc"
135
+ writeable = "writeable"
136
+ CPY = "CPY"
137
+ ser = "ser"
138
+
139
+ [tool.deptry]
140
+ known_first_party = ["deltakit_compile"]
141
+ extend_exclude = ["examples"]
142
+
143
+ [tool.deptry.per_rule_ignores]
144
+ DEP001 = ["deltakit-stim"]
145
+
146
+ [tool.bandit]
147
+ exclude_dirs = [
148
+ ".github",
149
+ ".venv",
150
+ "**/lit.cfg.py",
151
+ ]
152
+ skips = ["B101"]
153
+
154
+ [tool.pytest.ini_options]
155
+ testpaths = ["tests/unit"]
156
+ filterwarnings = [
157
+ "ignore:cannot collect test class 'TestOp' because it has a __init__ constructor:pytest.PytestCollectionWarning",
158
+ "ignore:cannot collect test class 'TestTermOp' because it has a __init__ constructor:pytest.PytestCollectionWarning",
159
+ "ignore:cannot collect test class 'TestType' because it has a __init__ constructor:pytest.PytestCollectionWarning",
160
+ ]
161
+
162
+ [tool.coverage.report]
163
+ exclude_also = [
164
+ "raise NotImplementedError",
165
+ "return NotImplemented",
166
+ ]
167
+
168
+ [tool.coverage.paths]
169
+ source = [
170
+ "src/deltakit_compile",
171
+ ".venv/lib/python*/site-packages/deltakit_compile",
172
+ ]
173
+
174
+ [tool.pydoclint]
175
+ style = "google"
176
+ exclude = '\.git|\.venv.*'
177
+ arg-type-hints-in-docstring = false
178
+ check-return-types = false
179
+ check-yield-types = false
180
+ check-style-mismatch = true
181
+ require-yield-section-when-yielding-nothing = false
182
+ require-return-section-when-returning-nothing = false
183
+ skip-checking-raises = true
184
+
185
+ [build-system]
186
+ requires = ["uv_build>=0.9.15"]
187
+ build-backend = "uv_build"
@@ -0,0 +1,187 @@
1
+ [project]
2
+ name = "deltakit-compile"
3
+ version = "0.1.0"
4
+ description = "A compiler toolkit for quantum error correction"
5
+ readme = "README.md"
6
+ authors = [{ name = "Deltakit Team", email = "deltakit@riverlane.com" }]
7
+ requires-python = ">=3.10,<3.15"
8
+
9
+ classifiers = [
10
+ "Development Status :: 4 - Beta",
11
+ "Intended Audience :: Science/Research",
12
+ "Intended Audience :: Developers",
13
+ "Operating System :: OS Independent",
14
+ "Programming Language :: Python",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3 :: Only",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Programming Language :: Python :: 3.14",
22
+ "Topic :: Scientific/Engineering :: Quantum Computing",
23
+ "Typing :: Typed",
24
+ ]
25
+
26
+ dependencies = [
27
+ "xdsl>=0.66,<0.69",
28
+ "typer>=0.15.4,<0.27",
29
+ "pyyaml >=6.0.3, <7",
30
+ "pydantic >=2.11.0a1, <3",
31
+ "pydantic >=2.12, <3; python_version >= '3.14'",
32
+ "pydantic-core >=2.28, <3",
33
+ "numpy >=1.25, <3",
34
+ "numpy >=1.26, <3; python_version >= '3.12'",
35
+ "numpy >=2.1, <3; python_version >= '3.13'",
36
+ "numpy >=2.3.4, <3; python_version >= '3.14'",
37
+ "deltakit-stim >=0.2.2, <0.3",
38
+ "typing_extensions >=4.15, <5",
39
+ ]
40
+
41
+ [dependency-groups]
42
+ examples = [
43
+ "ipykernel>=6.29.5,<8",
44
+ "stim >=1.14, <2",
45
+ "stim >=1.15, <2; python_version >= '3.13'",
46
+ "stim >=1.16, <2; python_version >= '3.14'",
47
+ ]
48
+ test = [
49
+ "pytest >=8.4.0, <10",
50
+ "pytest-cov >=4.0.0, <8",
51
+ "pytest-mock >=3.14.0, <4",
52
+ "pytest-xdist >=3.8.0, <4",
53
+ "pytest-json-report >=1.5.0, <2",
54
+ "filecheck >=1.0.3, <2",
55
+ "filecheckize >=0.2, <0.3",
56
+ "lit >=18.1.8, <19",
57
+ "nbclient>=0.10.2,<0.12",
58
+ "coverage >=7.7.0, <8",
59
+ "packaging >=25.0, <27",
60
+ { include-group = "examples" },
61
+ ]
62
+ typing = ["types-PyYAML >=5.4.2, <6"]
63
+ lint = [
64
+ { include-group = "typing" },
65
+ "mypy>=2.2.0,<3",
66
+ "types-networkx >=3.1, <4",
67
+ "ruff==0.15.19",
68
+ "typos >=1.34, <2",
69
+ "deptry>=0.23,<0.26",
70
+ "pydoclint >=0.8.6, <0.9",
71
+ ]
72
+ licences = ["pip-licenses >=3.5.3, <6"]
73
+ security = [
74
+ "bandit[toml] >=1.7.5, <2",
75
+ "pip-audit>=2.8.0, <3",
76
+ "ochrona >=2.0.2, <3",
77
+ ]
78
+ release = [
79
+ "python-semantic-release >=10.6.1, <11",
80
+ "packaging >=25.0, <27",
81
+ "requests>=2.32.0",
82
+ "tomlkit<0.16,>=0.13",
83
+ ]
84
+ dev = [
85
+ { include-group = "test" },
86
+ { include-group = "lint" },
87
+ { include-group = "security" },
88
+ "pre-commit >=4.2, <5",
89
+ "validate-pyproject >=0.24.1, <0.26.0",
90
+ ]
91
+
92
+ [project.scripts]
93
+ deltakit_compile = "deltakit_compile.cli:app"
94
+
95
+ [project.urls]
96
+ Homepage = "https://github.com/Deltakit/deltakit-compile"
97
+ Source = "https://github.com/Deltakit/deltakit-compile"
98
+ Documentation = "https://deltakit.riverlane.com/"
99
+ Issues = "https://github.com/Deltakit/deltakit-compile/issues"
100
+ Changelog = "https://github.com/Deltakit/deltakit-compile/releases"
101
+
102
+ [tool.uv.build-backend]
103
+ module-name = "deltakit_compile"
104
+ module-root = "src"
105
+
106
+ [build-system]
107
+ requires = ["uv_build>=0.9.15"]
108
+ build-backend = "uv_build"
109
+
110
+ [tool.mypy]
111
+ files = ["src/**/*.py", "tests/unit/**/*.py"]
112
+ enable_error_code = ["deprecated"]
113
+
114
+ [[tool.mypy.overrides]]
115
+ module = ["stim"]
116
+ follow_untyped_imports = true
117
+
118
+ [[tool.mypy.overrides]]
119
+ module = ["deltakit-stim"]
120
+ ignore_missing_imports = true
121
+
122
+ [[tool.mypy.overrides]]
123
+ module = ["deltakit_compile.*"]
124
+ disable_error_code = ["type-abstract"]
125
+ enable_error_code = ["explicit-override"]
126
+
127
+ [tool.typos.default]
128
+ extend-ignore-re = [
129
+ # Ignore jupyter notebook cell IDs
130
+ "\"id\"\\s*:\\s*\"[0-9a-f]{8,}\"",
131
+ ]
132
+
133
+ [tool.typos.default.extend-words]
134
+ # Don't correct "iy" - often used in the context of "probability of an IY operation"
135
+ iy = "iy"
136
+ iz = "iz"
137
+ IZ = "IZ"
138
+ anc = "anc"
139
+ writeable = "writeable" # Used in numpy APIs.
140
+ CPY = "CPY" # A ruff rule identifier
141
+ ser = "ser" # Used by a pydantic function.
142
+
143
+ [tool.deptry]
144
+ known_first_party = ["deltakit_compile"]
145
+ extend_exclude = ["examples"]
146
+
147
+ [tool.deptry.per_rule_ignores]
148
+ DEP001 = ['deltakit-stim']
149
+
150
+ [tool.bandit]
151
+ exclude_dirs = ['.github', '.venv', '**/lit.cfg.py']
152
+ skips = [
153
+ 'B101', # We are happy to use asserts as part of defensive programming
154
+ ]
155
+
156
+ [tool.pytest.ini_options]
157
+ testpaths = ["tests/unit"]
158
+ filterwarnings = [
159
+ "ignore:cannot collect test class 'TestOp' because it has a __init__ constructor:pytest.PytestCollectionWarning",
160
+ "ignore:cannot collect test class 'TestTermOp' because it has a __init__ constructor:pytest.PytestCollectionWarning",
161
+ "ignore:cannot collect test class 'TestType' because it has a __init__ constructor:pytest.PytestCollectionWarning",
162
+ ]
163
+
164
+ [tool.coverage.report]
165
+ exclude_also = ["raise NotImplementedError", "return NotImplemented"]
166
+
167
+ [tool.coverage.paths]
168
+ source = [
169
+ "src/deltakit_compile",
170
+ ".venv/lib/python*/site-packages/deltakit_compile",
171
+ ]
172
+
173
+ [tool.pydoclint]
174
+ style = 'google'
175
+ exclude = '\.git|\.venv.*'
176
+ # We do not want type hints to be duplicated in docstrings.
177
+ arg-type-hints-in-docstring = false
178
+ check-return-types = false
179
+ check-yield-types = false
180
+ # Ensure that Google style is used
181
+ check-style-mismatch = true
182
+ # Empty yields or returns do not have to be documented.
183
+ require-yield-section-when-yielding-nothing = false
184
+ require-return-section-when-returning-nothing = false
185
+ # The raise checks are oddly restrictive - forcing us to document exceptions in the function
186
+ # body and nothing more.
187
+ skip-checking-raises = true
@@ -0,0 +1,2 @@
1
+ # (c) Copyright Riverlane 2025-2026. All rights reserved.
2
+ """deltakit-compile is the compiler infrastructure of Deltakit."""
@@ -0,0 +1,201 @@
1
+ # (c) Copyright Riverlane 2025-2026. All rights reserved.
2
+ """
3
+ CLI module
4
+ """
5
+
6
+ import importlib.metadata
7
+ import json
8
+ from pathlib import Path
9
+ from typing import Annotated
10
+
11
+ import typer
12
+ from deltakit_stim import Circuit
13
+ from typer.core import TyperGroup
14
+ from typing_extensions import override
15
+ from xdsl.parser import Parser
16
+
17
+ from deltakit_compile.constants import DIST_NAME
18
+ from deltakit_compile.frontend.deltakit_stim.io import (
19
+ deltakit_stim_circuit_to_dialect,
20
+ deltakit_stim_context,
21
+ deltakit_stim_dialect_to_circuit,
22
+ )
23
+ from deltakit_compile.pass_runner import ArgumentDict, PassRunner
24
+
25
+
26
+ class OrderCommands(TyperGroup):
27
+ """Subclass enforcing that commands are ordered in alphabetical order in the help messages."""
28
+
29
+ @override
30
+ def list_commands(self, ctx):
31
+ return sorted(self.commands)
32
+
33
+
34
+ app = typer.Typer(
35
+ cls=OrderCommands,
36
+ add_completion=False,
37
+ no_args_is_help=True,
38
+ pretty_exceptions_show_locals=False,
39
+ )
40
+
41
+
42
+ # region Deltakit-Stim commands
43
+
44
+ deltakit_stim_app = typer.Typer(
45
+ cls=OrderCommands,
46
+ add_completion=False,
47
+ no_args_is_help=True,
48
+ pretty_exceptions_show_locals=False,
49
+ )
50
+ app.add_typer(
51
+ deltakit_stim_app,
52
+ name="deltakit-stim",
53
+ help="Commands for converting between MLIR and Deltakit-Stim circuits.",
54
+ )
55
+
56
+
57
+ @deltakit_stim_app.command("parse")
58
+ def parse_deltakit_stim(
59
+ input_path: Annotated[
60
+ Path,
61
+ typer.Argument(
62
+ exists=True, dir_okay=False, help="Path to the input Deltakit-Stim circuit."
63
+ ),
64
+ ],
65
+ output_path: Annotated[
66
+ Path | None,
67
+ typer.Option(
68
+ "--output",
69
+ "-O",
70
+ help="Destination path for the output MLIR file. "
71
+ "If not specified, it's next to the input file with an _out suffix.",
72
+ ),
73
+ ] = None,
74
+ ) -> None:
75
+ """Convert a Deltakit-Stim circuit to an MLIR file containing operations from Deltakit's stim
76
+ and deltakit-stim dialects."""
77
+ circuit = Circuit.from_file(input_path)
78
+ module_op = deltakit_stim_circuit_to_dialect(circuit)
79
+
80
+ # If no output path provided, use input filename with _out
81
+ if output_path is None:
82
+ output_path = input_path.with_name(f"{input_path.stem}_out.mlir")
83
+
84
+ output_path.write_text(str(module_op), encoding="utf-8")
85
+ print(f"Output program file saved at: {output_path}") # noqa: T201
86
+
87
+
88
+ @deltakit_stim_app.command("print")
89
+ def print_deltakit_stim(
90
+ input_path: Annotated[
91
+ Path, typer.Argument(exists=True, dir_okay=False, help="Path to the input MLIR file.")
92
+ ],
93
+ output_path: Annotated[
94
+ Path | None,
95
+ typer.Option(
96
+ "--output",
97
+ "-O",
98
+ help="Destination path for the output Deltakit-Stim circuit. "
99
+ "If not specified, it's next to the input file with an _out suffix.",
100
+ ),
101
+ ] = None,
102
+ ) -> None:
103
+ """Convert an MLIR file containing operations from Deltakit's stim and deltakit-stim dialects
104
+ into a Deltakit-Stim circuit."""
105
+ module_str = input_path.read_text(encoding="utf-8")
106
+ module_op = Parser(deltakit_stim_context(), module_str).parse_module()
107
+ circuit = deltakit_stim_dialect_to_circuit(module_op)
108
+
109
+ # If no output path provided, use input filename with _out
110
+ if output_path is None:
111
+ output_path = input_path.with_name(f"{input_path.stem}_out.stim")
112
+
113
+ circuit.to_file(output_path)
114
+ print(f"Output program file saved at: {output_path}") # noqa: T201
115
+
116
+
117
+ # endregion
118
+
119
+ # region root commands
120
+
121
+
122
+ def _parse_pass_arguments(params_str: str) -> ArgumentDict:
123
+ """Parse a JSON string of pass arguments into a dictionary."""
124
+ try:
125
+ input_parameters = json.loads(params_str)
126
+ if not isinstance(input_parameters, dict):
127
+ msg = f"Pass arguments are {type(input_parameters)}, but should be a dictionary"
128
+ raise ValueError(msg)
129
+
130
+ return input_parameters
131
+ except ValueError as exp:
132
+ msg = "Pass arguments must be in a valid JSON dictionary"
133
+ raise ValueError(msg) from exp
134
+
135
+
136
+ @app.command("compile-passes")
137
+ def compile_passes(
138
+ input_path: Annotated[
139
+ Path,
140
+ typer.Argument(exists=True, dir_okay=False, help="Path to the input program file."),
141
+ ],
142
+ output_path: Annotated[
143
+ Path | None,
144
+ typer.Option(
145
+ "--output",
146
+ "-O",
147
+ help="Destination path for the compiled file. "
148
+ "If not specified, it defaults to the input file's directory with an _out suffix.",
149
+ ),
150
+ ] = None,
151
+ passes: Annotated[
152
+ list[str] | None,
153
+ typer.Option(
154
+ "--pass",
155
+ "-p",
156
+ help="Compiler pass to be run on the input file. "
157
+ "Use this multiple times for multiple passes, run in the order listed.",
158
+ ),
159
+ ] = None,
160
+ pass_args: str = typer.Option(
161
+ default="{}",
162
+ help="Additional arguments to be provided to the compiler passes. "
163
+ "These must be in the form of a JSON dict, e.g. '{\"param\": 0xFF}'.",
164
+ ),
165
+ test_mode: Annotated[
166
+ bool,
167
+ typer.Option(
168
+ "--test-mode",
169
+ "-t",
170
+ help="Flag to enable a testing mode where the Test dialect can be used.",
171
+ ),
172
+ ] = False,
173
+ ) -> None:
174
+ """Run individual compiler passes on an MLIR file.
175
+
176
+ With this you can run any passes in any order with any arguments with no guard rails (for
177
+ testing and experimentation). Multiple module ops can be in the same input MLIR file (treated as
178
+ separate programs) if separated by '// ----' lines."""
179
+ program = input_path.read_text(encoding="utf-8")
180
+ params = _parse_pass_arguments(pass_args)
181
+ output_program = PassRunner(include_test_dialect=test_mode).run(
182
+ program, passes if passes is not None else [], params
183
+ )
184
+
185
+ if output_path is None:
186
+ output_path = input_path.with_name(f"{input_path.stem}_out.mlir")
187
+
188
+ output_path.write_text(output_program, encoding="utf-8")
189
+ print(f"Output program file saved at: {output_path}") # noqa: T201
190
+
191
+
192
+ @app.command("version")
193
+ def deltakit_compile_version() -> None:
194
+ """Print the version of deltakit_compile."""
195
+ print(f"deltakit_compile v{importlib.metadata.version(DIST_NAME)}") # noqa: T201
196
+
197
+
198
+ # endregion
199
+
200
+ if __name__ == "__main__": # pragma: no cover
201
+ app()
@@ -0,0 +1,6 @@
1
+ # (c) Copyright Riverlane 2025-2026. All rights reserved.
2
+ """Constants for deltakit_compile package."""
3
+
4
+ from typing import Final
5
+
6
+ DIST_NAME: Final[str] = "deltakit_compile"