bloqade-circuit 0.6.1__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.

@@ -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)
@@ -253,19 +253,29 @@ class Squin(lowering.LoweringABC[CirqNode]):
253
253
  return state.current_frame.push(qubit.Apply(op_.result, qargs))
254
254
 
255
255
  def visit_HPowGate(self, state: lowering.State[CirqNode], node: cirq.HPowGate):
256
- if node.exponent == 1:
256
+ if abs(node.exponent) == 1:
257
257
  return state.current_frame.push(op.stmts.H())
258
258
 
259
- return state.lower(node.in_su2())
259
+ # NOTE: decompose into products of paulis for arbitrary exponents according to _decompose_ method
260
+ # can't use decompose directly since that method requires qubits to be passed in for some reason
261
+ y_rhs = state.lower(cirq.YPowGate(exponent=0.25)).expect_one()
262
+ x = state.lower(
263
+ cirq.XPowGate(exponent=node.exponent, global_shift=node.global_shift)
264
+ ).expect_one()
265
+ y_lhs = state.lower(cirq.YPowGate(exponent=-0.25)).expect_one()
266
+
267
+ # NOTE: reversed order since we're creating a mult stmt
268
+ m_lhs = state.current_frame.push(op.stmts.Mult(y_lhs, x))
269
+ return state.current_frame.push(op.stmts.Mult(m_lhs.result, y_rhs))
260
270
 
261
271
  def visit_XPowGate(self, state: lowering.State[CirqNode], node: cirq.XPowGate):
262
- if node.exponent == 1:
272
+ if abs(node.exponent == 1):
263
273
  return state.current_frame.push(op.stmts.X())
264
274
 
265
275
  return self.visit(state, node.in_su2())
266
276
 
267
277
  def visit_YPowGate(self, state: lowering.State[CirqNode], node: cirq.YPowGate):
268
- if node.exponent == 1:
278
+ if abs(node.exponent == 1):
269
279
  return state.current_frame.push(op.stmts.Y())
270
280
 
271
281
  return self.visit(state, node.in_su2())
@@ -277,7 +287,7 @@ class Squin(lowering.LoweringABC[CirqNode]):
277
287
  if node.exponent == 0.25:
278
288
  return state.current_frame.push(op.stmts.T())
279
289
 
280
- if node.exponent == 1:
290
+ if abs(node.exponent == 1):
281
291
  return state.current_frame.push(op.stmts.Z())
282
292
 
283
293
  # NOTE: just for the Z gate, an arbitrary exponent is equivalent to the ShiftOp
@@ -390,3 +400,41 @@ class Squin(lowering.LoweringABC[CirqNode]):
390
400
  )
391
401
 
392
402
  return noise_channel
403
+
404
+ def visit_DepolarizingChannel(
405
+ self, state: lowering.State[CirqNode], node: cirq.DepolarizingChannel
406
+ ):
407
+ p = state.current_frame.push(py.Constant(node.p)).result
408
+ return state.current_frame.push(noise.stmts.Depolarize(p))
409
+
410
+ def visit_AsymmetricDepolarizingChannel(
411
+ self, state: lowering.State[CirqNode], node: cirq.AsymmetricDepolarizingChannel
412
+ ):
413
+ nqubits = node.num_qubits()
414
+ if nqubits > 2:
415
+ raise lowering.BuildError(
416
+ "AsymmetricDepolarizingChannel applied to more than 2 qubits is not supported!"
417
+ )
418
+
419
+ if nqubits == 1:
420
+ p_x = state.current_frame.push(py.Constant(node.p_x)).result
421
+ p_y = state.current_frame.push(py.Constant(node.p_y)).result
422
+ p_z = state.current_frame.push(py.Constant(node.p_z)).result
423
+ params = state.current_frame.push(ilist.New(values=(p_x, p_y, p_z))).result
424
+ return state.current_frame.push(noise.stmts.SingleQubitPauliChannel(params))
425
+
426
+ # NOTE: nqubits == 2
427
+ error_probs = node.error_probabilities
428
+ paulis = ("I", "X", "Y", "Z")
429
+ values = []
430
+ for p1 in paulis:
431
+ for p2 in paulis:
432
+ if p1 == p2 == "I":
433
+ continue
434
+
435
+ p = error_probs.get(p1 + p2, 0.0)
436
+ p_ssa = state.current_frame.push(py.Constant(p)).result
437
+ values.append(p_ssa)
438
+
439
+ params = state.current_frame.push(ilist.New(values=values)).result
440
+ return state.current_frame.push(noise.stmts.TwoQubitPauliChannel(params))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bloqade-circuit
3
- Version: 0.6.1
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
@@ -13,12 +13,17 @@ bloqade/analysis/measure_id/__init__.py,sha256=J9I58iIyt4IjB36xK6_q9PV1B-40VJ1Gu
13
13
  bloqade/analysis/measure_id/analysis.py,sha256=93S3a_Wu7Bt1j217l1hZMY2tLlR00aUYN27o0IhZsqU,1748
