Skip to content

barrier

barrier(qargs: tuple[Qubit, ...]) -> None

Barrier instruction.

Parameters:

Name Type Description Default
qargs tuple[Qubit, ...]

The qubits to apply the barrier to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
131
132
133
134
135
136
137
138
139
140
@wraps(uop.Barrier)
def barrier(qargs: tuple[Qubit, ...]) -> None:
    """
    Barrier instruction.

    Args:
        qargs: The qubits to apply the barrier to.
    """

    ...

ccx

ccx(ctrl1: Qubit, ctrl2: Qubit, qarg: Qubit) -> None

Toffoli gate.

Parameters:

Name Type Description Default
ctrl1 Qubit

The first control qubit.

required
ctrl2 Qubit

The second control qubit.

required
qarg Qubit

The target qubit.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
422
423
424
425
426
427
428
429
430
431
432
@wraps(uop.CCX)
def ccx(ctrl1: Qubit, ctrl2: Qubit, qarg: Qubit) -> None:
    """
    Toffoli gate.

    Args:
        ctrl1: The first control qubit.
        ctrl2: The second control qubit.
        qarg: The target qubit.
    """
    ...

ch

ch(ctrl: Qubit, qarg: Qubit) -> None

Controlled-Hadamard gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
396
397
398
399
400
401
402
403
404
405
406
407
@wraps(uop.CH)
def ch(ctrl: Qubit, qarg: Qubit) -> None:
    """
    Controlled-Hadamard gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit

    """

    ...

cos

cos(value: float) -> float

Cosine math function.

Parameters:

Name Type Description Default
value float

The value to take the cosine of.

required

Returns:

Type Description
float

The cosine of value.

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
609
610
611
612
613
614
615
616
617
618
619
620
621
622
@wraps(expr.Cos)
def cos(value: float) -> float:
    """
    Cosine math function.

    Args:
        value: The value to take the cosine of.

    Returns:
        The cosine of `value`.

    """

    ...

cp

cp(ctrl: Qubit, qarg: Qubit, lam: float) -> None

Controlled phase rotation gate. Same as cu1

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit.

required
lam float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
506
507
508
509
510
511
512
513
514
515
516
517
@wraps(uop.CU1)
def cp(ctrl: Qubit, qarg: Qubit, lam: float) -> None:
    """
    Controlled phase rotation gate. Same as cu1

    Args:
        ctrl: The control qubit.
        qarg: The target qubit.
        lam: The angle of rotation.
    """

    ...

creg

creg(n_bits: int) -> CReg

Create a new classical register with n_bits bits.

Parameters:

Name Type Description Default
n_bits int

The number of bits in the register.

required

Returns:

Type Description
CReg

The newly created classical register.

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
35
36
37
38
39
40
41
42
43
44
45
46
47
@wraps(core.CRegNew)
def creg(n_bits: int) -> CReg:
    """
    Create a new classical register with `n_bits` bits.

    Args:
        n_bits: The number of bits in the register.

    Returns:
        The newly created classical register.

    """
    ...

crx

crx(ctrl: Qubit, qarg: Qubit, lam: float) -> None

Controlled Rx rotation gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit.

required
lam float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
448
449
450
451
452
453
454
455
456
457
458
459
460
@wraps(uop.CRX)
def crx(ctrl: Qubit, qarg: Qubit, lam: float) -> None:
    """
    Controlled Rx rotation gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit.
        lam: The angle of rotation.

    """

    ...

cry

cry(ctrl: Qubit, qarg: Qubit, lam: float) -> None

Controlled Ry rotation gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit.

required
lam float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
463
464
465
466
467
468
469
470
471
472
473
474
475
@wraps(uop.CRY)
def cry(ctrl: Qubit, qarg: Qubit, lam: float) -> None:
    """
    Controlled Ry rotation gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit.
        lam: The angle of rotation.

    """

    ...

crz

crz(ctrl: Qubit, qarg: Qubit, lam: float) -> None

Controlled Rz rotation gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit.

required
lam float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
478
479
480
481
482
483
484
485
486
487
488
489
@wraps(uop.CRZ)
def crz(ctrl: Qubit, qarg: Qubit, lam: float) -> None:
    """
    Controlled Rz rotation gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit.
        lam: The angle of rotation.

    """
    ...

cswap

cswap(ctrl: Qubit, qarg1: Qubit, qarg2: Qubit) -> None

Controlled Swap gate (Fredkin gate).

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg1 Qubit

The first target qubit.

required
qarg2 Qubit

The second target qubit.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
435
436
437
438
439
440
441
442
443
444
445
@wraps(uop.CSwap)
def cswap(ctrl: Qubit, qarg1: Qubit, qarg2: Qubit) -> None:
    """
    Controlled Swap gate (Fredkin gate).

    Args:
        ctrl: The control qubit.
        qarg1: The first target qubit.
        qarg2: The second target qubit.
    """
    ...

csx

csx(ctrl: Qubit, qarg: Qubit) -> None

Controlled-Sqrt(X) gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
371
372
373
374
375
376
377
378
379
380
@wraps(uop.CSX)
def csx(ctrl: Qubit, qarg: Qubit) -> None:
    """
    Controlled-Sqrt(X) gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit
    """
    ...

cu

cu(
    ctrl: Qubit,
    qarg: Qubit,
    theta: float,
    phi: float,
    lam: float,
    gamma: float,
) -> None

Controlled 4-parameter unitary gate.

This is equal to:

gate cu(theta,phi,lambda,gamma) c, t{ p(gamma) c; p((lambda+phi)/2) c; p((lambda-phi)/2) t; cx c,t; u(-theta/2,0,-(phi+lambda)/2) t; cx c,t; u(theta/2,phi,0) t; }

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit.

required
theta float

The angle of rotation.

required
phi float

The angle of rotation.

required
lam float

The angle of rotation.

required
gamma float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
@wraps(uop.CU)
def cu(
    ctrl: Qubit, qarg: Qubit, theta: float, phi: float, lam: float, gamma: float
) -> None:
    """
    Controlled 4-parameter unitary gate.

    This is equal to:

    gate cu(theta,phi,lambda,gamma) c, t{
        p(gamma) c;
        p((lambda+phi)/2) c;
        p((lambda-phi)/2) t;
        cx c,t;
        u(-theta/2,0,-(phi+lambda)/2) t;
        cx c,t;
        u(theta/2,phi,0) t;
    }

    Args:
        ctrl: The control qubit.
        qarg: The target qubit.
        theta: The angle of rotation.
        phi: The angle of rotation.
        lam: The angle of rotation.
        gamma: The angle of rotation.
    """
    ...

cu1

cu1(ctrl: Qubit, qarg: Qubit, lam: float) -> None

Controlled phase rotation gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit.

required
lam float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
492
493
494
495
496
497
498
499
500
501
502
503
@wraps(uop.CU1)
def cu1(ctrl: Qubit, qarg: Qubit, lam: float) -> None:
    """
    Controlled phase rotation gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit.
        lam: The angle of rotation.
    """

    ...

cu3

cu3(
    ctrl: Qubit,
    qarg: Qubit,
    theta: float,
    phi: float,
    lam: float,
) -> None

Controlled 3-parameter unitary gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit.

required
theta float

The angle of rotation.

required
phi float

The angle of rotation.

required
lam float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
520
521
522
523
524
525
526
527
528
529
530
531
532
533
@wraps(uop.CU3)
def cu3(ctrl: Qubit, qarg: Qubit, theta: float, phi: float, lam: float) -> None:
    """
    Controlled 3-parameter unitary gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit.
        theta: The angle of rotation.
        phi: The angle of rotation.
        lam: The angle of rotation.

    """
    ...

cx

cx(ctrl: Qubit, qarg: Qubit) -> None

Controlled-X (CNOT) gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
83
84
85
86
87
88
89
90
91
92
@wraps(uop.CX)
def cx(ctrl: Qubit, qarg: Qubit) -> None:
    """
    Controlled-X (CNOT) gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit.
    """
    ...

cy

cy(ctrl: Qubit, qarg: Qubit) -> None

Controlled-Y gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
383
384
385
386
387
388
389
390
391
392
393
@wraps(uop.CY)
def cy(ctrl: Qubit, qarg: Qubit) -> None:
    """
    Controlled-Y gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit
    """

    ...

cz

cz(ctrl: Qubit, qarg: Qubit) -> None

Controlled-Z gate.

Parameters:

Name Type Description Default
ctrl Qubit

The control qubit.

required
qarg Qubit

The target qubit

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
359
360
361
362
363
364
365
366
367
368
@wraps(uop.CZ)
def cz(ctrl: Qubit, qarg: Qubit) -> None:
    """
    Controlled-Z gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit
    """
    ...

exp

exp(value: float) -> float

Exponential math function.

Parameters:

Name Type Description Default
value float

The value to exponentiate.

required

Returns:

Type Description
float

The exponential of value.

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
641
642
643
644
645
646
647
648
649
650
651
652
653
654
@wraps(expr.Exp)
def exp(value: float) -> float:
    """
    Exponential math function.

    Args:
        value: The value to exponentiate.

    Returns:
        The exponential of `value`.

    """

    ...

h

h(qarg: Qubit) -> None

