bloqade-circuit 0.6.2__py3-none-any.whl → 0.6.3__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/pyqrack/device.py CHANGED
@@ -3,7 +3,9 @@ from dataclasses import field, dataclass
3
3
 
4
4
  import numpy as np
5
5
  from kirin import ir
6
+ from kirin.passes import fold
6
7
 
8
+ from bloqade.squin import noise as squin_noise
7
9
  from pyqrack.pauli import Pauli
8
10
  from bloqade.device import AbstractSimulatorDevice
9
11
  from bloqade.pyqrack.reg import Measurement, PyQrackQubit
@@ -16,6 +18,7 @@ from bloqade.pyqrack.base import (
16
18
  _default_pyqrack_args,
17
19
  )
18
20
  from bloqade.pyqrack.task import PyQrackSimulatorTask
21
+ from bloqade.squin.noise.rewrite import RewriteNoiseStmts
19
22
  from bloqade.analysis.address.lattice import AnyAddress
20
23
  from bloqade.analysis.address.analysis import AddressAnalysis
21
24
 
@@ -47,14 +50,23 @@ class PyQrackSimulatorBase(AbstractSimulatorDevice[PyQrackSimulatorTask]):
47
50
  kwargs: dict[str, Any],
48
51
  memory: MemoryType,
49
52
  ) -> PyQrackSimulatorTask[Params, RetType, MemoryType]:
53
+
54
+ if squin_noise in mt.dialects:
55
+ # NOTE: rewrite noise statements
56
+ mt_ = mt.similar(mt.dialects)
57
+ RewriteNoiseStmts(mt_.dialects)(mt_)
58
+ fold.Fold(mt_.dialects)(mt_)
59
+ else:
60
+ mt_ = mt
61
+
50
62
  interp = PyQrackInterpreter(
51
- mt.dialects,
63
+ mt_.dialects,
52
64
  memory=memory,
53
65
  rng_state=self.rng_state,
54
66
  loss_m_result=self.loss_m_result,
55
67
  )
56
68
  return PyQrackSimulatorTask(
57
- kernel=mt, args=args, kwargs=kwargs, pyqrack_interp=interp
69
+ kernel=mt_, args=args, kwargs=kwargs, pyqrack_interp=interp
58
70
  )
59
71
 
60
72
  def state_vector(
@@ -1,3 +1,5 @@
1
+ import math
2
+
1
3
  from kirin import interp
2
4
 
3
5
  from bloqade.squin import op
@@ -122,6 +124,18 @@ class PyQrackMethods(interp.MethodTable):
122
124
  ) -> tuple[OperatorRuntimeABC]:
123
125
  return (OperatorRuntime(method_name=stmt.name.lower()),)
124
126
 
127
+ @interp.impl(op.stmts.SqrtX)
128
+ @interp.impl(op.stmts.SqrtY)
129
+ def sqrt(
130
+ self,
131
+ interp: PyQrackInterpreter,
132
+ frame: interp.Frame,
133
+ stmt: op.stmts.SqrtX | op.stmts.SqrtY,
134
+ ):
135
+ axis_name = "x" if isinstance(stmt, op.stmts.SqrtX) else "y"
136
+ axis = OperatorRuntime(method_name=axis_name)
137
+ return (RotRuntime(axis=axis, angle=-0.5 * math.pi),)
138
+
125
139
  @interp.impl(op.stmts.P0)
126
140
  @interp.impl(op.stmts.P1)