14
14
  bloqade/analysis/measure_id/impls.py,sha256=ItS9bLMs8UdAkElYgrqD48Xlh9ZyoJq5xDPWcXjWH1c,4823
15
15
  bloqade/analysis/measure_id/lattice.py,sha256=WPrn0R79umCH909BFWsUJ64qx9n_3KYimIW5UaXNuGU,1891
16
- bloqade/cirq_utils/__init__.py,sha256=RZTqtfAviI64lUrA6_XX6Bf83RC8VnKxrFaVx0lcxik,223
16
+ bloqade/cirq_utils/__init__.py,sha256=1DRDCF3PpgJCOr0z7iULdrn3dqm7GLpRGs9AlqE7XA8,280
17
17
  bloqade/cirq_utils/lineprog.py,sha256=JosrhfeOHI9FycUT_sYFj8TBzLpo97TL8zK-Ap2U4eQ,11021
18
- bloqade/cirq_utils/parallelize.py,sha256=jnvZdA22UOkcIWVVulfhlN95Ha5q2ES-b1ZuQz--gOY,13770
18
+ bloqade/cirq_utils/parallelize.py,sha256=E2MsPm61Dkm3n0v4EFPJFGOc4B_Aw01yfhu-ViOKGiA,13812
19
+ bloqade/cirq_utils/noise/__init__.py,sha256=Z7d293ibzsNZyfS0tbL2JrdoypsDm20KE4zwlY6QnVA,559
20
+ bloqade/cirq_utils/noise/_two_zone_utils.py,sha256=3atgRbCMXZh0hu3zXAk7dThe4vljigKg0Z1bKPGM0s4,18293
21
+ bloqade/cirq_utils/noise/conflict_graph.py,sha256=ZUwPWTknrb6SgtZUVPeICn3YA-nUeWQJDuKKX5jL9tE,7179
22
+ bloqade/cirq_utils/noise/model.py,sha256=06Y_BLChOA-PhhAJcWLSgLVAAJoNjOrAujL1YCwcXA0,20590
23
+ bloqade/cirq_utils/noise/transform.py,sha256=tvDt4WMLM8dKPME51y0_peSZk2-jKmjq0urOxm0lWuQ,2309
19
24
  bloqade/pyqrack/__init__.py,sha256=lonTS-luJkTVujCCtgdZRC12V7FQdoFcozAI-byXwN0,810
20
25
  bloqade/pyqrack/base.py,sha256=9z61PaaAFqCBBwkgsDZSr-qr9IQ5OJ_JUvltmJ7Bgls,4407
21
- bloqade/pyqrack/device.py,sha256=cOdyT1k0b73QbOsEIu5KqxHW2OAWP86fi_3XGPhaWGA,7134
26
+ bloqade/pyqrack/device.py,sha256=40vduanEgA26GAW3buHoRpyqPA0xUt2tONY3w5JeH5s,7524
22
27
  bloqade/pyqrack/reg.py,sha256=uTL07CT1R0xUsInLmwU9YuuNdV6lV0lCs1zhdUz1qIs,1660
23
28
  bloqade/pyqrack/target.py,sha256=c78VtLWAiDNp_0sXwvVzhaEoeFsr1fUVsupxWuo6p3s,3661
24
29
  bloqade/pyqrack/task.py,sha256=ydVso4wZQ1iIzgSBG0lDxClPTLcsZfkbnZk_1qFV95o,991
@@ -30,7 +35,7 @@ bloqade/pyqrack/qasm2/glob.py,sha256=EGe7sh9SuvpRW4V4rFcX6Gf7ot8iyThYbsdPeEBKzYM
30
35
  bloqade/pyqrack/qasm2/parallel.py,sha256=ITetuXOH2KUDpDOBuFnJoz2DhduvyBC72cOAOOixTaM,1606