Hadamard gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
155
156
157
158
159
160
161
162
163
164
@wraps(uop.H)
def h(qarg: Qubit) -> None:
    """
    Hadamard gate.

    Args:
        qarg: The qubit to apply the gate to.

    """
    ...

id

id(qarg: Qubit) -> None

Identity gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
143
144
145
146
147
148
149
150
151
152
@wraps(uop.Id)
def id(qarg: Qubit) -> None:
    """
    Identity gate.

    Args:
        qarg: The qubit to apply the gate to.

    """
    ...

inline

inline(text: str) -> None

Inline QASM code into the current program.

Parameters:

Name Type Description Default
text str

The QASM code to inline.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
 9
10
11
12
13
14
15
16
17
@wraps(inline_.InlineQASM)
def inline(text: str) -> None:
    """
    Inline QASM code into the current program.

    Args:
        text: The QASM code to inline.
    """
    ...

ln

ln(value: float) -> float

logarithm math function.

Parameters:

Name Type Description Default
value float

The value to take the natural logarithm of.

required

Returns:

Type Description
float

The natural logarithm of value.

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
657
658
659
660
661
662
663
664
665
666
667
668
669
670
@wraps(expr.Log)
def ln(value: float) -> float:
    """
    logarithm math function.

    Args:
        value: The value to take the natural logarithm of.

    Returns:
        The natural logarithm of `value`.

    """

    ...

measure

measure(qreg: QReg, creg: CReg) -> None
measure(qarg: Qubit, cbit: Bit) -> None
measure(qarg, cbit) -> None

Measure the qubit qarg and store the result in the classical bit cbit.

Parameters:

Name Type Description Default
qarg

The qubit to measure.

required
cbit

The classical bit to store the result in.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
71
72
73
74
75
76
77
78
79
80
@wraps(core.Measure)
def measure(qarg, cbit) -> None:
    """
    Measure the qubit `qarg` and store the result in the classical bit `cbit`.

    Args:
        qarg: The qubit to measure.
        cbit: The classical bit to store the result in.
    """
    ...

p

p(qarg: Qubit, lam: float) -> None

Phase gate.

This is equivalent to u(0,0,lam), and u1(lam)

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
lam float

The angle of phase.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
203
204
205
206
207
208
209
210
211
212
213
214
215
@wraps(uop.U1)
def p(qarg: Qubit, lam: float) -> None:
    """
    Phase gate.

    This is equivalent to u(0,0,lam), and u1(lam)

    Args:
        qarg: The qubit to apply the gate to.
        lam: The angle of phase.

    """
    ...

qreg

qreg(n_qubits: int) -> QReg

Create a new quantum register with n_qubits qubits.

Parameters:

Name Type Description Default
n_qubits int

The number of qubits in the register.

required

Returns:

Type Description
QReg

The newly created quantum register.

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
20
21
22
23
24
25
26
27
28
29
30
31
32
@wraps(core.QRegNew)
def qreg(n_qubits: int) -> QReg:
    """
    Create a new quantum register with `n_qubits` qubits.

    Args:
        n_qubits: The number of qubits in the register.

    Returns:
        The newly created quantum register.

    """
    ...

reset

reset(qarg: Qubit) -> None

Reset the qubit qarg to the |0⟩ state.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to reset.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
50
51
52
53
54
55
56
57
58
59
60
@wraps(core.Reset)
def reset(qarg: Qubit) -> None:
    """
    Reset the qubit `qarg` to the |0⟩ state.

    Args:
        qarg: The qubit to reset.

    """

    ...

rx

rx(qarg: Qubit, theta: float) -> None

Single qubit rotation about the X axis on block sphere

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
theta float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
292
293
294
295
296
297
298
299
300
301
@wraps(uop.RX)
def rx(qarg: Qubit, theta: float) -> None:
    """
    Single qubit rotation about the X axis on block sphere

    Args:
        qarg: The qubit to apply the gate to.
        theta: The angle of rotation.
    """
    ...

rxx

rxx(ctrl: Qubit, qarg: Qubit, theta: float) -> None

XX rotation gate.

Parameters:

Name Type Description Default
ctrl Qubit

The first qubit.

required
qarg Qubit

The second qubit.

required
theta float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
566
567
568
569
570
571
572
573
574
575
576
577
@wraps(uop.RXX)
def rxx(ctrl: Qubit, qarg: Qubit, theta: float) -> None:
    """
    XX rotation gate.

    Args:
        ctrl: The first qubit.
        qarg: The second qubit.
        theta: The angle of rotation.

    """
    ...

ry

ry(qarg: Qubit, theta: float) -> None

Single qubit rotation about the Y axis on block sphere

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
theta float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
304
305
306
307
308
309
310
311
312
313
314
315
@wraps(uop.RY)
def ry(qarg: Qubit, theta: float) -> None:
    """
    Single qubit rotation about the Y axis on block sphere

    Args:
        qarg: The qubit to apply the gate to.
        theta: The angle of rotation.

    """

    ...

rz

rz(qarg: Qubit, theta: float) -> None

Single qubit rotation about the Z axis on block sphere

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
theta float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
318
319
320
321
322
323
324
325
326
327
@wraps(uop.RZ)
def rz(qarg: Qubit, theta: float) -> None:
    """
    Single qubit rotation about the Z axis on block sphere

    Args:
        qarg: The qubit to apply the gate to.
        theta: The angle of rotation.
    """
    ...

rzz

rzz(ctrl: Qubit, qarg: Qubit, theta: float) -> None

ZZ rotation gate.

Parameters:

Name Type Description Default
ctrl Qubit

The first qubit.

required
qarg Qubit

The second qubit.

required
theta float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
580
581
582
583
584
585
586
587
588
589
590
591
@wraps(uop.RZZ)
def rzz(ctrl: Qubit, qarg: Qubit, theta: float) -> None:
    """
    ZZ rotation gate.

    Args:
        ctrl: The first qubit.
        qarg: The second qubit.
        theta: The angle of rotation.

    """
    ...

s

s(qarg: Qubit) -> None

S gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
218
219
220
221
222
223
224
225
226
227
@wraps(uop.S)
def s(qarg: Qubit) -> None:
    """
    S gate.

    Args:
        qarg: The qubit to apply the gate to.
    """

    ...

sdg

sdg(qarg: Qubit) -> None

Hermitian conjugate of the S gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
230
231
232
233
234
235
236
237
238
239
240
@wraps(uop.Sdag)
def sdg(qarg: Qubit) -> None:
    """
    Hermitian conjugate of the S gate.

    Args:
        qarg: The qubit to apply the gate to.

    """

    ...

sin

sin(value: float) -> float

Sine math function.

Parameters:

Name Type Description Default
value float

The value to take the sine of.

required

Returns:

Type Description
float

The sine of value.

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
594
595
596
597
598
599
600
601
602
603
604
605
606
@wraps(expr.Sin)
def sin(value: float) -> float:
    """
    Sine math function.

    Args:
        value: The value to take the sine of.

    Returns:
        The sine of `value`.

    """
    ...

sqrt

sqrt(value: float) -> float

Square root math function.

Parameters:

Name Type Description Default
value float

The value to take the square root of.

required

Returns:

Type Description
float

The square root of value.

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
673
674
675
676
677
678
679
680
681
682
683
684
@wraps(expr.Sqrt)
def sqrt(value: float) -> float:
    """
    Square root math function.

    Args:
        value: The value to take the square root of.

    Returns:
        The square root of `value`.
    """
    ...

swap

swap(ctrl: Qubit, qarg: Qubit) -> None

Swap gate.

Parameters:

Name Type Description Default
ctrl Qubit

The first qubit.

required
qarg Qubit

The second qubit.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
410
411
412
413
414
415
416
417
418
419
@wraps(uop.Swap)
def swap(ctrl: Qubit, qarg: Qubit) -> None:
    """
    Swap gate.

    Args:
        ctrl: The first qubit.
        qarg: The second qubit.
    """
    ...

sx

sx(qarg: Qubit) -> None

Sqrt(X) gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
243
244
245
246
247
248
249
250
251
252
@wraps(uop.SX)
def sx(qarg: Qubit) -> None:
    """
    Sqrt(X) gate.

    Args:
        qarg: The qubit to apply the gate to.
    """

    ...

sxdg

sxdg(qarg: Qubit) -> None

Hermitian conjugate of Sqrt(X) gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
255
256
257
258
259
260
261
262
263
264
@wraps(uop.SXdag)
def sxdg(qarg: Qubit) -> None:
    """
    Hermitian conjugate of Sqrt(X) gate.

    Args:
        qarg: The qubit to apply the gate to.
    """

    ...

t

t(qarg: Qubit) -> None

T gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
267
268
269
270
271
272
273
274
275
276
@wraps(uop.T)
def t(qarg: Qubit) -> None:
    """
    T gate.

    Args:
        qarg: The qubit to apply the gate to.
    """

    ...

tan

tan(value: float) -> float

Tangent math function.

Parameters:

Name Type Description Default
value float

The value to take the tangent of.

required

Returns:

Type Description
float

The tangent of value.

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
625
626
627
628
629
630
631
632
633
634
635
636
637
638
@wraps(expr.Tan)
def tan(value: float) -> float:
    """
    Tangent math function.

    Args:
        value: The value to take the tangent of.

    Returns:
        The tangent of `value`.

    """

    ...

