bloqade-circuit 0.4.1__tar.gz → 0.4.2__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.

Potentially problematic release.


This version of bloqade-circuit might be problematic. Click here for more details.

Files changed (303) hide show
  1. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/PKG-INFO +1 -1
  2. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/pyproject.toml +1 -1
  3. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parse/lowering.py +67 -73
  4. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/squin/test_noise.py +1 -1
  5. bloqade_circuit-0.4.2/test/qasm2/test_lowering.py +165 -0
  6. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/uv.lock +1 -1
  7. bloqade_circuit-0.4.1/test/qasm2/test_lowering.py +0 -79
  8. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/.github/dependabot.yml +0 -0
  9. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/.github/workflows/ci.yml +0 -0
  10. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/.github/workflows/isort.yml +0 -0
  11. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/.github/workflows/lint.yml +0 -0
  12. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/.github/workflows/release.yml +0 -0
  13. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/.gitignore +0 -0
  14. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/.pre-commit-config.yaml +0 -0
  15. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/LICENSE +0 -0
  16. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/README.md +0 -0
  17. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/_typos.toml +0 -0
  18. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/justfile +0 -0
  19. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/analysis/__init__.py +0 -0
  20. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/analysis/address/__init__.py +0 -0
  21. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/analysis/address/analysis.py +0 -0
  22. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/analysis/address/impls.py +0 -0
  23. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/analysis/address/lattice.py +0 -0
  24. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/analysis/fidelity/__init__.py +0 -0
  25. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/analysis/fidelity/analysis.py +0 -0
  26. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/device.py +0 -0
  27. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/__init__.py +0 -0
  28. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/base.py +0 -0
  29. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/device.py +0 -0
  30. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/noise/__init__.py +0 -0
  31. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/noise/native.py +0 -0
  32. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/qasm2/__init__.py +0 -0
  33. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/qasm2/core.py +0 -0
  34. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/qasm2/glob.py +0 -0
  35. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/qasm2/parallel.py +0 -0
  36. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/qasm2/uop.py +0 -0
  37. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/reg.py +0 -0
  38. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/squin/__init__.py +0 -0
  39. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/squin/noise/__init__.py +0 -0
  40. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/squin/noise/native.py +0 -0
  41. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/squin/op.py +0 -0
  42. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/squin/qubit.py +0 -0
  43. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/squin/runtime.py +0 -0
  44. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/squin/wire.py +0 -0
  45. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/target.py +0 -0
  46. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/pyqrack/task.py +0 -0
  47. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/__init__.py +0 -0
  48. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/_qasm_loading.py +0 -0
  49. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/_wrappers.py +0 -0
  50. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/__init__.py +0 -0
  51. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/core/__init__.py +0 -0
  52. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/core/_dialect.py +0 -0
  53. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/core/_emit.py +0 -0
  54. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/core/_typeinfer.py +0 -0
  55. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/core/address.py +0 -0
  56. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/core/stmts.py +0 -0
  57. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/expr/__init__.py +0 -0
  58. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/expr/_dialect.py +0 -0
  59. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/expr/_emit.py +0 -0
  60. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/expr/_from_python.py +0 -0
  61. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/expr/_interp.py +0 -0
  62. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/expr/stmts.py +0 -0
  63. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/glob.py +0 -0
  64. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/indexing.py +0 -0
  65. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/inline.py +0 -0
  66. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/noise/__init__.py +0 -0
  67. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/noise/_dialect.py +0 -0
  68. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/noise/fidelity.py +0 -0
  69. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/noise/model.py +0 -0
  70. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/noise/stmts.py +0 -0
  71. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/parallel.py +0 -0
  72. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/uop/__init__.py +0 -0
  73. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/uop/_dialect.py +0 -0
  74. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/uop/_emit.py +0 -0
  75. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/uop/schedule.py +0 -0
  76. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/dialects/uop/stmts.py +0 -0
  77. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/emit/__init__.py +0 -0
  78. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/emit/base.py +0 -0
  79. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/emit/gate.py +0 -0
  80. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/emit/impls/__init__.py +0 -0
  81. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/emit/impls/noise.py +0 -0
  82. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/emit/main.py +0 -0
  83. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/emit/target.py +0 -0
  84. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/glob.py +0 -0
  85. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/groups.py +0 -0
  86. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/noise.py +0 -0
  87. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parallel.py +0 -0
  88. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parse/__init__.py +0 -0
  89. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parse/ast.py +0 -0
  90. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parse/build.py +0 -0
  91. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parse/parser.py +0 -0
  92. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parse/print.py +0 -0
  93. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parse/qasm2.lark +0 -0
  94. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parse/visitor.py +0 -0
  95. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/parse/visitor.pyi +0 -0
  96. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/passes/__init__.py +0 -0
  97. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/passes/fold.py +0 -0
  98. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/passes/glob.py +0 -0
  99. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/passes/lift_qubits.py +0 -0
  100. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/passes/noise.py +0 -0
  101. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/passes/parallel.py +0 -0
  102. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/passes/py2qasm.py +0 -0
  103. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/passes/qasm2py.py +0 -0
  104. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/passes/unroll_if.py +0 -0
  105. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/__init__.py +0 -0
  106. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/desugar.py +0 -0
  107. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/glob.py +0 -0
  108. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/insert_qubits.py +0 -0
  109. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/native_gates.py +0 -0
  110. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/noise/__init__.py +0 -0
  111. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/noise/heuristic_noise.py +0 -0
  112. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/noise/remove_noise.py +0 -0
  113. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/parallel_to_uop.py +0 -0
  114. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/register.py +0 -0
  115. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/split_ifs.py +0 -0
  116. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/rewrite/uop_to_parallel.py +0 -0
  117. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qasm2/types.py +0 -0
  118. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qbraid/__init__.py +0 -0
  119. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qbraid/lowering.py +0 -0
  120. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qbraid/schema.py +0 -0
  121. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qbraid/simulation_result.py +0 -0
  122. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/qbraid/target.py +0 -0
  123. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/__init__.py +0 -0
  124. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/analysis/__init__.py +0 -0
  125. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/analysis/nsites/__init__.py +0 -0
  126. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/analysis/nsites/analysis.py +0 -0
  127. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/analysis/nsites/impls.py +0 -0
  128. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/analysis/nsites/lattice.py +0 -0
  129. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/analysis/schedule.py +0 -0
  130. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/cirq/__init__.py +0 -0
  131. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/cirq/lowering.py +0 -0
  132. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/groups.py +0 -0
  133. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/lowering.py +0 -0
  134. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/noise/__init__.py +0 -0
  135. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/noise/_dialect.py +0 -0
  136. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/noise/_wrapper.py +0 -0
  137. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/noise/rewrite.py +0 -0
  138. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/noise/stmts.py +0 -0
  139. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/op/__init__.py +0 -0
  140. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/op/_dialect.py +0 -0
  141. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/op/_wrapper.py +0 -0
  142. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/op/number.py +0 -0
  143. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/op/rewrite.py +0 -0
  144. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/op/stdlib.py +0 -0
  145. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/op/stmts.py +0 -0
  146. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/op/traits.py +0 -0
  147. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/op/types.py +0 -0
  148. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/passes/__init__.py +0 -0
  149. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/passes/stim.py +0 -0
  150. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/qubit.py +0 -0
  151. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/rewrite/__init__.py +0 -0
  152. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/rewrite/desugar.py +0 -0
  153. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/rewrite/qubit_to_stim.py +0 -0
  154. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/rewrite/squin_measure.py +0 -0
  155. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/rewrite/stim_rewrite_util.py +0 -0
  156. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/rewrite/wire_identity_elimination.py +0 -0
  157. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/rewrite/wire_to_stim.py +0 -0
  158. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/rewrite/wrap_analysis.py +0 -0
  159. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/squin/wire.py +0 -0
  160. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/__init__.py +0 -0
  161. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/_wrappers.py +0 -0
  162. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/__init__.py +0 -0
  163. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/auxiliary/__init__.py +0 -0
  164. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/auxiliary/_dialect.py +0 -0
  165. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/auxiliary/emit.py +0 -0
  166. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/auxiliary/interp.py +0 -0
  167. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/auxiliary/lowering.py +0 -0
  168. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/auxiliary/stmts/__init__.py +0 -0
  169. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/auxiliary/stmts/annotate.py +0 -0
  170. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/auxiliary/stmts/const.py +0 -0
  171. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/auxiliary/types.py +0 -0
  172. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/collapse/__init__.py +0 -0
  173. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/collapse/_dialect.py +0 -0
  174. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/collapse/emit_str.py +0 -0
  175. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/collapse/stmts/__init__.py +0 -0
  176. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/collapse/stmts/measure.py +0 -0
  177. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/collapse/stmts/pp_measure.py +0 -0
  178. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/collapse/stmts/reset.py +0 -0
  179. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/gate/__init__.py +0 -0
  180. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/gate/_dialect.py +0 -0
  181. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/gate/emit.py +0 -0
  182. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/gate/stmts/__init__.py +0 -0
  183. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/gate/stmts/base.py +0 -0
  184. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/gate/stmts/clifford_1q.py +0 -0
  185. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/gate/stmts/clifford_2q.py +0 -0
  186. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/gate/stmts/control_2q.py +0 -0
  187. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/gate/stmts/pp.py +0 -0
  188. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/noise/__init__.py +0 -0
  189. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/noise/_dialect.py +0 -0
  190. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/noise/emit.py +0 -0
  191. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/dialects/noise/stmts.py +0 -0
  192. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/emit/__init__.py +0 -0
  193. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/emit/stim_str.py +0 -0
  194. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/groups.py +0 -0
  195. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/parse/__init__.py +0 -0
  196. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/stim/parse/lowering.py +0 -0
  197. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/task.py +0 -0
  198. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/test_utils.py +0 -0
  199. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/types.py +0 -0
  200. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/__init__.py +0 -0
  201. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/__init__.py +0 -0
  202. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/animate.py +0 -0
  203. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/base.py +0 -0
  204. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/gate_event.py +0 -0
  205. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/runtime/__init__.py +0 -0
  206. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/runtime/aod.py +0 -0
  207. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/runtime/atoms.py +0 -0
  208. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/runtime/ppoly.py +0 -0
  209. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/runtime/qpustate.py +0 -0
  210. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/src/bloqade/visual/animation/runtime/utils.py +0 -0
  211. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/__init__.py +0 -0
  212. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/analysis/address/test_analysis.py +0 -0
  213. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/analysis/address/test_lattice.py +0 -0
  214. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/analysis/fidelity/test_fidelity.py +0 -0
  215. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/__init__.py +0 -0
  216. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/runtime/__init__.py +0 -0
  217. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/runtime/noise/__init__.py +0 -0
  218. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/runtime/noise/qasm2/test_loss.py +0 -0
  219. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/runtime/noise/qasm2/test_pauli.py +0 -0
  220. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/runtime/test_dyn_memory.py +0 -0
  221. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/runtime/test_qrack.py +0 -0
  222. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/squin/test_kernel.py +0 -0
  223. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/pyqrack/test_target.py +0 -0
  224. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/__init__.py +0 -0
  225. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/analysis/test_dag.py +0 -0
  226. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/emit/test_extended.py +0 -0
  227. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/emit/test_extended_noise.py +0 -0
  228. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/emit/test_qasm2.py +0 -0
  229. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/emit/test_qasm2_emit.py +0 -0
  230. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/__init__.py +0 -0
  231. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/invalid_programs/invalid_if.qasm +0 -0
  232. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/README.md +0 -0
  233. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/global.qasm +0 -0
  234. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/iqft1.qasm +0 -0
  235. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/main.qasm +0 -0
  236. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/noise.qasm +0 -0
  237. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/para.qasm +0 -0
  238. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/process_tomo.qasm +0 -0
  239. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/qelib1.inc +0 -0
  240. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/qft.qasm +0 -0
  241. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/qft2.qasm +0 -0
  242. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/rb.qasm +0 -0
  243. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/rep_code.qasm +0 -0
  244. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/ripple_carry_adder.qasm +0 -0
  245. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/tele.qasm +0 -0
  246. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/programs/valid_if.qasm +0 -0
  247. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/test_ast.py +0 -0
  248. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/parse/test_roundtrip.py +0 -0
  249. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/passes/__init__.py +0 -0
  250. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/passes/test_global_to_parallel.py +0 -0
  251. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/passes/test_global_to_uop.py +0 -0
  252. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/passes/test_heuristic_noise.py +0 -0
  253. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/passes/test_parallel_to_uop.py +0 -0
  254. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/passes/test_qasm2py.py +0 -0
  255. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/passes/test_unroll_if.py +0 -0
  256. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/passes/test_uop_to_parallel.py +0 -0
  257. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/test_count.py +0 -0
  258. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/test_inline.py +0 -0
  259. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/test_native.py +0 -0
  260. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qasm2/test_two2one.py +0 -0
  261. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qbraid/__init__.py +0 -0
  262. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qbraid/test_clean_circuit.py +0 -0
  263. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qbraid/test_lowering.py +0 -0
  264. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/qbraid/test_target.py +0 -0
  265. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/sample/__init__.py +0 -0
  266. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/sample/test_noise_model.py +0 -0
  267. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/squin/analysis/test_nsites_analysis.py +0 -0
  268. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/squin/cirq/test_cirq_to_squin.py +0 -0
  269. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/squin/op/test_reset.py +0 -0
  270. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/squin/stim/test_stim.py +0 -0
  271. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/squin/test_constprop.py +0 -0
  272. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/squin/test_mult_rewrite.py +0 -0
  273. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/squin/test_sugar.py +0 -0
  274. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/__init__.py +0 -0
  275. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/__init__.py +0 -0
  276. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/__init__.py +0 -0
  277. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/__init__.py +0 -0
  278. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/base.py +0 -0
  279. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/test_stim_1q.py +0 -0
  280. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/test_stim_ctrl.py +0 -0
  281. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/test_stim_detector.py +0 -0
  282. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/test_stim_meas.py +0 -0
  283. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/test_stim_noise.py +0 -0
  284. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/test_stim_obs_inc.py +0 -0
  285. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/test_stim_ppmeas.py +0 -0
  286. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/test_stim_qubit_coords.py +0 -0
  287. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/emit/test_stim_spp.py +0 -0
  288. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/test_stim_circuits.py +0 -0
  289. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/dialects/stim/test_stim_const.py +0 -0
  290. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/parse/__init__.py +0 -0
  291. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/parse/base.py +0 -0
  292. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/parse/test_parse.py +0 -0
  293. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/parse/test_parse_clifford.py +0 -0
  294. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/parse/test_parse_control.py +0 -0
  295. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/parse/test_parse_custom.py +0 -0
  296. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/parse/test_parse_noise.py +0 -0
  297. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/parse/test_parse_spp.py +0 -0
  298. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/wrapper/__init__.py +0 -0
  299. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/stim/wrapper/test_wrapper.py +0 -0
  300. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/test_serialization.py +0 -0
  301. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/test_zone_model.py +0 -0
  302. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/visual/__init__.py +0 -0
  303. {bloqade_circuit-0.4.1 → bloqade_circuit-0.4.2}/test/visual/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bloqade-circuit
