Skip to content

Index

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 src/bloqade/qasm2/_wrappers.py
103
104
105
106
107
108
109
110
111
112
@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 src/bloqade/qasm2/_wrappers.py
319
320
321
322
323
324
325
326
327
328
329
@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 src/bloqade/qasm2/_wrappers.py
305
306
307
308
309
310
311
312
313
314
315
316
@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 src/bloqade/qasm2/_wrappers.py
392
393
394
395
396
397
398
399
400
401
402
403
404
405
@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`.

    """

    ...

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 src/bloqade/qasm2/_wrappers.py
33
34
35
36
37
38
39
40
41
42
43
44
45
@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, theta: float) -> None

Controlled Rx rotation 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
Source code in src/bloqade/qasm2/_wrappers.py
332
333
334
335
336
337
338
339
340
341
342
343
344
@wraps(uop.CRX)
def crx(ctrl: Qubit, qarg: Qubit, theta: float) -> None:
    """
    Controlled Rx rotation gate.

    Args:
        ctrl: The control qubit.
        qarg: The target qubit.
        theta: 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 src/bloqade/qasm2/_wrappers.py
347
348
349
350
351
352
353
354
355
356
357
358
@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 src/bloqade/qasm2/_wrappers.py
361
362
363
364
365
366
367
368
369
370
371
372
373
374
@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 src/bloqade/qasm2/_wrappers.py
73
74
75
76
77
78
79
80
81
82
@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 src/bloqade/qasm2/_wrappers.py
292
293
294
295
296
297
298
299
300
301
302
@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 src/bloqade/qasm2/_wrappers.py
280
281
282
283
284
285
286
287
288
289
@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 src/bloqade/qasm2/_wrappers.py
424
425
426
427
428
429
430
431
432
433
434
435
436
437
@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 src/bloqade/qasm2/_wrappers.py
115
116
117
118
119
120
121
122
123
124
@wraps(uop.H)
def h(qarg: Qubit) -> None:
    """
    Hadamard 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 src/bloqade/qasm2/_wrappers.py
 7
 8
 9
10
11
12
13
14
15
@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 src/bloqade/qasm2/_wrappers.py
440
441
442
443
444
445
446
447
448
449
450
451
452
453
@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(qarg: Qubit, cbit: Bit) -> None

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

Parameters:

Name Type Description Default
qarg Qubit

The qubit to measure.

required
cbit Bit

The classical bit to store the result in.

required
Source code in src/bloqade/qasm2/_wrappers.py
61
62
63
64
65
66
67
68
69
70
@wraps(core.Measure)
def measure(qarg: Qubit, cbit: Bit) -> 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.
    """
    ...

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 src/bloqade/qasm2/_wrappers.py
18
19
20
21
22
23
24
25
26
27
28
29
30
@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 src/bloqade/qasm2/_wrappers.py
48
49
50
51
52
53
54
55
56
57
58
@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 src/bloqade/qasm2/_wrappers.py
213
214
215
216
217
218
219
220
221
222
@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.
    """
    ...

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 src/bloqade/qasm2/_wrappers.py
225
226
227
228
229
230
231
232
233
234
235
236
@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 src/bloqade/qasm2/_wrappers.py
239
240
241
242
243
244
245
246
247
248
@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.
    """
    ...

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 src/bloqade/qasm2/_wrappers.py
163
164
165
166
167
168
169
170
171
172
@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 src/bloqade/qasm2/_wrappers.py
175
176
177
178
179
180
181
182
183
184
185
@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 src/bloqade/qasm2/_wrappers.py
377
378
379
380
381
382
383
384
385
386
387
388
389
@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 src/bloqade/qasm2/_wrappers.py
456
457
458
459
460
461
462
463
464
465
466
467
@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`.
    """
    ...

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 src/bloqade/qasm2/_wrappers.py
188
189
190
191
192
193
194
195
196
197
@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 src/bloqade/qasm2/_wrappers.py
408
409
410
411
412
413
414
415
416
417
418
419
420
421
@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 src/bloqade/qasm2/_wrappers.py
200
201
202
203
204
205
206
207
208
209
210
@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 src/bloqade/qasm2/_wrappers.py
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
@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 src/bloqade/qasm2/_wrappers.py
251
252
253
254
255
256
257
258
259
260
261
262
@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 src/bloqade/qasm2/_wrappers.py
265
266
267
268
269
270
271
272
273
274
275
276
277
@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.
    """
    ...

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 src/bloqade/qasm2/_wrappers.py
127
128
129
130
131
132
133
134
135
136
@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 src/bloqade/qasm2/_wrappers.py
139
140
141
142
143
144
145
146
147
148
@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 src/bloqade/qasm2/_wrappers.py
151
152
153
154
155
156
157
158
159
160
@wraps(uop.Z)
def z(qarg: Qubit) -> None:
    """
    Pauli-Z gate.

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

    """
    ...