tdg

tdg(qarg: Qubit) -> None

Hermitian conjugate of the T gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
279
280
281
282
283
284
285
286
287
288
289
@wraps(uop.Tdag)
def tdg(qarg: Qubit) -> None:
    """
    Hermitian conjugate of the T gate.

    Args:
        qarg: The qubit to apply the gate to.

    """

    ...

u

u(
    qarg: Qubit, theta: float, phi: float, lam: float
) -> None

U gate.

Note

See https://arxiv.org/pdf/1707.03429 for definition of angles.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
theta float

The angle of rotation

required
phi float

The angle of rotation

required
lam float

The angle of rotation

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
@wraps(uop.UGate)
def u(qarg: Qubit, theta: float, phi: float, lam: float) -> None:
    """
    U gate.

    Note:
        See https://arxiv.org/pdf/1707.03429 for definition of angles.

    Args:
        qarg: The qubit to apply the gate to.
        theta: The angle of rotation
        phi: The angle of rotation
        lam: The angle of rotation

    """
    ...

u1

u1(qarg: Qubit, lam: float) -> None

1 Parameter single qubit unitary gate.

This is equivalent to u(0,0,lambda).

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
lam float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
330
331
332
333
334
335
336
337
338
339
340
341
@wraps(uop.U1)
def u1(qarg: Qubit, lam: float) -> None:
    """
    1 Parameter single qubit unitary gate.

    This is equivalent to u(0,0,lambda).

    Args:
        qarg: The qubit to apply the gate to.
        lam: The angle of rotation.
    """
    ...

u2

u2(qarg: Qubit, phi: float, lam: float) -> None

2 Parameter single qubit unitary gate.

This is equivalent to u(pi/2,phi,lambda)

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
phi float

The angle of rotation.

required
lam float

The angle of rotation.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
344
345
346
347
348
349
350
351
352
353
354
355
356
@wraps(uop.U2)
def u2(qarg: Qubit, phi: float, lam: float) -> None:
    """
    2 Parameter single qubit unitary gate.

    This is equivalent to u(pi/2,phi,lambda)

    Args:
        qarg: The qubit to apply the gate to.
        phi: The angle of rotation.
        lam: The angle of rotation.
    """
    ...

u3

u3(
    qarg: Qubit, theta: float, phi: float, lam: float
) -> None

U3 gate, same as u

Note

See https://arxiv.org/pdf/1707.03429 for definition of angles.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
theta float

The angle of rotation

required
phi float

The angle of rotation

required
lam float

The angle of rotation

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
@wraps(uop.UGate)
def u3(qarg: Qubit, theta: float, phi: float, lam: float) -> None:
    """
    U3 gate, same as u

    Note:
        See https://arxiv.org/pdf/1707.03429 for definition of angles.

    Args:
        qarg: The qubit to apply the gate to.
        theta: The angle of rotation
        phi: The angle of rotation
        lam: The angle of rotation

    """
    ...

x

x(qarg: Qubit) -> None

Pauli-X gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
167
168
169
170
171
172
173
174
175
176
@wraps(uop.X)
def x(qarg: Qubit) -> None:
    """
    Pauli-X gate.

    Args:
        qarg: The qubit to apply the gate to.
    """

    ...

y

y(qarg: Qubit) -> None

Pauli-Y gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
179
180
181
182
183
184
185
186
187
188
@wraps(uop.Y)
def y(qarg: Qubit) -> None:
    """
    Pauli-Y gate.

    Args:
        qarg: The qubit to apply the gate to.

    """
    ...

z

z(qarg: Qubit) -> None

Pauli-Z gate.

Parameters:

Name Type Description Default
qarg Qubit

The qubit to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/_wrappers.py
191
192
193
194
195
196
197
198
199
200
@wraps(uop.Z)
def z(qarg: Qubit) -> None:
    """
    Pauli-Z gate.

    Args:
        qarg: The qubit to apply the gate to.

    """
    ...

core

BitType module-attribute

BitType = PyClass(Bit)

Kirin type for a classical bit.

CRegType module-attribute

CRegType = PyClass(CReg)

Kirin type for a classical register.

QRegType module-attribute

QRegType = IListType[QubitType, Any]

Kirin type for a quantum register.

QubitType module-attribute

QubitType = PyClass(Qubit)

Kirin type for a qubit.

CRegEq

Bases: Statement

Check if two classical registers are equal.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(Int | CRegType | BitType)

lhs (CReg): The first register.

result class-attribute instance-attribute

result: ResultValue = result(Bool)

result (bool): True if the registers are equal, False otherwise.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(Int | CRegType | BitType)

rhs (CReg): The second register.

CRegGet

Bases: Statement

Get a bit from a classical register.

idx class-attribute instance-attribute

idx: SSAValue = argument(Int)

idx (Int): The index of the bit in the register.

reg class-attribute instance-attribute

reg: SSAValue = argument(CRegType)

reg (CReg): The classical register.

result class-attribute instance-attribute

result: ResultValue = result(BitType)

result (Bit): The bit at position idx.

CRegNew

Bases: Statement

Create a new classical register.

n_bits class-attribute instance-attribute

n_bits: SSAValue = argument(Int)

n_bits (Int): The number of bits in the register.

result class-attribute instance-attribute

result: ResultValue = result(CRegType)

result (CReg): The new classical register with all bits set to 0.

Measure

Bases: Statement

Measure a qubit and store the result in a bit.

carg class-attribute instance-attribute

carg: SSAValue = argument(BitType | CRegType)

carg (Bit | CReg): The bit or register to store the result in.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType | QRegType)

qarg (Qubit | QReg): The qubit or quantum register to measure.

QRegGet

Bases: Statement

Get a qubit from a quantum register.

idx class-attribute instance-attribute

idx: SSAValue = argument(Int)

idx (Int): The index of the qubit in the register.

reg class-attribute instance-attribute

reg: SSAValue = argument(QRegType)

reg (QReg): The quantum register.

result class-attribute instance-attribute

result: ResultValue = result(QubitType)

result (Qubit): The qubit at position idx.

QRegNew

Bases: Statement

Create a new quantum register.

n_qubits class-attribute instance-attribute

n_qubits: SSAValue = argument(Int)

n_qubits: The number of qubits in the register.

result class-attribute instance-attribute

result: ResultValue = result(QRegType)

A new quantum register with n_qubits set to |0>.

Reset

Bases: Statement

Reset a qubit to the |0> state.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType)

qarg (Qubit): The qubit to reset.

stmts

CRegEq

Bases: Statement

Check if two classical registers are equal.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(Int | CRegType | BitType)

lhs (CReg): The first register.

result class-attribute instance-attribute

result: ResultValue = result(Bool)

result (bool): True if the registers are equal, False otherwise.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(Int | CRegType | BitType)

rhs (CReg): The second register.

CRegGet

Bases: Statement

Get a bit from a classical register.

idx class-attribute instance-attribute

idx: SSAValue = argument(Int)

idx (Int): The index of the bit in the register.

reg class-attribute instance-attribute

reg: SSAValue = argument(CRegType)

reg (CReg): The classical register.

result class-attribute instance-attribute

result: ResultValue = result(BitType)

result (Bit): The bit at position idx.

CRegNew

Bases: Statement

Create a new classical register.

n_bits class-attribute instance-attribute

n_bits: SSAValue = argument(Int)

n_bits (Int): The number of bits in the register.

result class-attribute instance-attribute

result: ResultValue = result(CRegType)

result (CReg): The new classical register with all bits set to 0.

Measure

Bases: Statement

Measure a qubit and store the result in a bit.

carg class-attribute instance-attribute

carg: SSAValue = argument(BitType | CRegType)

carg (Bit | CReg): The bit or register to store the result in.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType | QRegType)

qarg (Qubit | QReg): The qubit or quantum register to measure.

QRegGet

Bases: Statement

Get a qubit from a quantum register.

idx class-attribute instance-attribute

idx: SSAValue = argument(Int)

idx (Int): The index of the qubit in the register.

reg class-attribute instance-attribute

reg: SSAValue = argument(QRegType)

reg (QReg): The quantum register.

result class-attribute instance-attribute

result: ResultValue = result(QubitType)

result (Qubit): The qubit at position idx.

QRegNew

Bases: Statement

Create a new quantum register.

n_qubits class-attribute instance-attribute

n_qubits: SSAValue = argument(Int)

n_qubits: The number of qubits in the register.

result class-attribute instance-attribute

result: ResultValue = result(QRegType)

A new quantum register with n_qubits set to |0>.

Reset

Bases: Statement

Reset a qubit to the |0> state.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType)

qarg (Qubit): The qubit to reset.

dialects

core

BitType module-attribute

BitType = PyClass(Bit)

Kirin type for a classical bit.

CRegType module-attribute

CRegType = PyClass(CReg)

Kirin type for a classical register.

QRegType module-attribute

QRegType = IListType[QubitType, Any]

Kirin type for a quantum register.

QubitType module-attribute

QubitType = PyClass(Qubit)

Kirin type for a qubit.

CRegEq

Bases: Statement

Check if two classical registers are equal.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(Int | CRegType | BitType)