3
- Version: 0.4.1
3
+ Version: 0.4.2
4
4
  Summary: The software development toolkit for neutral atom arrays.
5
5
  Author-email: Roger-luo <rluo@quera.com>, kaihsin <khwu@quera.com>, weinbe58 <pweinberg@quera.com>, johnzl-777 <jlong@quera.com>
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "bloqade-circuit"
3
- version = "0.4.1"
3
+ version = "0.4.2"
4
4
  description = "The software development toolkit for neutral atom arrays."
5
5
  readme = "README.md"
6
6
  authors = [
@@ -2,9 +2,9 @@ from typing import Any
2
2
  from dataclasses import field, dataclass
3
3
 
4
4
  from kirin import ir, types, lowering
5
- from kirin.dialects import cf, func, ilist
5
+ from kirin.dialects import cf, scf, func, ilist
6
6
 
7
- from bloqade.qasm2.types import CRegType, QRegType
7
+ from bloqade.qasm2.types import CRegType, QRegType, QubitType
8
8
  from bloqade.qasm2.dialects import uop, core, expr, glob, noise, parallel
9
9
 
10
10
  from . import ast
@@ -101,6 +101,13 @@ class QASM2(lowering.LoweringABC[ast.Node]):
101
101
  def lower_global(
102
102
  self, state: lowering.State[ast.Node], node: ast.Node
103
103
  ) -> lowering.LoweringABC.Result:
104
+ if isinstance(node, ast.Name):
105
+ # NOTE: might be a lookup for a gate function invoke
106
+ try:
107
+ return lowering.LoweringABC.Result(state.current_frame.globals[node.id])
108
+ except KeyError:
109
+ pass
110
+
104
111
  raise lowering.BuildError("Global variables are not supported in QASM 2.0")
105
112
 
106
113
  def visit_MainProgram(self, state: lowering.State[ast.Node], node: ast.MainProgram):
@@ -171,7 +178,6 @@ class QASM2(lowering.LoweringABC[ast.Node]):
171
178
  def visit_Reset(self, state: lowering.State[ast.Node], node: ast.Reset):
172
179
  state.current_frame.push(core.Reset(qarg=state.lower(node.qarg).expect_one()))
173
180
 
174
- # TODO: clean this up? copied from cf dialect with a small modification
175
181
  def visit_IfStmt(self, state: lowering.State[ast.Node], node: ast.IfStmt):
176
182
  cond_stmt = core.CRegEq(
177
183
  lhs=state.lower(node.cond.lhs).expect_one(),
@@ -179,84 +185,23 @@ class QASM2(lowering.LoweringABC[ast.Node]):
179
185
  )
180
186
  cond = state.current_frame.push(cond_stmt).result
181
187
  frame = state.current_frame
182
- before_block = frame.curr_block
183
188
 
184
- with state.frame(node.body, region=frame.curr_region) as if_frame:
189
+ with state.frame(node.body) as if_frame:
185
190
  true_cond = if_frame.entr_block.args.append_from(types.Bool, cond.name)
186
191
  if cond.name:
187
192
  if_frame.defs[cond.name] = true_cond
188
193
 
194
+ # NOTE: pass in definitions from outer scope (usually just for the qreg)
195
+ if_frame.defs.update(frame.defs)
196
+
189
197
  if_frame.exhaust()
190
- self.branch_next_if_not_terminated(if_frame)
191
198
 
192
- with state.frame([], region=frame.curr_region) as else_frame:
193
- true_cond = else_frame.entr_block.args.append_from(types.Bool, cond.name)
194
- if cond.name:
195
- else_frame.defs[cond.name] = true_cond
196
- else_frame.exhaust()
197
- self.branch_next_if_not_terminated(else_frame)
198
-
199
- with state.frame(frame.stream.split(), region=frame.curr_region) as after_frame:
200
- after_frame.defs.update(frame.defs)
201
- phi: set[str] = set()
202
- for name in if_frame.defs.keys():
203
- if frame.get(name):
204
- phi.add(name)
205
- elif name in else_frame.defs:
206
- phi.add(name)
207
-
208
- for name in else_frame.defs.keys():
209
- if frame.get(name): # not defined in if_frame
210
- phi.add(name)
211
-
212
- for name in phi:
213
- after_frame.defs[name] = after_frame.entr_block.args.append_from(
214
- types.Any, name
215
- )
199
+ # NOTE: qasm2 can never yield anything from if
200
+ if_frame.push(scf.Yield())
216
201
 
217
- after_frame.exhaust()
218
- self.branch_next_if_not_terminated(after_frame)
219
- after_frame.next_block.stmts.append(
220
- cf.Branch(arguments=(), successor=frame.next_block)
221
- )
202
+ then_body = if_frame.curr_region
222
203
 
223
- if_args = []
224
- for name in phi:
225
- if value := if_frame.get(name):
226
- if_args.append(value)
227
- else:
228
- raise lowering.BuildError(f"undefined variable {name} in if branch")
229
-
230
- else_args = []
231
- for name in phi:
232
- if value := else_frame.get(name):
233
- else_args.append(value)
234
- else:
235
- raise lowering.BuildError(f"undefined variable {name} in else branch")
236
-
237
- if_frame.next_block.stmts.append(
238
- cf.Branch(
239
- arguments=tuple(if_args),
240
- successor=after_frame.entr_block,
241
- )
242
- )
243
- else_frame.next_block.stmts.append(
244
- cf.Branch(
245
- arguments=tuple(else_args),
246
- successor=after_frame.entr_block,
247
- )
248
- )
249
- before_block.stmts.append(
250
- cf.ConditionalBranch(
251
- cond=cond,
252
- then_arguments=(cond,),
253
- then_successor=if_frame.entr_block,
254
- else_arguments=(cond,),
255
- else_successor=else_frame.entr_block,
256
- )
257
- )
258
- frame.defs.update(after_frame.defs)
259
- frame.jump_next_block()
204
+ state.current_frame.push(scf.IfElse(cond, then_body=then_body))
260
205
 
261
206
  def branch_next_if_not_terminated(self, frame: lowering.Frame):
262
207
  """Branch to the next block if the current block is not terminated.
@@ -430,7 +375,56 @@ class QASM2(lowering.LoweringABC[ast.Node]):
430
375
  raise lowering.BuildError(f"Include {node.filename} not found")
431
376
 
432
377
  def visit_Gate(self, state: lowering.State[ast.Node], node: ast.Gate):
433
- raise NotImplementedError("Gate lowering not supported")
378
+ arg_names = node.cparams + node.qparams
379
+ arg_types = [types.Float for _ in node.cparams] + [
380
+ QubitType for _ in node.qparams
381
+ ]
382
+
383
+ with state.frame(
384
+ stmts=node.body,
385
+ finalize_next=False,
386
+ ) as body_frame:
387
+ # NOTE: insert _self as arg
388
+ body_frame.curr_block.args.append_from(
389
+ types.Generic(
390
+ ir.Method, types.Tuple.where(tuple(arg_types)), types.NoneType
391
+ ),
392
+ name=node.name + "_self",
393
+ )
394
+
395
+ for arg_type, arg_name in zip(arg_types, arg_names):
396
+ # NOTE: append args as block arguments
397
+ block_arg = body_frame.curr_block.args.append_from(
398
+ arg_type, name=arg_name
399
+ )
400
+
401
+ # NOTE: add arguments as definitions to frame
402
+ body_frame.defs[arg_name] = block_arg
403
+
404
+ body_frame.exhaust()
405
+
406
+ # NOTE: append none as return value
407
+ return_val = func.ConstantNone()
408
+ body_frame.push(return_val)
409
+ body_frame.push(func.Return(return_val))
410
+
411
+ body = body_frame.curr_region
412
+
413
+ gate_func = expr.GateFunction(
414
+ sym_name=node.name,
415
+ signature=func.Signature(inputs=tuple(arg_types), output=types.NoneType),
416
+ body=body,
417
+ )
418
+
419
+ mt = ir.Method(
420
+ mod=None,
421
+ py_func=None,
422
+ sym_name=node.name,
423
+ dialects=self.dialects,
424
+ arg_names=[*node.cparams, *node.qparams],
425
+ code=gate_func,
426
+ )
427
+ state.current_frame.globals[node.name] = mt
434
428
 
435
429
  def visit_Instruction(self, state: lowering.State[ast.Node], node: ast.Instruction):
436
430
  params = [state.lower(param).expect_one() for param in node.params]
@@ -137,7 +137,7 @@ def test_pp_error():
137
137
  zero_avg /= len(result)
138
138
 
139
139
  # should be approximately 10% since that is the bit flip error probability in the kernel above
140
- assert 0.05 < zero_avg < 0.25
140
+ assert 0.0 < zero_avg < 0.25
141
141
 
142
142
 
143
143
  def test_depolarize():
@@ -0,0 +1,165 @@
1
+ import math
2
+ import pathlib
3
+ import tempfile
4
+ import textwrap
5
+
6
+ from kirin import ir, types
7
+ from kirin.dialects import func
8
+
9
+ from bloqade import qasm2
10
+ from bloqade.qasm2.parse.lowering import QASM2
11
+
12
+ lines = textwrap.dedent(
13
+ """
14
+ OPENQASM 2.0;
15
+
16
+ qreg q[2];
17
+ creg c[2];
18
+
19
+ h q[0];
20
+ CX q[0], q[1];
21
+ barrier q[0], q[1];
22
+ CX q[0], q[1];
23
+ rx(pi/2) q[0];
24
+ """
25
+ )
26
+
27
+
28
+ def test_run_lowering():
29
+ ast = qasm2.parse.loads(lines)
30
+ code = QASM2(qasm2.main).run(ast)
31
+ code.print()
32
+
33
+
34
+ def test_loadfile():
35
+
36
+ with tempfile.TemporaryDirectory() as tmp_dir:
37
+ with open(f"{tmp_dir}/test.qasm", "w") as f:
38
+ f.write(lines)
39
+
40
+ file = pathlib.Path(f"{tmp_dir}/test.qasm")
41
+ qasm2.loadfile(file)
42
+
43
+
44
+ def test_negative_lowering():
45
+
46
+ mwe = """
47
+ OPENQASM 2.0;
48
+ include "qelib1.inc";
49
+ qreg q[1];
50
+ rz(-0.2) q[0];
51
+ """
52
+
53
+ entry = qasm2.loads(mwe)
54
+
55
+ body = ir.Region(
56
+ ir.Block(
57
+ [
58
+ (size := qasm2.expr.ConstInt(value=1)),
59
+ (qreg := qasm2.core.QRegNew(n_qubits=size.result)),
60
+ (phi := qasm2.expr.ConstFloat(value=0.2)),
61
+ (theta := qasm2.expr.Neg(phi.result)),
62
+ (idx := qasm2.expr.ConstInt(value=0)),
63
+ (qubit := qasm2.core.QRegGet(qreg.result, idx.result)),
64
+ (qasm2.uop.RZ(qubit.result, theta.result)),
65
+ (none := func.ConstantNone()),
66
+ (func.Return(none.result)),
67
+ ]
68
+ )
69
+ )
70
+
71
+ code = func.Function(
72
+ sym_name="main",
73
+ signature=func.Signature((), types.NoneType),
74
+ body=body,
75
+ )
76
+
77
+ code.print()
78
+ entry.print()
79
+
80
+ assert entry.code.is_structurally_equal(code)
81
+
82
+
83
+ def test_gate():
84
+ qasm2_prog = textwrap.dedent(
85
+ """
86
+ OPENQASM 2.0;
87
+ include "qelib1.inc";
88
+ qreg q[2];
89
+ gate custom_gate q1, q2 {
90
+ cx q1, q2;
91
+ }
92
+ h q[0];
93
+ custom_gate q[0], q[1];
94
+ """
95
+ )
96
+
97
+ main = qasm2.loads(qasm2_prog, compactify=False)
98
+
99
+ main.print()
100
+
101
+ from bloqade.pyqrack import StackMemorySimulator
102
+
103
+ target = StackMemorySimulator(min_qubits=2)
104
+ ket = target.state_vector(main)
105
+
106
+ assert ket[1] == ket[2] == 0
107
+ assert math.isclose(abs(ket[0]) ** 2, 0.5, abs_tol=1e-6)
108
+ assert math.isclose(abs(ket[3]) ** 2, 0.5, abs_tol=1e-6)
109
+
110
+
111
+ def test_gate_with_params():
112
+ qasm2_prog = textwrap.dedent(
113
+ """
114
+ OPENQASM 2.0;
115
+ include "qelib1.inc";
116
+ qreg q[2];
117
+ h q[1];
118
+ gate custom_gate(theta) q1, q2 {
119
+ u(theta, 0, 0) q1;
120
+ cx q1, q2;
121
+ }
122
+ h q[1];
123
+ custom_gate(1.5707963267948966) q[0], q[1];
124
+ """
125
+ )
126
+
127
+ main = qasm2.loads(qasm2_prog, compactify=False)
128
+
129
+ main.print()
130
+
131
+ from bloqade.pyqrack import StackMemorySimulator
132
+
133
+ target = StackMemorySimulator(min_qubits=2)
134
+ ket = target.state_vector(main)
135
+
136
+ assert ket[1] == ket[2] == 0
137
+ assert math.isclose(abs(ket[0]) ** 2, 0.5, abs_tol=1e-6)
138
+ assert math.isclose(abs(ket[3]) ** 2, 0.5, abs_tol=1e-6)
139
+
140
+
141
+ def test_if_lowering():
142
+
143
+ qasm2_prog = textwrap.dedent(
144
+ """
145
+ OPENQASM 2.0;
146
+ include "qelib1.inc";
147
+ qreg q[1];
148
+ creg c[1];
149
+ if(c == 1) x q[0];
150
+ """
151
+ )
152
+
153
+ main = qasm2.loads(qasm2_prog)
154
+
155
+ main.print()
156
+
157
+ @qasm2.main
158
+ def main2():
159
+ q = qasm2.qreg(1)
160
+ c = qasm2.creg(1)
161
+
162
+ if c == 1:
163
+ qasm2.x(q[0])
164
+
165
+ main2.print()
@@ -96,7 +96,7 @@ wheels = [
96
96
 
97
97
  [[package]]
98
98
  name = "bloqade-circuit"
99
- version = "0.4.1"
99
+ version = "0.4.2"
100
100
  source = { editable = "." }
101
101
  dependencies = [
102
102
  { name = "kirin-toolchain" },
@@ -1,79 +0,0 @@
1
- import pathlib
2
- import tempfile
3
- import textwrap
4
-
5
- from kirin import ir, types
6
- from kirin.dialects import func
7
-
8
- from bloqade import qasm2
9
- from bloqade.qasm2.parse.lowering import QASM2
10
-
11
- lines = textwrap.dedent(
12
- """
13
- OPENQASM 2.0;
14
-
15
- qreg q[2];
16
- creg c[2];
17
-
18
- h q[0];
19
- CX q[0], q[1];
20
- barrier q[0], q[1];
21
- CX q[0], q[1];
22
- rx(pi/2) q[0];
23
- """
24
- )
25
-
26
-
27
- def test_run_lowering():
28
- ast = qasm2.parse.loads(lines)
29
- code = QASM2(qasm2.main).run(ast)
30
- code.print()
31
-
32
-
33
- def test_loadfile():
34
-
35
- with tempfile.TemporaryDirectory() as tmp_dir:
36
- with open(f"{tmp_dir}/test.qasm", "w") as f:
37
- f.write(lines)
38
-
39
- file = pathlib.Path(f"{tmp_dir}/test.qasm")
40
- qasm2.loadfile(file)
41
-
42
-
43
- def test_negative_lowering():
44
-
45
- mwe = """
46
- OPENQASM 2.0;
47
- include "qelib1.inc";
48
- qreg q[1];
49
- rz(-0.2) q[0];
50
- """
51
-
52
- entry = qasm2.loads(mwe)
53
-
54
- body = ir.Region(
55
- ir.Block(
56
- [
57
- (size := qasm2.expr.ConstInt(value=1)),
58
- (qreg := qasm2.core.QRegNew(n_qubits=size.result)),
59
- (phi := qasm2.expr.ConstFloat(value=0.2)),
60
- (theta := qasm2.expr.Neg(phi.result)),
61
- (idx := qasm2.expr.ConstInt(value=0)),
62
- (qubit := qasm2.core.QRegGet(qreg.result, idx.result)),
63
- (qasm2.uop.RZ(qubit.result, theta.result)),
64
- (none := func.ConstantNone()),
65
- (func.Return(none.result)),
66
- ]
67
- )
68
- )
69
-
70
- code = func.Function(
71
- sym_name="main",
72
- signature=func.Signature((), types.NoneType),
73
- body=body,
74
- )
75
-
76
- code.print()
77
- entry.print()
78
-
79
- assert entry.code.is_structurally_equal(code)
File without changes