Skip to content

Target

qBraid

qBraid(
    *,
    allow_parallel: bool = False,
    allow_global: bool = False,
    provider: QbraidProvider,
    qelib1: bool = True
)

qBraid target for Bloqade kernels.

qBraid target that accepts a Bloqade kernel and submits the kernel to the QuEra simulator hosted on qBraid. A QbraidJob is obtainable that then lets you query the status of the submitted program on the simulator as well as obtain results.

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
provider QbraidProvider

Qbraid-provided object to allow submission of the kernel to the QuEra simulator.

required
qelib1 bool

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

True
Source code in .venv/lib/python3.12/site-packages/bloqade/qbraid/target.py
21
22
23
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
def __init__(
    self,
    *,
    allow_parallel: bool = False,
    allow_global: bool = False,
    provider: "QbraidProvider",  # inject externally for easier mocking
    qelib1: bool = True,
) -> None:
    """Initialize the qBraid 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.

        provider (QbraidProvider):
            Qbraid-provided object to allow submission of the kernel to the QuEra simulator.
        qelib1 (bool):
            Include the `include "qelib1.inc"` line in the resulting QASM2 AST that's
            submitted to qBraid. Defaults to `True`.
    """

    self.qelib1 = qelib1
    self.provider = provider
    self.allow_parallel = allow_parallel
    self.allow_global = allow_global

emit

emit(
    method: Method,
    shots: Optional[int] = None,
    tags: Optional[dict[str, str]] = None,
) -> Union[QbraidJob, list[QbraidJob]]

Submit the Bloqade kernel to the QuEra simulator on qBraid.

Parameters:

Name Type Description Default
method Method

The kernel to submit to qBraid.

required
shots Optional[int]

(Optional[int]): Number of times to run the kernel. Defaults to None.

None
tags Optional[dict[str, str]]

(Optional[dict[str,str]]): A dictionary of tags to associate with the Job.

None

Returns:

Type Description
Union[QbraidJob, list[QbraidJob]]

Union[QbraidJob, list[QbraidJob]]: An object you can query for the status of your submission as well as obtain simulator results from.

Source code in .venv/lib/python3.12/site-packages/bloqade/qbraid/target.py
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
def emit(
    self,
    method: ir.Method,
    shots: Optional[int] = None,
    tags: Optional[dict[str, str]] = None,
) -> Union["QbraidJob", list["QbraidJob"]]:
    """Submit the Bloqade kernel to the QuEra simulator on qBraid.

    Args:
        method (ir.Method):
            The kernel to submit to qBraid.
        shots: (Optional[int]):
            Number of times to run the kernel. Defaults to None.
        tags: (Optional[dict[str,str]]):
            A dictionary of tags to associate with the Job.

    Returns:
        Union[QbraidJob, list[QbraidJob]]:
            An object you can query for the status of your submission as well as
            obtain simulator results from.
    """

    # Convert method to QASM2 string
    qasm2_emitter = QASM2(
        allow_parallel=self.allow_parallel,
        allow_global=self.allow_global,
        qelib1=self.qelib1,
    )
    qasm2_prog = qasm2_emitter.emit_str(method)

    # Submit the QASM2 string to the qBraid simulator
    quera_qasm_simulator = self.provider.get_device("quera_qasm_simulator")

    return quera_qasm_simulator.run(qasm2_prog, shots=shots, tags=tags)