lhs (CReg): The first register.

result class-attribute instance-attribute

result: ResultValue = result(Bool)

result (bool): True if the registers are equal, False otherwise.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(Int | CRegType | BitType)

rhs (CReg): The second register.

CRegGet

Bases: Statement

Get a bit from a classical register.

idx class-attribute instance-attribute

idx: SSAValue = argument(Int)

idx (Int): The index of the bit in the register.

reg class-attribute instance-attribute

reg: SSAValue = argument(CRegType)

reg (CReg): The classical register.

result class-attribute instance-attribute

result: ResultValue = result(BitType)

result (Bit): The bit at position idx.

CRegNew

Bases: Statement

Create a new classical register.

n_bits class-attribute instance-attribute

n_bits: SSAValue = argument(Int)

n_bits (Int): The number of bits in the register.

result class-attribute instance-attribute

result: ResultValue = result(CRegType)

result (CReg): The new classical register with all bits set to 0.

Measure

Bases: Statement

Measure a qubit and store the result in a bit.

carg class-attribute instance-attribute

carg: SSAValue = argument(BitType | CRegType)

carg (Bit | CReg): The bit or register to store the result in.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType | QRegType)

qarg (Qubit | QReg): The qubit or quantum register to measure.

QRegGet

Bases: Statement

Get a qubit from a quantum register.

idx class-attribute instance-attribute

idx: SSAValue = argument(Int)

idx (Int): The index of the qubit in the register.

reg class-attribute instance-attribute

reg: SSAValue = argument(QRegType)

reg (QReg): The quantum register.

result class-attribute instance-attribute

result: ResultValue = result(QubitType)

result (Qubit): The qubit at position idx.

QRegNew

Bases: Statement

Create a new quantum register.

n_qubits class-attribute instance-attribute

n_qubits: SSAValue = argument(Int)

n_qubits: The number of qubits in the register.

result class-attribute instance-attribute

result: ResultValue = result(QRegType)

A new quantum register with n_qubits set to |0>.

Reset

Bases: Statement

Reset a qubit to the |0> state.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType)

qarg (Qubit): The qubit to reset.

stmts

CRegEq

Bases: Statement

Check if two classical registers are equal.

lhs class-attribute instance-attribute
lhs: SSAValue = argument(Int | CRegType | BitType)

lhs (CReg): The first register.

result class-attribute instance-attribute
result: ResultValue = result(Bool)

result (bool): True if the registers are equal, False otherwise.

rhs class-attribute instance-attribute
rhs: SSAValue = argument(Int | CRegType | BitType)

rhs (CReg): The second register.

CRegGet

Bases: Statement

Get a bit from a classical register.

idx class-attribute instance-attribute
idx: SSAValue = argument(Int)

idx (Int): The index of the bit in the register.

reg class-attribute instance-attribute
reg: SSAValue = argument(CRegType)

reg (CReg): The classical register.

result class-attribute instance-attribute
result: ResultValue = result(BitType)

result (Bit): The bit at position idx.

CRegNew

Bases: Statement

Create a new classical register.

n_bits class-attribute instance-attribute
n_bits: SSAValue = argument(Int)

n_bits (Int): The number of bits in the register.

result class-attribute instance-attribute
result: ResultValue = result(CRegType)

result (CReg): The new classical register with all bits set to 0.

Measure

Bases: Statement

Measure a qubit and store the result in a bit.

carg class-attribute instance-attribute
carg: SSAValue = argument(BitType | CRegType)

carg (Bit | CReg): The bit or register to store the result in.

qarg class-attribute instance-attribute
qarg: SSAValue = argument(QubitType | QRegType)

qarg (Qubit | QReg): The qubit or quantum register to measure.

QRegGet

Bases: Statement

Get a qubit from a quantum register.

idx class-attribute instance-attribute
idx: SSAValue = argument(Int)

idx (Int): The index of the qubit in the register.

reg class-attribute instance-attribute
reg: SSAValue = argument(QRegType)

reg (QReg): The quantum register.

result class-attribute instance-attribute
result: ResultValue = result(QubitType)

result (Qubit): The qubit at position idx.

QRegNew

Bases: Statement

Create a new quantum register.

n_qubits class-attribute instance-attribute
n_qubits: SSAValue = argument(Int)

n_qubits: The number of qubits in the register.

result class-attribute instance-attribute
result: ResultValue = result(QRegType)

A new quantum register with n_qubits set to |0>.

Reset

Bases: Statement

Reset a qubit to the |0> state.

qarg class-attribute instance-attribute
qarg: SSAValue = argument(QubitType)

qarg (Qubit): The qubit to reset.

expr

Add

Bases: Statement

Add two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the addition.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the addition.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the addition.

ConstFloat

Bases: Statement

IR Statement representing a constant float value.

result class-attribute instance-attribute

result: ResultValue = result(Float)

result (Float): The result value.

value class-attribute instance-attribute

value: float = attribute(Float)

value (float): The constant float value.

ConstInt

Bases: Statement

IR Statement representing a constant integer value.

result class-attribute instance-attribute

result: ResultValue = result(Int)

result (Int): The result value.

value class-attribute instance-attribute

value: int = attribute(Int)

value (int): The constant integer value.

ConstPI

Bases: Statement

The constant value of PI.

result class-attribute instance-attribute

result: ResultValue = result(Float)

result (ConstPI): The result value.

Cos

Bases: Statement

Take the cosine of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The cosine of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the cosine of.

Div

Bases: Statement

Divide two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The numerator.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the division.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The denominator.

Exp

Bases: Statement

Take the exponential of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The exponential of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the exponential of.

GateFunction

Bases: Statement

Special Function for qasm2 gate subroutine.

Log

Bases: Statement

Take the natural log of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The natural log of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the natural log of.

Mul

Bases: Statement

Multiply two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the multiplication.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the multiplication.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the multiplication.

Neg

Bases: Statement

Negate a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The negated number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to negate.

Pow

Bases: Statement

Take the power of a number.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The base.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the power operation.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The exponent.

Sin

Bases: Statement

Take the sine of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The sine of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the sine of.

Sqrt

Bases: Statement

Take the square root of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The square root of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the square root of.

Sub

Bases: Statement

Subtract two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the subtraction.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the subtraction.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the subtraction.

Tan

Bases: Statement

Take the tangent of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The tangent of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the tangent of.

stmts

Add

Bases: Statement

Add two numbers.

lhs class-attribute instance-attribute
lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the addition.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the addition.

rhs class-attribute instance-attribute
rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the addition.

ConstFloat

Bases: Statement

IR Statement representing a constant float value.

result class-attribute instance-attribute
result: ResultValue = result(Float)

result (Float): The result value.

value class-attribute instance-attribute
value: float = attribute(Float)

value (float): The constant float value.

ConstInt

Bases: Statement

IR Statement representing a constant integer value.

result class-attribute instance-attribute
result: ResultValue = result(Int)

result (Int): The result value.

value class-attribute instance-attribute
value: int = attribute(Int)

value (int): The constant integer value.

ConstPI

Bases: Statement

The constant value of PI.

result class-attribute instance-attribute
result: ResultValue = result(Float)

result (ConstPI): The result value.

Cos

Bases: Statement

Take the cosine of a number.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (float): The cosine of the number.

value class-attribute instance-attribute
value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the cosine of.

Div

Bases: Statement

Divide two numbers.

lhs class-attribute instance-attribute
lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The numerator.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the division.

rhs class-attribute instance-attribute
rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The denominator.

Exp

Bases: Statement

Take the exponential of a number.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (float): The exponential of the number.

value class-attribute instance-attribute
value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the exponential of.

GateFunction

Bases: Statement

Special Function for qasm2 gate subroutine.

Log

Bases: Statement

Take the natural log of a number.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (float): The natural log of the number.

value class-attribute instance-attribute
value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the natural log of.

Mul

Bases: Statement

Multiply two numbers.

lhs class-attribute instance-attribute
lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the multiplication.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the multiplication.

rhs class-attribute instance-attribute
rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the multiplication.

Neg

Bases: Statement

Negate a number.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (Union[int, float]): The negated number.

value class-attribute instance-attribute
value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to negate.

Pow

Bases: Statement

Take the power of a number.

lhs class-attribute instance-attribute
lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The base.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the power operation.

rhs class-attribute instance-attribute
rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The exponent.

Sin

Bases: Statement

Take the sine of a number.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (float): The sine of the number.

value class-attribute instance-attribute
value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the sine of.

Sqrt

Bases: Statement

Take the square root of a number.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (float): The square root of the number.

value class-attribute instance-attribute
value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the square root of.

Sub

Bases: Statement

Subtract two numbers.

lhs class-attribute instance-attribute
lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the subtraction.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the subtraction.

rhs class-attribute instance-attribute
rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the subtraction.

Tan

Bases: Statement

Take the tangent of a number.

result class-attribute instance-attribute
result: ResultValue = result(PyNum)

result (float): The tangent of the number.

value class-attribute instance-attribute
value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the tangent of.

indexing

This dialect provides the indexing syntax in Python lowering for QASM2 dialects. The dialect itself does not contain new statements.

Using this dialect will be conflict with Python semantics provided by kirin.dialects.py.binop and kirin.dialects.py.indexing dialects.