31
36
  bloqade/pyqrack/qasm2/uop.py,sha256=bLZONsEK15ymFGIQwy7muQv-TX0mvLrECuMp1Y3XTfA,8612
32
37
  bloqade/pyqrack/squin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
- bloqade/pyqrack/squin/op.py,sha256=fHBPV6Q3sKj50K34KfnctacZoNQ8iFz4j5k3qTtRfnI,5123
38
+ bloqade/pyqrack/squin/op.py,sha256=m9QiQgQnKy1tYvrieU6MjXf_b9i2fovj4r2novcQwIc,5535
34
39
  bloqade/pyqrack/squin/qubit.py,sha256=svQMbsLxv3yjiFMSRc4C7QGllzjtmlSWOsMY1mjTI8Q,2223
35
40
  bloqade/pyqrack/squin/runtime.py,sha256=BM_xRoTpsRipL_Vt-N5UO-x2Nsgiafw3nwiqiuOeH68,15401
36
41
  bloqade/pyqrack/squin/wire.py,sha256=rqlAeU-r_EHOwJMqHrEAxpZ_rKsvUpwGG7MP4BW75Nw,1658
@@ -134,8 +139,8 @@ bloqade/squin/analysis/nsites/__init__.py,sha256=RlQg7ivczXCXG5lMeL3ipYKj2oJKC4T
134
139
  bloqade/squin/analysis/nsites/analysis.py,sha256=rIe1RU1MZRItcE2aB8DYahLrv73HfD3IHCX3E_EGQ1c,1773
135
140
  bloqade/squin/analysis/nsites/impls.py,sha256=bVqO4E2hDzfYWwSG0pfj2j8oT1m0C3b42LdSHr4HQlo,2874
136
141
  bloqade/squin/analysis/nsites/lattice.py,sha256=ruh0808SHtj3ecuT-C3AZTsLY2j3DRhtezGiTZvcuVs,942
137
- bloqade/squin/cirq/__init__.py,sha256=fxvBvwX5VNfDmqkeM4GHguLQh53k-PJVsz89Eu0wRXw,8552
138
- bloqade/squin/cirq/lowering.py,sha256=G3AQ86JMOQ_H4TYn5rDeHiV9nivG8lJU1RH_IqoX4WE,15691
142
+ bloqade/squin/cirq/__init__.py,sha256=qGTrEzDEHqIMOh031y23-Y1NsyKew3QCrBYD9P_i63E,9236
143
+ bloqade/squin/cirq/lowering.py,sha256=F0_skv9lORxUFrhbNaN2ZQpqGnhPyslHt5E92uta5BQ,17959
139
144
  bloqade/squin/cirq/emit/emit_circuit.py,sha256=7puJ3eCFwE9VdPb9NAiSdyRNkoQPwo_uVykz9Yv7c14,3761
140
145
  bloqade/squin/cirq/emit/noise.py,sha256=rESjGC_66s2Y4FwwYda4rY3mYHYjbqLlKE_vnqpZDYI,1534
141
146
  bloqade/squin/cirq/emit/op.py,sha256=z54NP5KqMxffXeFGWamEzvunpTNrxmYuluurk4j2-ps,4000
@@ -223,7 +228,7 @@ bloqade/visual/animation/runtime/atoms.py,sha256=EmjxhujLiHHPS_HtH_B-7TiqeHgvW5u
223
228
  bloqade/visual/animation/runtime/ppoly.py,sha256=JB9IP53N1w6adBJEue6J5Nmj818Id9JvrlgrmiQTU1I,1385
224
229
  bloqade/visual/animation/runtime/qpustate.py,sha256=rlmxQeJSvaohXrTpXQL5y-NJcpvfW33xPaYM1slv7cc,4270
225
230
  bloqade/visual/animation/runtime/utils.py,sha256=ju9IzOWX-vKwfpqUjlUKu3Ssr_UFPFFq-tzH_Nqyo_c,1212
226
- bloqade_circuit-0.6.1.dist-info/METADATA,sha256=UulZPuoA-eaFH24p9sAdzlPQ2exC05Yvl7mdxTtuDJ0,3849
227
- bloqade_circuit-0.6.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
228
- bloqade_circuit-0.6.1.dist-info/licenses/LICENSE,sha256=S5GIJwR6QCixPA9wryYb44ZEek0Nz4rt_zLUqP05UbU,13160
229
- bloqade_circuit-0.6.1.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,,