bloqade-circuit 0.2.3__py3-none-any.whl → 0.4.0__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 bloqade-circuit might be problematic. Click here for more details.

Files changed (101) hide show
  1. bloqade/analysis/address/impls.py +3 -2
  2. bloqade/pyqrack/device.py +1 -3
  3. bloqade/pyqrack/noise/native.py +8 -8
  4. bloqade/pyqrack/qasm2/core.py +4 -1
  5. bloqade/pyqrack/squin/op.py +7 -0
  6. bloqade/pyqrack/squin/qubit.py +5 -27
  7. bloqade/pyqrack/squin/runtime.py +18 -0
  8. bloqade/pyqrack/squin/wire.py +4 -22
  9. bloqade/pyqrack/task.py +13 -5
  10. bloqade/qasm2/__init__.py +1 -0
  11. bloqade/qasm2/_qasm_loading.py +151 -0
  12. bloqade/qasm2/dialects/core/__init__.py +9 -1
  13. bloqade/qasm2/dialects/expr/__init__.py +18 -1
  14. bloqade/{noise/native → qasm2/dialects/noise}/__init__.py +1 -7
  15. bloqade/qasm2/dialects/noise/_dialect.py +3 -0
  16. bloqade/{noise → qasm2/dialects/noise}/fidelity.py +4 -4
  17. bloqade/qasm2/dialects/noise/model.py +278 -0
  18. bloqade/{noise/native → qasm2/dialects/noise}/stmts.py +1 -1
  19. bloqade/qasm2/dialects/uop/__init__.py +39 -3
  20. bloqade/qasm2/dialects/uop/schedule.py +1 -1
  21. bloqade/qasm2/emit/impls/__init__.py +1 -0
  22. bloqade/qasm2/emit/impls/noise.py +89 -0
  23. bloqade/qasm2/emit/main.py +23 -4
  24. bloqade/qasm2/emit/target.py +19 -4
  25. bloqade/qasm2/noise.py +67 -0
  26. bloqade/qasm2/parse/__init__.py +7 -4
  27. bloqade/qasm2/parse/lowering.py +20 -130
  28. bloqade/qasm2/parse/qasm2.lark +1 -1
  29. bloqade/qasm2/passes/__init__.py +1 -0
  30. bloqade/qasm2/passes/fold.py +6 -0
  31. bloqade/qasm2/passes/glob.py +12 -8
  32. bloqade/qasm2/passes/noise.py +27 -16
  33. bloqade/qasm2/passes/parallel.py +9 -0
  34. bloqade/qasm2/passes/unroll_if.py +25 -0
  35. bloqade/qasm2/rewrite/__init__.py +3 -0
  36. bloqade/qasm2/rewrite/desugar.py +3 -2
  37. bloqade/qasm2/rewrite/native_gates.py +67 -4
  38. bloqade/qasm2/rewrite/noise/__init__.py +0 -0
  39. bloqade/qasm2/rewrite/{heuristic_noise.py → noise/heuristic_noise.py} +32 -62
  40. bloqade/{noise/native/rewrite.py → qasm2/rewrite/noise/remove_noise.py} +2 -2
  41. bloqade/qasm2/rewrite/split_ifs.py +66 -0
  42. bloqade/qbraid/lowering.py +8 -8
  43. bloqade/squin/__init__.py +7 -1
  44. bloqade/squin/analysis/nsites/__init__.py +1 -0
  45. bloqade/squin/analysis/nsites/impls.py +16 -1
  46. bloqade/squin/groups.py +4 -4
  47. bloqade/squin/lowering.py +27 -0
  48. bloqade/squin/noise/__init__.py +7 -26
  49. bloqade/squin/noise/_wrapper.py +25 -0
  50. bloqade/squin/op/__init__.py +34 -159
  51. bloqade/squin/op/_wrapper.py +105 -0
  52. bloqade/squin/op/stdlib.py +62 -0
  53. bloqade/squin/op/stmts.py +10 -0
  54. bloqade/squin/passes/__init__.py +1 -0
  55. bloqade/squin/passes/stim.py +68 -0
  56. bloqade/squin/qubit.py +32 -37
  57. bloqade/squin/rewrite/__init__.py +11 -0
  58. bloqade/squin/rewrite/desugar.py +65 -0
  59. bloqade/squin/rewrite/qubit_to_stim.py +61 -0
  60. bloqade/squin/rewrite/squin_measure.py +73 -0
  61. bloqade/squin/rewrite/stim_rewrite_util.py +153 -0
  62. bloqade/squin/rewrite/wire_identity_elimination.py +24 -0
  63. bloqade/squin/rewrite/wire_to_stim.py +52 -0
  64. bloqade/squin/rewrite/wrap_analysis.py +72 -0
  65. bloqade/squin/wire.py +5 -22
  66. bloqade/stim/__init__.py +40 -5
  67. bloqade/stim/_wrappers.py +18 -12
  68. bloqade/stim/dialects/__init__.py +1 -5
  69. bloqade/stim/dialects/{aux → auxiliary}/__init__.py +13 -1
  70. bloqade/stim/dialects/{aux → auxiliary}/emit.py +18 -3
  71. bloqade/stim/dialects/{aux → auxiliary}/stmts/__init__.py +1 -0
  72. bloqade/stim/dialects/{aux → auxiliary}/stmts/annotate.py +8 -0
  73. bloqade/stim/dialects/collapse/__init__.py +13 -2
  74. bloqade/stim/dialects/collapse/{emit.py → emit_str.py} +4 -2
  75. bloqade/stim/dialects/collapse/stmts/pp_measure.py +1 -1
  76. bloqade/stim/dialects/gate/__init__.py +16 -1
  77. bloqade/stim/dialects/gate/emit.py +10 -3
  78. bloqade/stim/dialects/gate/stmts/base.py +1 -1
  79. bloqade/stim/dialects/gate/stmts/pp.py +1 -1
  80. bloqade/stim/dialects/noise/emit.py +33 -2
  81. bloqade/stim/dialects/noise/stmts.py +29 -0
  82. bloqade/stim/emit/__init__.py +1 -1
  83. bloqade/stim/groups.py +4 -2
  84. bloqade/stim/parse/__init__.py +1 -0
  85. bloqade/stim/parse/lowering.py +686 -0
  86. {bloqade_circuit-0.2.3.dist-info → bloqade_circuit-0.4.0.dist-info}/METADATA +5 -3
  87. {bloqade_circuit-0.2.3.dist-info → bloqade_circuit-0.4.0.dist-info}/RECORD +95 -77
  88. bloqade/noise/__init__.py +0 -2
  89. bloqade/noise/native/_dialect.py +0 -3
  90. bloqade/noise/native/_wrappers.py +0 -34
  91. bloqade/noise/native/model.py +0 -346
  92. bloqade/qasm2/dialects/noise.py +0 -16
  93. bloqade/squin/rewrite/measure_desugar.py +0 -33
  94. /bloqade/stim/dialects/{aux → auxiliary}/_dialect.py +0 -0
  95. /bloqade/stim/dialects/{aux → auxiliary}/interp.py +0 -0
  96. /bloqade/stim/dialects/{aux → auxiliary}/lowering.py +0 -0
  97. /bloqade/stim/dialects/{aux → auxiliary}/stmts/const.py +0 -0
  98. /bloqade/stim/dialects/{aux → auxiliary}/types.py +0 -0
  99. /bloqade/stim/emit/{stim.py → stim_str.py} +0 -0
  100. {bloqade_circuit-0.2.3.dist-info → bloqade_circuit-0.4.0.dist-info}/WHEEL +0 -0
  101. {bloqade_circuit-0.2.3.dist-info → bloqade_circuit-0.4.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,7 +1,7 @@
1
1
  from kirin.emit import EmitStrFrame
2
2
  from kirin.interp import MethodTable, impl
3
3
 
4
- from bloqade.stim.emit.stim import EmitStimMain
4
+ from bloqade.stim.emit.stim_str import EmitStimMain
5
5
 
6
6
  from . import stmts
7
7
  from ._dialect import dialect
@@ -44,7 +44,7 @@ class EmitStimNoiseMethods(MethodTable):
44
44
  px: str = frame.get(stmt.px)
45
45
  py: str = frame.get(stmt.py)
46
46
  pz: str = frame.get(stmt.pz)
47
- res = f"PAULI_CHANNEL_1({px},{py},{pz}) " + " ".join(targets)
47
+ res = f"PAULI_CHANNEL_1({px}, {py}, {pz}) " + " ".join(targets)
48
48
  emit.writeln(frame, res)
49
49
 
50
50
  return ()
@@ -64,3 +64,34 @@ class EmitStimNoiseMethods(MethodTable):
64
64
  emit.writeln(frame, res)
65
65
 
66
66
  return ()
67
+
68
+ @impl(stmts.TrivialError)
69
+ def non_stim_error(
70
+ self, emit: EmitStimMain, frame: EmitStrFrame, stmt: stmts.TrivialError
71
+ ):
72
+
73
+ targets: tuple[str, ...] = frame.get_values(stmt.targets)
74
+ prob: tuple[str, ...] = frame.get_values(stmt.probs)
75
+ prob_str: str = ", ".join(prob)
76
+
77
+ res = f"I_ERROR[{stmt.name}]({prob_str}) " + " ".join(targets)
78
+ emit.writeln(frame, res)
79
+
80
+ return ()
81
+
82
+ @impl(stmts.TrivialCorrelatedError)
83
+ def non_stim_corr_error(
84
+ self,
85
+ emit: EmitStimMain,
86
+ frame: EmitStrFrame,
87
+ stmt: stmts.TrivialCorrelatedError,
88
+ ):
89
+
90
+ targets: tuple[str, ...] = frame.get_values(stmt.targets)
91
+ prob: tuple[str, ...] = frame.get_values(stmt.probs)
92
+ prob_str: str = ", ".join(prob)
93
+
94
+ res = f"I_ERROR[{stmt.name}:{stmt.nonce}]({prob_str}) " + " ".join(targets)
95
+ emit.writeln(frame, res)
96
+
97
+ return ()
@@ -75,3 +75,32 @@ class ZError(ir.Statement):
75
75
  traits = frozenset({lowering.FromPythonCall()})
76
76
  p: ir.SSAValue = info.argument(types.Float)
77
77
  targets: tuple[ir.SSAValue, ...] = info.argument(types.Int)
78
+
79
+
80
+ @statement
81
+ class NonStimError(ir.Statement):
82
+ name = "NonStimError"
83
+ traits = frozenset({lowering.FromPythonCall()})
84
+ probs: tuple[ir.SSAValue, ...] = info.argument(types.Float)
85
+ targets: tuple[ir.SSAValue, ...] = info.argument(types.Int)
86
+
87
+
88
+ @statement
89
+ class NonStimCorrelatedError(ir.Statement):
90
+ name = "NonStimCorrelatedError"
91
+ traits = frozenset({lowering.FromPythonCall()})
92
+ nonce: int = (
93
+ info.attribute()
94
+ ) # Must be a unique value, otherwise stim might merge two correlated errors with equal probabilities
95
+ probs: tuple[ir.SSAValue, ...] = info.argument(types.Float)
96
+ targets: tuple[ir.SSAValue, ...] = info.argument(types.Int)
97
+
98
+
99
+ @statement(dialect=dialect)
100
+ class TrivialCorrelatedError(NonStimCorrelatedError):
101
+ name = "TRIV_CORR_ERROR"
102
+
103
+
104
+ @statement(dialect=dialect)
105
+ class TrivialError(NonStimError):
106
+ name = "TRIV_ERROR"
@@ -1 +1 @@
1
- from .stim import FuncEmit as FuncEmit, EmitStimMain as EmitStimMain
1
+ from .stim_str import FuncEmit as FuncEmit, EmitStimMain as EmitStimMain
bloqade/stim/groups.py CHANGED
@@ -2,10 +2,12 @@ from kirin import ir
2
2
  from kirin.passes import Fold, TypeInfer
3
3
  from kirin.dialects import func, lowering
4
4
 
5
- from .dialects import aux, gate, noise, collapse
5
+ from .dialects import gate, noise, collapse, auxiliary
6
6
 
7
7
 
8
- @ir.dialect_group([noise, gate, aux, collapse, func, lowering.func, lowering.call])
8
+ @ir.dialect_group(
9
+ [noise, gate, auxiliary, collapse, func, lowering.func, lowering.call]
10
+ )
9
11
  def main(self):
10
12
  typeinfer_pass = TypeInfer(self)
11
13
  fold_pass = Fold(self)
@@ -0,0 +1 @@
1
+ from .lowering import loads as loads, loadfile as loadfile