inline

Inline QASM dialect.

This dialect allows users to use QASM string as part of a @qasm2.main kernel.

uop

QubitType module-attribute

QubitType = PyClass(Qubit)

Kirin type for a qubit.

Barrier

Bases: Statement

Apply the Barrier statement.

qargs class-attribute instance-attribute

qargs: tuple[SSAValue, ...] = argument(QubitType)

qargs: tuple of qubits to apply the barrier to.

CCX

Bases: Statement

Apply the doubly controlled X gate.

ctrl1 class-attribute instance-attribute

ctrl1: SSAValue = argument(QubitType)

ctrl1 (Qubit): The first control qubit.

ctrl2 class-attribute instance-attribute

ctrl2: SSAValue = argument(QubitType)

ctrl2 (Qubit): The second control qubit.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType)

qarg (Qubit): The target qubit.

CH

Bases: TwoQubitCtrlGate

Apply the Controlled-H gate.

CRX

Bases: TwoQubitCtrlGate

Apply the Controlled-RX gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The angle to rotate around the X axis.

CRY

Bases: TwoQubitCtrlGate

Apply the Controlled-RY gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The angle to rotate around the Y axis.

CRZ

Bases: TwoQubitCtrlGate

Apply the Controlled-RZ gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The angle to rotate around the Z axis.

CSX

Bases: TwoQubitCtrlGate

Apply the Controlled-Sqrt(X) gate.

CSwap

Bases: Statement

Apply the controlled swap gate.

ctrl class-attribute instance-attribute

ctrl: SSAValue = argument(QubitType)

ctrl (Qubit): The control qubit.

qarg1 class-attribute instance-attribute

qarg1: SSAValue = argument(QubitType)

qarg1 (Qubit): The first target qubit.

qarg2 class-attribute instance-attribute

qarg2: SSAValue = argument(QubitType)

qarg2 (Qubit): The second target qubit.

CU

Bases: TwoQubitCtrlGate

Apply the Controlled-U gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute

phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

CU1

Bases: TwoQubitCtrlGate

Apply the Controlled-U1 gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

CU3

Bases: TwoQubitCtrlGate

Apply the Controlled-U3 gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute

phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

CX

Bases: TwoQubitCtrlGate

Alias for the CNOT or CH gate operations.

CY

Bases: TwoQubitCtrlGate

Apply the Controlled-Y gate.

CZ

Bases: TwoQubitCtrlGate

Apply the Controlled-Z gate.

H

Bases: SingleQubitGate

Apply the Hadamard gate.

Id

Bases: SingleQubitGate

Apply the Identity gate.

RX

Bases: SingleQubitGate

Apply the RX gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around x axis.

RXX

Bases: TwoQubitCtrlGate

Apply the XX rotation gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around the X axis.

RY

Bases: SingleQubitGate

Apply the RY gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around y axis.

RZ

Bases: SingleQubitGate

Apply the RZ gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): the angle of rotation around Z axis.

RZZ

Bases: TwoQubitCtrlGate

Apply the ZZ rotation gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around the Z axis.

S

Bases: SingleQubitGate

Apply the S gate.

SX

Bases: SingleQubitGate

Apply the quantum Sqrt(X) gate.

SXdag

Bases: SingleQubitGate

Apply the dagger of quantum Sqrt(X) gate.

Sdag

Bases: SingleQubitGate

Apply the hermitian conj of S gate.

SingleQubitGate

Bases: Statement

Base class for single qubit gates.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType)

qarg (Qubit): The qubit argument.

Swap

Bases: TwoQubitCtrlGate

Apply the Swap gate.

T

Bases: SingleQubitGate

Apply the T gate.

Tdag

Bases: SingleQubitGate

Apply the hermitian conj of T gate.

TwoQubitCtrlGate

Bases: Statement

ctrl class-attribute instance-attribute

ctrl: SSAValue = argument(QubitType)

ctrl (Qubit): The control qubit.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType)

qarg (Qubit): The target qubit.

U1

Bases: SingleQubitGate

Apply the U1 gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

U2

Bases: SingleQubitGate

Apply the U2 gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute

phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

UGate

Bases: SingleQubitGate

Apply A general single qubit unitary gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute

phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The theta parameter.

X

Bases: SingleQubitGate

Apply the X gate.

Y

Bases: SingleQubitGate

Apply the Y gate.

Z

Bases: SingleQubitGate

Apply the Z gate.

stmts

Barrier

Bases: Statement

Apply the Barrier statement.

qargs class-attribute instance-attribute
qargs: tuple[SSAValue, ...] = argument(QubitType)

qargs: tuple of qubits to apply the barrier to.

CCX

Bases: Statement

Apply the doubly controlled X gate.

ctrl1 class-attribute instance-attribute
ctrl1: SSAValue = argument(QubitType)

ctrl1 (Qubit): The first control qubit.

ctrl2 class-attribute instance-attribute
ctrl2: SSAValue = argument(QubitType)

ctrl2 (Qubit): The second control qubit.

qarg class-attribute instance-attribute
qarg: SSAValue = argument(QubitType)

qarg (Qubit): The target qubit.

CH

Bases: TwoQubitCtrlGate

Apply the Controlled-H gate.

CRX

Bases: TwoQubitCtrlGate

Apply the Controlled-RX gate.

lam class-attribute instance-attribute
lam: SSAValue = argument(PyNum)

lam (float): The angle to rotate around the X axis.

CRY

Bases: TwoQubitCtrlGate

Apply the Controlled-RY gate.

lam class-attribute instance-attribute
lam: SSAValue = argument(PyNum)

lam (float): The angle to rotate around the Y axis.

CRZ

Bases: TwoQubitCtrlGate

Apply the Controlled-RZ gate.

lam class-attribute instance-attribute
lam: SSAValue = argument(PyNum)

lam (float): The angle to rotate around the Z axis.

CSX

Bases: TwoQubitCtrlGate

Apply the Controlled-Sqrt(X) gate.

CSwap

Bases: Statement

Apply the controlled swap gate.

ctrl class-attribute instance-attribute
ctrl: SSAValue = argument(QubitType)

ctrl (Qubit): The control qubit.

qarg1 class-attribute instance-attribute
qarg1: SSAValue = argument(QubitType)

qarg1 (Qubit): The first target qubit.

qarg2 class-attribute instance-attribute
qarg2: SSAValue = argument(QubitType)

qarg2 (Qubit): The second target qubit.

CU

Bases: TwoQubitCtrlGate

Apply the Controlled-U gate.

lam class-attribute instance-attribute
lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute
phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

CU1

Bases: TwoQubitCtrlGate

Apply the Controlled-U1 gate.

lam class-attribute instance-attribute
lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

CU3

Bases: TwoQubitCtrlGate

Apply the Controlled-U3 gate.

lam class-attribute instance-attribute
lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute
phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

CX

Bases: TwoQubitCtrlGate

Alias for the CNOT or CH gate operations.

CY

Bases: TwoQubitCtrlGate

Apply the Controlled-Y gate.

CZ

Bases: TwoQubitCtrlGate

Apply the Controlled-Z gate.

H

Bases: SingleQubitGate

Apply the Hadamard gate.

Id

Bases: SingleQubitGate

Apply the Identity gate.

RX

Bases: SingleQubitGate

Apply the RX gate.

theta class-attribute instance-attribute
theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around x axis.

RXX

Bases: TwoQubitCtrlGate

Apply the XX rotation gate.

theta class-attribute instance-attribute
theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around the X axis.

RY

Bases: SingleQubitGate

Apply the RY gate.

theta class-attribute instance-attribute
theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around y axis.

RZ

Bases: SingleQubitGate

Apply the RZ gate.

theta class-attribute instance-attribute
theta: SSAValue = argument(PyNum)

theta (float): the angle of rotation around Z axis.

RZZ

Bases: TwoQubitCtrlGate

Apply the ZZ rotation gate.

theta class-attribute instance-attribute
theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around the Z axis.

S

Bases: SingleQubitGate

Apply the S gate.

SX

Bases: SingleQubitGate

Apply the quantum Sqrt(X) gate.

SXdag

Bases: SingleQubitGate

Apply the dagger of quantum Sqrt(X) gate.

Sdag

Bases: SingleQubitGate

Apply the hermitian conj of S gate.

SingleQubitGate

Bases: Statement

Base class for single qubit gates.

qarg class-attribute instance-attribute
qarg: SSAValue = argument(QubitType)

qarg (Qubit): The qubit argument.

Swap

Bases: TwoQubitCtrlGate

Apply the Swap gate.

T

Bases: SingleQubitGate

Apply the T gate.

Tdag

Bases: SingleQubitGate

Apply the hermitian conj of T gate.

TwoQubitCtrlGate

Bases: Statement

ctrl class-attribute instance-attribute
ctrl: SSAValue = argument(QubitType)

ctrl (Qubit): The control qubit.

qarg class-attribute instance-attribute
qarg: SSAValue = argument(QubitType)

qarg (Qubit): The target qubit.

U1

Bases: SingleQubitGate

Apply the U1 gate.

lam class-attribute instance-attribute
lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

U2

Bases: SingleQubitGate

Apply the U2 gate.