127
141
  def projector(
@@ -157,6 +157,7 @@ def load_circuit(
157
157
  def emit_circuit(
158
158
  mt: ir.Method,
159
159
  qubits: Sequence[cirq.Qid] | None = None,
160
+ ignore_returns: bool = False,
160
161
  ) -> cirq.Circuit:
161
162
  """Converts a squin.kernel method to a cirq.Circuit object.
162
163
 
@@ -170,6 +171,9 @@ def emit_circuit(
170
171
  statement in the order they appear inside the kernel.
171
172
  **Note**: If a list of qubits is provided, make sure that there is a sufficient
172
173
  number of qubits for the resulting circuit.
174
+ ignore_returns (bool):
175
+ If `False`, emitting a circuit from a kernel that returns a value will error.
176
+ Set it to `True` in order to ignore the return value(s). Defaults to `False`.
173
177
 
174
178
  ## Examples:
175
179
 
@@ -228,11 +232,14 @@ def emit_circuit(
228
232
  and manipulate the qubits in other circuits directly written in cirq as well.
229
233
  """
230
234
 
231
- if isinstance(mt.code, func.Function) and not mt.code.signature.output.is_subseteq(
232
- types.NoneType
235
+ if (
236
+ not ignore_returns
237
+ and isinstance(mt.code, func.Function)
238
+ and not mt.code.signature.output.is_subseteq(types.NoneType)
233
239
  ):
234
240
  raise EmitError(
235
241
  "The method you are trying to convert to a circuit has a return value, but returning from a circuit is not supported."
242
+ " Set `ignore_returns = True` in order to simply ignore the return values and emit a circuit."
236
243
  )
237
244
 
238
245
  emitter = EmitCirq(qubits=qubits)
@@ -244,7 +251,12 @@ def emit_circuit(
244
251
  return emitter.run(mt_, args=())
245
252
 
246
253
 
247
- def dump_circuit(mt: ir.Method, qubits: Sequence[cirq.Qid] | None = None, **kwargs):
254
+ def dump_circuit(
255
+ mt: ir.Method,
256
+ qubits: Sequence[cirq.Qid] | None = None,
257
+ ignore_returns: bool = False,
258
+ **kwargs,
259
+ ):
248
260
  """Converts a squin.kernel method to a cirq.Circuit object and dumps it as JSON.
249
261
 
250
262
  This just runs `emit_circuit` and calls the `cirq.to_json` function to emit a JSON.
@@ -259,7 +271,10 @@ def dump_circuit(mt: ir.Method, qubits: Sequence[cirq.Qid] | None = None, **kwar
259
271
  statement in the order they appear inside the kernel.
260
272
  **Note**: If a list of qubits is provided, make sure that there is a sufficient
261
273
  number of qubits for the resulting circuit.
274
+ ignore_returns (bool):
275
+ If `False`, emitting a circuit from a kernel that returns a value will error.
276
+ Set it to `True` in order to ignore the return value(s). Defaults to `False`.
262
277
 
263
278
  """
264
- circuit = emit_circuit(mt, qubits=qubits)
279
+ circuit = emit_circuit(mt, qubits=qubits, ignore_returns=ignore_returns)
265
280
  return cirq.to_json(circuit, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bloqade-circuit
3
- Version: 0.6.2
3
+ Version: 0.6.3
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
@@ -23,7 +23,7 @@ bloqade/cirq_utils/noise/model.py,sha256=06Y_BLChOA-PhhAJcWLSgLVAAJoNjOrAujL1YCw
23
23
  bloqade/cirq_utils/noise/transform.py,sha256=tvDt4WMLM8dKPME51y0_peSZk2-jKmjq0urOxm0lWuQ,2309
24
24
  bloqade/pyqrack/__init__.py,sha256=lonTS-luJkTVujCCtgdZRC12V7FQdoFcozAI-byXwN0,810
25
25
  bloqade/pyqrack/base.py,sha256=9z61PaaAFqCBBwkgsDZSr-qr9IQ5OJ_JUvltmJ7Bgls,4407
26
- bloqade/pyqrack/device.py,sha256=cOdyT1k0b73QbOsEIu5KqxHW2OAWP86fi_3XGPhaWGA,7134
26
+ bloqade/pyqrack/device.py,sha256=40vduanEgA26GAW3buHoRpyqPA0xUt2tONY3w5JeH5s,7524
27
27
  bloqade/pyqrack/reg.py,sha256=uTL07CT1R0xUsInLmwU9YuuNdV6lV0lCs1zhdUz1qIs,1660
28
28
  bloqade/pyqrack/target.py,sha256=c78VtLWAiDNp_0sXwvVzhaEoeFsr1fUVsupxWuo6p3s,3661
29
29
  bloqade/pyqrack/task.py,sha256=ydVso4wZQ1iIzgSBG0lDxClPTLcsZfkbnZk_1qFV95o,991
@@ -35,7 +35,7 @@ bloqade/pyqrack/qasm2/glob.py,sha256=EGe7sh9SuvpRW4V4rFcX6Gf7ot8iyThYbsdPeEBKzYM
35
35
  bloqade/pyqrack/qasm2/parallel.py,sha256=ITetuXOH2KUDpDOBuFnJoz2DhduvyBC72cOAOOixTaM,1606
36
36
  bloqade/pyqrack/qasm2/uop.py,sha256=bLZONsEK15ymFGIQwy7muQv-TX0mvLrECuMp1Y3XTfA,8612
37
37
  bloqade/pyqrack/squin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
- bloqade/pyqrack/squin/op.py,sha256=fHBPV6Q3sKj50K34KfnctacZoNQ8iFz4j5k3qTtRfnI,5123
38
+ bloqade/pyqrack/squin/op.py,sha256=m9QiQgQnKy1tYvrieU6MjXf_b9i2fovj4r2novcQwIc,5535
39
39
  bloqade/pyqrack/squin/qubit.py,sha256=svQMbsLxv3yjiFMSRc4C7QGllzjtmlSWOsMY1mjTI8Q,2223
40
40
  bloqade/pyqrack/squin/runtime.py,sha256=BM_xRoTpsRipL_Vt-N5UO-x2Nsgiafw3nwiqiuOeH68,15401
41
41
  bloqade/pyqrack/squin/wire.py,sha256=rqlAeU-r_EHOwJMqHrEAxpZ_rKsvUpwGG7MP4BW75Nw,1658
@@ -139,7 +139,7 @@ bloqade/squin/analysis/nsites/__init__.py,sha256=RlQg7ivczXCXG5lMeL3ipYKj2oJKC4T
139
139
  bloqade/squin/analysis/nsites/analysis.py,sha256=rIe1RU1MZRItcE2aB8DYahLrv73HfD3IHCX3E_EGQ1c,1773
140
140
  bloqade/squin/analysis/nsites/impls.py,sha256=bVqO4E2hDzfYWwSG0pfj2j8oT1m0C3b42LdSHr4HQlo,2874
141
141
  bloqade/squin/analysis/nsites/lattice.py,sha256=ruh0808SHtj3ecuT-C3AZTsLY2j3DRhtezGiTZvcuVs,942
142
- bloqade/squin/cirq/__init__.py,sha256=fxvBvwX5VNfDmqkeM4GHguLQh53k-PJVsz89Eu0wRXw,8552
142
+ bloqade/squin/cirq/__init__.py,sha256=qGTrEzDEHqIMOh031y23-Y1NsyKew3QCrBYD9P_i63E,9236
143
143
  bloqade/squin/cirq/lowering.py,sha256=F0_skv9lORxUFrhbNaN2ZQpqGnhPyslHt5E92uta5BQ,17959
144
144
  bloqade/squin/cirq/emit/emit_circuit.py,sha256=7puJ3eCFwE9VdPb9NAiSdyRNkoQPwo_uVykz9Yv7c14,3761
145
145
  bloqade/squin/cirq/emit/noise.py,sha256=rESjGC_66s2Y4FwwYda4rY3mYHYjbqLlKE_vnqpZDYI,1534
@@ -228,7 +228,7 @@ bloqade/visual/animation/runtime/atoms.py,sha256=EmjxhujLiHHPS_HtH_B-7TiqeHgvW5u
228
228
  bloqade/visual/animation/runtime/ppoly.py,sha256=JB9IP53N1w6adBJEue6J5Nmj818Id9JvrlgrmiQTU1I,1385
229
229
  bloqade/visual/animation/runtime/qpustate.py,sha256=rlmxQeJSvaohXrTpXQL5y-NJcpvfW33xPaYM1slv7cc,4270
230
230
  bloqade/visual/animation/runtime/utils.py,sha256=ju9IzOWX-vKwfpqUjlUKu3Ssr_UFPFFq-tzH_Nqyo_c,1212
231
- bloqade_circuit-0.6.2.dist-info/METADATA,sha256=jAkPyCEphiBvZ8PrjxLr8CBFybEdJl9wUY1TNVChGkc,3849
232
- bloqade_circuit-0.6.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
233
- bloqade_circuit-0.6.2.dist-info/licenses/LICENSE,sha256=S5GIJwR6QCixPA9wryYb44ZEek0Nz4rt_zLUqP05UbU,13160
234
- bloqade_circuit-0.6.2.dist-info/RECORD,,
231
+ bloqade_circuit-0.6.3.dist-info/METADATA,sha256=K2Me5w0S2bHxND1_JeYHn5CBC7HjLOdzfpacoATbqWo,3849
232
+ bloqade_circuit-0.6.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
233
+ bloqade_circuit-0.6.3.dist-info/licenses/LICENSE,sha256=S5GIJwR6QCixPA9wryYb44ZEek0Nz4rt_zLUqP05UbU,13160
234
+ bloqade_circuit-0.6.3.dist-info/RECORD,,