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.
- bloqade/analysis/address/impls.py +3 -2
- bloqade/pyqrack/device.py +1 -3
- bloqade/pyqrack/noise/native.py +8 -8
- bloqade/pyqrack/qasm2/core.py +4 -1
- bloqade/pyqrack/squin/op.py +7 -0
- bloqade/pyqrack/squin/qubit.py +5 -27
- bloqade/pyqrack/squin/runtime.py +18 -0
- bloqade/pyqrack/squin/wire.py +4 -22
- bloqade/pyqrack/task.py +13 -5
- bloqade/qasm2/__init__.py +1 -0
- bloqade/qasm2/_qasm_loading.py +151 -0
- bloqade/qasm2/dialects/core/__init__.py +9 -1
- bloqade/qasm2/dialects/expr/__init__.py +18 -1
- bloqade/{noise/native → qasm2/dialects/noise}/__init__.py +1 -7
- bloqade/qasm2/dialects/noise/_dialect.py +3 -0
- bloqade/{noise → qasm2/dialects/noise}/fidelity.py +4 -4
- bloqade/qasm2/dialects/noise/model.py +278 -0
- bloqade/{noise/native → qasm2/dialects/noise}/stmts.py +1 -1
- bloqade/qasm2/dialects/uop/__init__.py +39 -3
- bloqade/qasm2/dialects/uop/schedule.py +1 -1
- bloqade/qasm2/emit/impls/__init__.py +1 -0
- bloqade/qasm2/emit/impls/noise.py +89 -0
- bloqade/qasm2/emit/main.py +23 -4
- bloqade/qasm2/emit/target.py +19 -4
- bloqade/qasm2/noise.py +67 -0
- bloqade/qasm2/parse/__init__.py +7 -4
- bloqade/qasm2/parse/lowering.py +20 -130
- bloqade/qasm2/parse/qasm2.lark +1 -1
- bloqade/qasm2/passes/__init__.py +1 -0
- bloqade/qasm2/passes/fold.py +6 -0
- bloqade/qasm2/passes/glob.py +12 -8
- bloqade/qasm2/passes/noise.py +27 -16
- bloqade/qasm2/passes/parallel.py +9 -0
- bloqade/qasm2/passes/unroll_if.py +25 -0
- bloqade/qasm2/rewrite/__init__.py +3 -0
- bloqade/qasm2/rewrite/desugar.py +3 -2
- bloqade/qasm2/rewrite/native_gates.py +67 -4
- bloqade/qasm2/rewrite/noise/__init__.py +0 -0
- bloqade/qasm2/rewrite/{heuristic_noise.py → noise/heuristic_noise.py} +32 -62
- bloqade/{noise/native/rewrite.py → qasm2/rewrite/noise/remove_noise.py} +2 -2
- bloqade/qasm2/rewrite/split_ifs.py +66 -0
- bloqade/qbraid/lowering.py +8 -8
- bloqade/squin/__init__.py +7 -1
- bloqade/squin/analysis/nsites/__init__.py +1 -0
- bloqade/squin/analysis/nsites/impls.py +16 -1
- bloqade/squin/groups.py +4 -4
- bloqade/squin/lowering.py +27 -0
- bloqade/squin/noise/__init__.py +7 -26
- bloqade/squin/noise/_wrapper.py +25 -0
- bloqade/squin/op/__init__.py +34 -159
- bloqade/squin/op/_wrapper.py +105 -0
- bloqade/squin/op/stdlib.py +62 -0
- bloqade/squin/op/stmts.py +10 -0
- bloqade/squin/passes/__init__.py +1 -0
- bloqade/squin/passes/stim.py +68 -0
- bloqade/squin/qubit.py +32 -37
- bloqade/squin/rewrite/__init__.py +11 -0
- bloqade/squin/rewrite/desugar.py +65 -0
- bloqade/squin/rewrite/qubit_to_stim.py +61 -0
- bloqade/squin/rewrite/squin_measure.py +73 -0
- bloqade/squin/rewrite/stim_rewrite_util.py +153 -0
- bloqade/squin/rewrite/wire_identity_elimination.py +24 -0
- bloqade/squin/rewrite/wire_to_stim.py +52 -0
- bloqade/squin/rewrite/wrap_analysis.py +72 -0
- bloqade/squin/wire.py +5 -22
- bloqade/stim/__init__.py +40 -5
- bloqade/stim/_wrappers.py +18 -12
- bloqade/stim/dialects/__init__.py +1 -5
- bloqade/stim/dialects/{aux → auxiliary}/__init__.py +13 -1
- bloqade/stim/dialects/{aux → auxiliary}/emit.py +18 -3
- bloqade/stim/dialects/{aux → auxiliary}/stmts/__init__.py +1 -0
- bloqade/stim/dialects/{aux → auxiliary}/stmts/annotate.py +8 -0
- bloqade/stim/dialects/collapse/__init__.py +13 -2
- bloqade/stim/dialects/collapse/{emit.py → emit_str.py} +4 -2
- bloqade/stim/dialects/collapse/stmts/pp_measure.py +1 -1
- bloqade/stim/dialects/gate/__init__.py +16 -1
- bloqade/stim/dialects/gate/emit.py +10 -3
- bloqade/stim/dialects/gate/stmts/base.py +1 -1
- bloqade/stim/dialects/gate/stmts/pp.py +1 -1
- bloqade/stim/dialects/noise/emit.py +33 -2
- bloqade/stim/dialects/noise/stmts.py +29 -0
- bloqade/stim/emit/__init__.py +1 -1
- bloqade/stim/groups.py +4 -2
- bloqade/stim/parse/__init__.py +1 -0
- bloqade/stim/parse/lowering.py +686 -0
- {bloqade_circuit-0.2.3.dist-info → bloqade_circuit-0.4.0.dist-info}/METADATA +5 -3
- {bloqade_circuit-0.2.3.dist-info → bloqade_circuit-0.4.0.dist-info}/RECORD +95 -77
- bloqade/noise/__init__.py +0 -2
- bloqade/noise/native/_dialect.py +0 -3
- bloqade/noise/native/_wrappers.py +0 -34
- bloqade/noise/native/model.py +0 -346
- bloqade/qasm2/dialects/noise.py +0 -16
- bloqade/squin/rewrite/measure_desugar.py +0 -33
- /bloqade/stim/dialects/{aux → auxiliary}/_dialect.py +0 -0
- /bloqade/stim/dialects/{aux → auxiliary}/interp.py +0 -0
- /bloqade/stim/dialects/{aux → auxiliary}/lowering.py +0 -0
- /bloqade/stim/dialects/{aux → auxiliary}/stmts/const.py +0 -0
- /bloqade/stim/dialects/{aux → auxiliary}/types.py +0 -0
- /bloqade/stim/emit/{stim.py → stim_str.py} +0 -0
- {bloqade_circuit-0.2.3.dist-info → bloqade_circuit-0.4.0.dist-info}/WHEEL +0 -0
- {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.
|
|
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"
|
bloqade/stim/emit/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
from .
|
|
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
|
|
5
|
+
from .dialects import gate, noise, collapse, auxiliary
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
@ir.dialect_group(
|
|
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
|