lam class-attribute instance-attribute
lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute
phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

UGate

Bases: SingleQubitGate

Apply A general single qubit unitary gate.

lam class-attribute instance-attribute
lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute
phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

theta class-attribute instance-attribute
theta: SSAValue = argument(PyNum)

theta (float): The theta parameter.

X

Bases: SingleQubitGate

Apply the X gate.

Y

Bases: SingleQubitGate

Apply the Y gate.

Z

Bases: SingleQubitGate

Apply the Z gate.

emit

target

QASM2

QASM2(
    qelib1: bool = True,
    allow_parallel: bool = False,
    allow_global: bool = False,
    custom_gate: bool = True,
)

QASM2 target for Bloqade kernels.

QASM2 target that accepts a Bloqade kernel and produces an AST that you can then obtain a string for printing or saving as a file.

Parameters:

Name Type Description Default
allow_parallel bool

Allow parallel gate in the resulting QASM2 AST. Defaults to False. In the case its False, and the input kernel uses parallel gates, they will get rewrite into uop gates.

False
allow_global bool

Allow global gate in the resulting QASM2 AST. Defaults to False. In the case its False, and the input kernel uses global gates, they will get rewrite into parallel gates. If both allow_parallel and allow_global are False, the input kernel will be rewritten to use uop gates.

False
qelib1 bool

Include the include "qelib1.inc" line in the resulting QASM2 AST that's submitted to qBraid. Defaults to True.

True
custom_gate bool

Include the custom gate definitions in the resulting QASM2 AST. Defaults to True. If False, all the qasm2.gate will be inlined.

True
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/emit/target.py
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
def __init__(
    self,
    qelib1: bool = True,
    allow_parallel: bool = False,
    allow_global: bool = False,
    custom_gate: bool = True,
) -> None:
    """Initialize the QASM2 target.

    Args:
        allow_parallel (bool):
            Allow parallel gate in the resulting QASM2 AST. Defaults to `False`.
            In the case its False, and the input kernel uses parallel gates, they will get rewrite into uop gates.

        allow_global (bool):
            Allow global gate in the resulting QASM2 AST. Defaults to `False`.
            In the case its False, and the input kernel uses global gates, they will get rewrite into parallel gates.
            If both `allow_parallel` and `allow_global` are False, the input kernel will be rewritten to use uop gates.

        qelib1 (bool):
            Include the `include "qelib1.inc"` line in the resulting QASM2 AST that's
            submitted to qBraid. Defaults to `True`.
        custom_gate (bool):
            Include the custom gate definitions in the resulting QASM2 AST. Defaults to `True`. If `False`, all the qasm2.gate will be inlined.



    """
    from bloqade import qasm2

    self.main_target = qasm2.main
    self.gate_target = qasm2.gate

    self.qelib1 = qelib1
    self.custom_gate = custom_gate
    self.allow_parallel = allow_parallel
    self.allow_global = allow_global

    if allow_parallel:
        self.main_target = self.main_target.add(qasm2.dialects.parallel)
        self.gate_target = self.gate_target.add(qasm2.dialects.parallel)

    if allow_global:
        self.main_target = self.main_target.add(qasm2.dialects.glob)
        self.gate_target = self.gate_target.add(qasm2.dialects.glob)

    if allow_global or allow_parallel:
        self.main_target = self.main_target.add(ilist)
        self.gate_target = self.gate_target.add(ilist)

emit

emit(entry: Method) -> ast.MainProgram

Emit a QASM2 AST from the Bloqade kernel.

Parameters:

Name Type Description Default
entry Method

The Bloqade kernel to convert to the QASM2 AST

required

Returns:

Type Description
MainProgram

ast.MainProgram: A QASM2 AST object

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/emit/target.py
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
def emit(self, entry: ir.Method) -> ast.MainProgram:
    """Emit a QASM2 AST from the Bloqade kernel.

    Args:
        entry (ir.Method):
            The Bloqade kernel to convert to the QASM2 AST

    Returns:
        ast.MainProgram:
            A QASM2 AST object

    """
    assert len(entry.args) == 0, "entry method should not have arguments"

    # make a cloned instance of kernel
    entry = entry.similar()
    QASM2Fold(entry.dialects, inline_gate_subroutine=not self.custom_gate).fixpoint(
        entry
    )

    if not self.allow_global:
        # rewrite global to parallel
        GlobalToParallel(dialects=entry.dialects)(entry)

    if not self.allow_parallel:
        # rewrite parallel to uop
        ParallelToUOp(dialects=entry.dialects)(entry)

    Py2QASM(entry.dialects)(entry)
    target_main = EmitQASM2Main(self.main_target)
    target_main.run(entry, ())

    main_program = target_main.output
    assert main_program is not None, f"failed to emit {entry.sym_name}"

    extra = []
    if self.qelib1:
        extra.append(ast.Include("qelib1.inc"))

    if self.custom_gate:
        cg = CallGraph(entry)
        target_gate = EmitQASM2Gate(self.gate_target)

        for _, fn in cg.defs.items():
            if fn is entry:
                continue

            fn = fn.similar()
            QASM2Fold(fn.dialects).fixpoint(fn)

            if not self.allow_global:
                # rewrite global to parallel
                GlobalToParallel(dialects=fn.dialects)(fn)

            if not self.allow_parallel:
                # rewrite parallel to uop
                ParallelToUOp(dialects=fn.dialects)(fn)

            Py2QASM(fn.dialects)(fn)

            target_gate.run(fn, tuple(ast.Name(name) for name in fn.arg_names[1:]))
            assert target_gate.output is not None, f"failed to emit {fn.sym_name}"
            extra.append(target_gate.output)

    main_program.statements = extra + main_program.statements
    return main_program

emit_str

emit_str(entry: Method) -> str

Emit a QASM2 AST from the Bloqade kernel.

Parameters:

Name Type Description Default
entry Method

The Bloqade kernel to convert to the QASM2 AST

required

Returns:

Name Type Description
str str

A string with the QASM2 representation of the kernel

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/emit/target.py
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
def emit_str(self, entry: ir.Method) -> str:
    """Emit a QASM2 AST from the Bloqade kernel.

    Args:
        entry (ir.Method):
            The Bloqade kernel to convert to the QASM2 AST

    Returns:
        str:
            A string with the QASM2 representation of the kernel

    """
    console = Console(
        file=io.StringIO(),
        force_terminal=False,
        force_interactive=False,
        force_jupyter=False,
        record=True,
    )
    pprint(self.emit(entry), console=console)
    return console.export_text()

expr

Add

Bases: Statement

Add two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the addition.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the addition.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the addition.

ConstFloat

Bases: Statement

IR Statement representing a constant float value.

result class-attribute instance-attribute

result: ResultValue = result(Float)

result (Float): The result value.

value class-attribute instance-attribute

value: float = attribute(Float)

value (float): The constant float value.

ConstInt

Bases: Statement

IR Statement representing a constant integer value.

result class-attribute instance-attribute

result: ResultValue = result(Int)

result (Int): The result value.

value class-attribute instance-attribute

value: int = attribute(Int)

value (int): The constant integer value.

ConstPI

Bases: Statement

The constant value of PI.

result class-attribute instance-attribute

result: ResultValue = result(Float)

result (ConstPI): The result value.

Cos

Bases: Statement

Take the cosine of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The cosine of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the cosine of.

Div

Bases: Statement

Divide two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The numerator.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the division.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The denominator.

Exp

Bases: Statement

Take the exponential of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The exponential of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the exponential of.

GateFunction

Bases: Statement

Special Function for qasm2 gate subroutine.

Log

Bases: Statement

Take the natural log of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The natural log of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the natural log of.

Mul

Bases: Statement

Multiply two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the multiplication.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the multiplication.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the multiplication.

Neg

Bases: Statement

Negate a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The negated number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to negate.

Pow

Bases: Statement

Take the power of a number.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The base.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the power operation.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The exponent.

Sin

Bases: Statement

Take the sine of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The sine of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the sine of.

Sqrt

Bases: Statement

Take the square root of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The square root of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the square root of.

Sub

Bases: Statement

Subtract two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the subtraction.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the subtraction.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the subtraction.

Tan

Bases: Statement

Take the tangent of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The tangent of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the tangent of.

stmts

Add

Bases: Statement

Add two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the addition.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the addition.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the addition.

ConstFloat

Bases: Statement

IR Statement representing a constant float value.

result class-attribute instance-attribute

result: ResultValue = result(Float)

result (Float): The result value.

value class-attribute instance-attribute

value: float = attribute(Float)

value (float): The constant float value.

ConstInt

Bases: Statement

IR Statement representing a constant integer value.

result class-attribute instance-attribute

result: ResultValue = result(Int)

result (Int): The result value.

value class-attribute instance-attribute

value: int = attribute(Int)

value (int): The constant integer value.

ConstPI

Bases: Statement

The constant value of PI.

result class-attribute instance-attribute

result: ResultValue = result(Float)

result (ConstPI): The result value.

Cos

Bases: Statement

Take the cosine of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The cosine of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the cosine of.

Div

Bases: Statement

Divide two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The numerator.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the division.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The denominator.

Exp

Bases: Statement

Take the exponential of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The exponential of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the exponential of.

GateFunction

Bases: Statement

Special Function for qasm2 gate subroutine.

Log

Bases: Statement

Take the natural log of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The natural log of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the natural log of.

Mul

Bases: Statement

Multiply two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the multiplication.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the multiplication.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the multiplication.

Neg

Bases: Statement

Negate a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The negated number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to negate.

Pow

Bases: Statement

Take the power of a number.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The base.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the power operation.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The exponent.

Sin

Bases: Statement

Take the sine of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The sine of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the sine of.

Sqrt

Bases: Statement

Take the square root of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The square root of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the square root of.

Sub

Bases: Statement

Subtract two numbers.

lhs class-attribute instance-attribute

lhs: SSAValue = argument(PyNum)

lhs (Union[int, float]): The left-hand side of the subtraction.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (Union[int, float]): The result of the subtraction.

rhs class-attribute instance-attribute

rhs: SSAValue = argument(PyNum)

rhs (Union[int, float]): The right-hand side of the subtraction.

Tan

Bases: Statement

Take the tangent of a number.

result class-attribute instance-attribute

result: ResultValue = result(PyNum)

result (float): The tangent of the number.

value class-attribute instance-attribute

value: SSAValue = argument(PyNum)

value (Union[int, float]): The number to take the tangent of.

glob

QASM2 extension for global gates.

u

u(
    registers: IList[QReg, Any] | list,
    theta: float,
    phi: float,
    lam: float,
) -> None

Apply a U gate to all qubits in the input registers.

Parameters:

Name Type Description Default
theta float

The angle theta.

required
phi float

The angle phi.

required
lam float

The angle lam.

required
registers IList[QReg] | list[QReg]

The registers to apply the gate to.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/glob.py
12
13
14
15
16
17
18
19
20
21
22
23
24
@wraps(glob.UGate)
def u(
    registers: ilist.IList[QReg, Any] | list, theta: float, phi: float, lam: float
) -> None:
    """Apply a U gate to all qubits in the input registers.

    Args:
        theta (float): The angle theta.
        phi (float): The angle phi.
        lam (float): The angle lam.
        registers (IList[QReg] | list[QReg]): The registers to apply the gate to.

    """

inline_

Inline QASM dialect.

This dialect allows users to use QASM string as part of a @qasm2.main kernel.

parallel

QASM2 extension for parallel execution of gates.

cz

cz(
    ctrls: IList[Qubit, Any] | list,
    qargs: IList[Qubit, Any] | list,
) -> None

Apply a controlled-Z gate to input qubits in parallel.

Parameters:

Name Type Description Default
ctrls IList[Qubit] | list[Qubit]

The control qubits.

required
qargs IList[Qubit] | list[Qubit]

The target qubits.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/parallel.py
12
13
14
15
16
17
18
19
20
21
22
@wraps(parallel.CZ)
def cz(
    ctrls: ilist.IList[Qubit, Any] | list, qargs: ilist.IList[Qubit, Any] | list
) -> None:
    """Apply a controlled-Z gate to input qubits in parallel.

    Args:
        ctrls (IList[Qubit] | list[Qubit]): The control qubits.
        qargs (IList[Qubit] | list[Qubit]): The target qubits.

    """

rz

rz(qargs: IList[Qubit, Any] | list, theta: float) -> None

Apply a RZ gate to input qubits in parallel.

Parameters:

Name Type Description Default
qargs IList[Qubit] | list[Qubit]

The target qubits.

required
theta float

The angle theta.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/parallel.py
40
41
42
43
44
45
46
47
48
@wraps(parallel.RZ)
def rz(qargs: ilist.IList[Qubit, Any] | list, theta: float) -> None:
    """Apply a RZ gate to input qubits in parallel.

    Args:
        qargs (IList[Qubit] | list[Qubit]): The target qubits.
        theta (float): The angle theta.

    """

u

u(
    qargs: IList[Qubit, Any] | list,
    theta: float,
    phi: float,
    lam: float,
) -> None

Apply a U gate to input qubits in parallel.

Parameters:

Name Type Description Default
qargs IList[Qubit] | list[Qubit]

The target qubits.

required
theta float

The angle theta.

required
phi float

The angle phi.

required
lam float

The angle lam.

required
Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/parallel.py
25
26
27
28
29
30
31
32
33
34
35
36
37
@wraps(parallel.UGate)
def u(
    qargs: ilist.IList[Qubit, Any] | list, theta: float, phi: float, lam: float
) -> None:
    """Apply a U gate to input qubits in parallel.

    Args:
        qargs (IList[Qubit] | list[Qubit]): The target qubits.
        theta (float): The angle theta.
        phi (float): The angle phi.
        lam (float): The angle lam.

    """

parse

lowering

QASM2 dataclass

QASM2(
    *,
    max_lines: int = 3,
    hint_indent: int = 2,
    hint_show_lineno: bool = True,
    stacktrace: bool = True
)

Bases: LoweringABC[Node]

branch_next_if_not_terminated

branch_next_if_not_terminated(frame: Frame)

Branch to the next block if the current block is not terminated.

This must be used after exhausting the current frame and before popping the frame.

Source code in .venv/lib/python3.12/site-packages/bloqade/qasm2/parse/lowering.py
371
372
373
374
375
376
377
378
379
380
381
def branch_next_if_not_terminated(self, frame: lowering.Frame):
    """Branch to the next block if the current block is not terminated.

    This must be used after exhausting the current frame and before popping the frame.
    """
    if not frame.curr_block.last_stmt or not frame.curr_block.last_stmt.has_trait(
        ir.IsTerminator
    ):
        frame.curr_block.stmts.append(
            cf.Branch(arguments=(), successor=frame.next_block)
        )

passes

fold

QASM2Fold dataclass

QASM2Fold(inline_gate_subroutine: bool = True)

Bases: Pass

Fold pass for qasm2.extended

glob

Passes that deal with global gates. As of now, only one rewrite pass exists which converts global gates to single qubit gates.

GlobalToParallel

Bases: Pass

Pass to convert Global gates into parallel gates.

This pass rewrites the global unitary gate from the qasm2.glob dialect into multiple parallel gates in the qasm2.parallel dialect.

Usage Examples
# Define kernel
@qasm2.extended
def main():
    q1 = qasm2.qreg(1)
    q2 = qasm2.qreg(2)

    theta = 1.3
    phi = 1.1
    lam = 1.2

    qasm2.glob.u(theta=theta, phi=phi, lam=lam, registers=[q1, q2])

GlobalToParallel(dialects=main.dialects)(main)

# Run rewrite
GlobalToParallel(main.dialects)(main)

The qasm2.glob.u statement has been rewritten to individual gates:

qasm2.parallel.u(theta=theta, phi=phi, lam=lam, qargs=[q1[0], q2[0], q2[1]])

GlobalToUOP

Bases: Pass

Pass to convert Global gates into single gates.

This pass rewrites the global unitary gate from the qasm2.glob dialect into multiple single gates in the qasm2.uop dialect, bringing the program closer to conforming to standard QASM2 syntax.

Usage Examples
# Define kernel
@qasm2.extended
def main():
    q1 = qasm2.qreg(1)
    q2 = qasm2.qreg(2)

    theta = 1.3
    phi = 1.1
    lam = 1.2

    qasm2.glob.u(theta=theta, phi=phi, lam=lam, registers=[q1, q2])

GlobalToUOP(dialects=main.dialects)(main)

# Run rewrite
GlobalToUOP(main.dialects)(main)

The qasm2.glob.u statement has been rewritten to individual gates:

qasm2.uop.u(q1[0], theta, phi, lam)
qasm2.uop.u(q2[0], theta, phi, lam)
qasm2.uop.u(q2[1], theta, phi, lam)

lift_qubits

LiftQubits

Bases: Pass

This pass lifts the creation of qubits to the block where the register is defined.

noise

NoisePass dataclass

NoisePass(
    noise_model: MoveNoiseModelABC = native.TwoRowZoneModel(),
    gate_noise_params: GateNoiseParams = native.GateNoiseParams(),
)

Bases: Pass

Apply a noise model to a quantum circuit.

NOTE: This pass is not guaranteed to be supported long-term in bloqade. We will be moving towards a more general approach to noise modeling in the future.

Usage examples
from bloqade import qasm2
from bloqade.noise import native
from bloqade.qasm2.passes.noise import NoisePass

noise_main = qasm2.extended.add(native.dialect)

@noise_main
def main():
    q = qasm2.qreg(2)
    qasm2.h(q[0])
    qasm2.cx(q[0], q[1])
    return q

# simple IR without any nosie
main.print()

noise_pass = NoisePass(noise_main)

# rewrite stuff in-place
noise_pass.unsafe_run(main)

# now, we do have noise channels in the IR
main.print()

parallel

Passes for converting parallel gates into multiple single gates as well as converting multiple single gates to parallel gates.

ParallelToUOp dataclass

ParallelToUOp()

Bases: Pass

Pass to convert parallel gates into single gates.

This pass rewrites any parallel gates from the qasm2.parallel dialect into multiple single gates in the qasm2.uop dialect, bringing the program closer to conforming to standard QASM2 syntax.

Usage Examples
# Define kernel
@qasm2.extended
def main():
    q = qasm2.qreg(4)

    qasm2.parallel.cz(ctrls=[q[0], q[2]], qargs=[q[1], q[3]])

# Run rewrite
ParallelToUOp(main.dialects)(main)

The qasm2.parallel.cz statement has been rewritten to individual gates:

qasm2.uop.cz(ctrl=q[0], qarg=q[1])
qasm2.uop.cz(ctrl=q[2], qarg=q[3])

UOpToParallel dataclass

UOpToParallel(
    merge_policy_type: Type[
        MergePolicyABC
    ] = SimpleOptimalMergePolicy,
)

Bases: Pass

Pass to convert single gates into parallel gates.

This pass looks for single gates from the qasm2.uop dialect that can be combined into parallel gates from the qasm2.parallel dialect and performs a rewrite to do so.

Usage Examples
# Define kernel
@qasm2.main
def test():
    q = qasm2.qreg(4)

    theta = 0.1
    phi = 0.2
    lam = 0.3

    qasm2.u(q[1], theta, phi, lam)
    qasm2.u(q[3], theta, phi, lam)
    qasm2.cx(q[1], q[3])
    qasm2.u(q[2], theta, phi, lam)
    qasm2.u(q[0], theta, phi, lam)
    qasm2.cx(q[0], q[2])

# Run rewrite
UOpToParallel(main.dialects)(main)

The individual qasm2.u statements have now been combined into a single qasm2.parallel.u statement.

qasm2.parallel.u(qargs = [q[0], q[1], q[2], q[3]], theta, phi, lam)
qasm2.uop.CX(q[1], q[3])
qasm2.uop.CX(q[0], q[2])

py2qasm

Rewrite py dialects into qasm dialects.

qasm2py

Rewrite qasm dialects into py dialects.

rewrite

heuristic_noise

NoiseRewriteRule dataclass

NoiseRewriteRule(
    address_analysis: Dict[SSAValue, Address],
    gate_noise_params: GateNoiseParams = native.GateNoiseParams(),
    noise_model: MoveNoiseModelABC = native.TwoRowZoneModel(),
)

Bases: RewriteRule

NOTE: This pass is not guaranteed to be supported long-term in bloqade. We will be moving towards a more general approach to noise modeling in the future.

register

RaiseRegisterRule

Bases: RewriteRule

This rule puts all registers at the top of the block.

This is required for the UOpToParallel rules to work correctly to handle cases where a register is defined in between two statements that can be parallelized.

uop_to_parallel

GreedyMixin

Bases: MergePolicyABC

Merge policy that greedily merges gates together.

The merge_gates method will merge policy will try greedily merge gates together. This policy has a worst case complexity of O(n) where n is the number of gates in the input iterable.

OptimalMixIn

Bases: MergePolicyABC

Merge policy that merges gates together optimally.

The merge_gates method will merge policy will try to merge every gate into every group of gates, terminating when it finds a group that can be merged with the current gate. This policy has a worst case complexity of O(n^2) where n is the number of gates in the input iterable.

SimpleMergePolicy dataclass

SimpleMergePolicy(
    address_analysis: Dict[SSAValue, Address],
    merge_groups: List[List[Statement]],
    group_numbers: Dict[Statement, int],
    group_has_merged: Dict[int, bool] = dict(),
)

Bases: MergePolicyABC

General merge policy for merging gates based on their type and arguments.

Base class to implement a merge policy for CZ, U and RZ gates, To completed the policy implement the merge_gates class method. This will take an iterable of statements and return a list of groups of statements that can be merged together. There are two mix-in classes that can be used to implement the merge_gates method. The GreedyMixin will merge gates together greedily, while the OptimalMixIn will merge gates together optimally.

address_analysis instance-attribute

address_analysis: Dict[SSAValue, Address]

Mapping from SSA values to their address analysis results. Needed for rewrites

group_has_merged class-attribute instance-attribute

group_has_merged: Dict[int, bool] = field(
    default_factory=dict
)

Mapping from group number to whether the group has been merged

group_numbers instance-attribute

group_numbers: Dict[Statement, int]

Mapping from statements to their group number

merge_groups instance-attribute

merge_groups: List[List[Statement]]

List of groups of statements that can be merged together

types

BitType module-attribute

BitType = PyClass(Bit)

Kirin type for a classical bit.

CRegType module-attribute

CRegType = PyClass(CReg)

Kirin type for a classical register.

QRegType module-attribute

QRegType = IListType[QubitType, Any]

Kirin type for a quantum register.

Bit

Runtime representation of a bit.

Note

This is the base class of more specific bit types, such as a reference to a piece of classical register in some quantum register dialects.

CReg

Runtime representation of a classical register.

uop

QubitType module-attribute

QubitType = PyClass(Qubit)

Kirin type for a qubit.

Barrier

Bases: Statement

Apply the Barrier statement.

qargs class-attribute instance-attribute

qargs: tuple[SSAValue, ...] = argument(QubitType)

qargs: tuple of qubits to apply the barrier to.

CCX

Bases: Statement

Apply the doubly controlled X gate.

ctrl1 class-attribute instance-attribute

ctrl1: SSAValue = argument(QubitType)

ctrl1 (Qubit): The first control qubit.

ctrl2 class-attribute instance-attribute

ctrl2: SSAValue = argument(QubitType)

ctrl2 (Qubit): The second control qubit.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType)

qarg (Qubit): The target qubit.

CH

Bases: TwoQubitCtrlGate

Apply the Controlled-H gate.

CRX

Bases: TwoQubitCtrlGate

Apply the Controlled-RX gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The angle to rotate around the X axis.

CRY

Bases: TwoQubitCtrlGate

Apply the Controlled-RY gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The angle to rotate around the Y axis.

CRZ

Bases: TwoQubitCtrlGate

Apply the Controlled-RZ gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The angle to rotate around the Z axis.

CSX

Bases: TwoQubitCtrlGate

Apply the Controlled-Sqrt(X) gate.

CSwap

Bases: Statement

Apply the controlled swap gate.

ctrl class-attribute instance-attribute

ctrl: SSAValue = argument(QubitType)

ctrl (Qubit): The control qubit.

qarg1 class-attribute instance-attribute

qarg1: SSAValue = argument(QubitType)

qarg1 (Qubit): The first target qubit.

qarg2 class-attribute instance-attribute

qarg2: SSAValue = argument(QubitType)

qarg2 (Qubit): The second target qubit.

CU

Bases: TwoQubitCtrlGate

Apply the Controlled-U gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute

phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

CU1

Bases: TwoQubitCtrlGate

Apply the Controlled-U1 gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

CU3

Bases: TwoQubitCtrlGate

Apply the Controlled-U3 gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute

phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

CX

Bases: TwoQubitCtrlGate

Alias for the CNOT or CH gate operations.

CY

Bases: TwoQubitCtrlGate

Apply the Controlled-Y gate.

CZ

Bases: TwoQubitCtrlGate

Apply the Controlled-Z gate.

H

Bases: SingleQubitGate

Apply the Hadamard gate.

Id

Bases: SingleQubitGate

Apply the Identity gate.

RX

Bases: SingleQubitGate

Apply the RX gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around x axis.

RXX

Bases: TwoQubitCtrlGate

Apply the XX rotation gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around the X axis.

RY

Bases: SingleQubitGate

Apply the RY gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around y axis.

RZ

Bases: SingleQubitGate

Apply the RZ gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): the angle of rotation around Z axis.

RZZ

Bases: TwoQubitCtrlGate

Apply the ZZ rotation gate.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The angle of rotation around the Z axis.

S

Bases: SingleQubitGate

Apply the S gate.

SX

Bases: SingleQubitGate

Apply the quantum Sqrt(X) gate.

SXdag

Bases: SingleQubitGate

Apply the dagger of quantum Sqrt(X) gate.

Sdag

Bases: SingleQubitGate

Apply the hermitian conj of S gate.

SingleQubitGate

Bases: Statement

Base class for single qubit gates.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType)

qarg (Qubit): The qubit argument.

Swap

Bases: TwoQubitCtrlGate

Apply the Swap gate.

T

Bases: SingleQubitGate

Apply the T gate.

Tdag

Bases: SingleQubitGate

Apply the hermitian conj of T gate.

TwoQubitCtrlGate

Bases: Statement

ctrl class-attribute instance-attribute

ctrl: SSAValue = argument(QubitType)

ctrl (Qubit): The control qubit.

qarg class-attribute instance-attribute

qarg: SSAValue = argument(QubitType)

qarg (Qubit): The target qubit.

U1

Bases: SingleQubitGate

Apply the U1 gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

U2

Bases: SingleQubitGate

Apply the U2 gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute

phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

UGate

Bases: SingleQubitGate

Apply A general single qubit unitary gate.

lam class-attribute instance-attribute

lam: SSAValue = argument(PyNum)

lam (float): The lambda parameter.

phi class-attribute instance-attribute

phi: SSAValue = argument(PyNum)

phi (float): The phi parameter.

theta class-attribute instance-attribute

theta: SSAValue = argument(PyNum)

theta (float): The theta parameter.

X

Bases: SingleQubitGate

Apply the X gate.

Y

Bases: SingleQubitGate

Apply the Y gate.

Z

Bases: SingleQubitGate

Apply the Z gate.