Skip to content

Braket

BraketHardwareRoutine

Bases: RoutineBase

__call__

__call__(
    *args: LiteralType,
    shots: int = 1,
    name: Optional[str] = None,
    use_experimental: bool = False,
    shuffle: bool = False,
    **kwargs
)

Compile to a RemoteBatch, which contain Braket backend specific tasks, run_async to Braket, and wait until the results are coming back.

Note

This is sync, and will wait until remote results finished.

Parameters:

Name Type Description Default
shots int

number of shots

1
args LiteralType

additional arguments for args variables.

()
name str

custom name of the batch

None
shuffle bool

shuffle the order of jobs

False
Return

RemoteBatch

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/routine/braket.py
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
@beartype
def __call__(
    self,
    *args: LiteralType,
    shots: int = 1,
    name: Optional[str] = None,
    use_experimental: bool = False,
    shuffle: bool = False,
    **kwargs,
):
    """
    Compile to a RemoteBatch, which contain
    Braket backend specific tasks, run_async to Braket,
    and wait until the results are coming back.

    Note:
        This is sync, and will wait until remote results
        finished.

    Args:
        shots (int): number of shots
        args: additional arguments for args variables.
        name (str): custom name of the batch
        shuffle (bool): shuffle the order of jobs

    Return:
        RemoteBatch

    """
    return self.run(shots, args, name, use_experimental, shuffle, **kwargs)

run

run(
    shots: int,
    args: Tuple[LiteralType, ...] = (),
    name: Optional[str] = None,
    use_experimental: bool = False,
    shuffle: bool = False,
    **kwargs
) -> RemoteBatch

Compile to a RemoteBatch, which contain Braket backend specific tasks, run_async to Braket, and wait until the results are coming back.

Note

This is sync, and will wait until remote results finished.

Parameters:

Name Type Description Default
shots int

number of shots

required
args Tuple

additional arguments

()
name str

custom name of the batch

None
shuffle bool

shuffle the order of jobs

False
Return

RemoteBatch

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/routine/braket.py
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
@beartype
def run(
    self,
    shots: int,
    args: Tuple[LiteralType, ...] = (),
    name: Optional[str] = None,
    use_experimental: bool = False,
    shuffle: bool = False,
    **kwargs,
) -> RemoteBatch:
    """
    Compile to a RemoteBatch, which contain
    Braket backend specific tasks, run_async to Braket,
    and wait until the results are coming back.

    Note:
        This is sync, and will wait until remote results
        finished.

    Args:
        shots (int): number of shots
        args (Tuple): additional arguments
        name (str): custom name of the batch
        shuffle (bool): shuffle the order of jobs

    Return:
        RemoteBatch

    """

    batch = self.run_async(shots, args, name, use_experimental, shuffle, **kwargs)
    batch.pull()
    return batch

run_async

run_async(
    shots: int,
    args: Tuple[LiteralType, ...] = (),
    name: Optional[str] = None,
    use_experimental: bool = False,
    shuffle: bool = False,
    **kwargs
) -> RemoteBatch

Compile to a RemoteBatch, which contain Braket backend specific tasks, and run_async to Braket.

Note

This is async.

Parameters:

Name Type Description Default
shots int

number of shots

required
args Tuple

Values of the parameter defined in args, defaults to ()

()
name str | None

custom name of the batch, defaults to None

None
use_experimental bool

Use experimental hardware capabilities

False
shuffle bool

shuffle the order of jobs

False
Return

RemoteBatch

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/routine/braket.py
 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
@beartype
def run_async(
    self,
    shots: int,
    args: Tuple[LiteralType, ...] = (),
    name: Optional[str] = None,
    use_experimental: bool = False,
    shuffle: bool = False,
    **kwargs,
) -> RemoteBatch:
    """
    Compile to a RemoteBatch, which contain
    Braket backend specific tasks, and run_async to Braket.

    Note:
        This is async.

    Args:
        shots (int): number of shots
        args (Tuple): Values of the parameter defined in `args`, defaults to ()
        name (str | None): custom name of the batch, defaults to None
        use_experimental (bool): Use experimental hardware capabilities
        shuffle (bool): shuffle the order of jobs

    Return:
        RemoteBatch

    """

    batch = self._compile(shots, use_experimental, args, name)
    batch._submit(shuffle, **kwargs)
    return batch

BraketLocalEmulatorRoutine

Bases: RoutineBase

__call__

__call__(
    *args: LiteralType,
    shots: int = 1,
    name: Optional[str] = None,
    multiprocessing: bool = False,
    num_workers: Optional[int] = None,
    **kwargs
)

Compile to a LocalBatch, and run. The LocalBatch contain tasks to run on local emulator.

Note

This is sync, and will wait until remote results finished.

Parameters:

Name Type Description Default
shots int

number of shots

1
args LiteralType

additional arguments for args variables.

()
multiprocessing bool

enable multi-process

False
num_workers int

number of workers to run the emulator

None
Return

LocalBatch

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/routine/braket.py
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
@beartype
def __call__(
    self,
    *args: LiteralType,
    shots: int = 1,
    name: Optional[str] = None,
    multiprocessing: bool = False,
    num_workers: Optional[int] = None,
    **kwargs,
):
    """
    Compile to a LocalBatch, and run.
    The LocalBatch contain tasks to run on local emulator.

    Note:
        This is sync, and will wait until remote results
        finished.

    Args:
        shots (int): number of shots
        args: additional arguments for args variables.
        multiprocessing (bool): enable multi-process
        num_workers (int): number of workers to run the emulator

    Return:
        LocalBatch

    """
    return self.run(
        shots,
        args,
        name,
        multiprocessing=multiprocessing,
        num_workers=num_workers,
        **kwargs,
    )

run

run(
    shots: int,
    args: Tuple[LiteralType, ...] = (),
    name: Optional[str] = None,
    multiprocessing: bool = False,
    num_workers: Optional[int] = None,
    **kwargs
) -> LocalBatch

Compile to a LocalBatch, and run. The LocalBatch contain tasks to run on local emulator.

Note

This is sync, and will wait until remote results finished.

Parameters:

Name Type Description Default
shots int

number of shots

required
args Tuple[LiteralType, ...]

additional arguments for args variables.

()
multiprocessing bool

enable multi-process

False
num_workers int

number of workers to run the emulator

None
Return

LocalBatch

Source code in .venv/lib/python3.12/site-packages/bloqade/analog/ir/routine/braket.py
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
@beartype
def run(
    self,
    shots: int,
    args: Tuple[LiteralType, ...] = (),
    name: Optional[str] = None,
    multiprocessing: bool = False,
    num_workers: Optional[int] = None,
    **kwargs,
) -> LocalBatch:
    """
    Compile to a LocalBatch, and run.
    The LocalBatch contain tasks to run on local emulator.

    Note:
        This is sync, and will wait until remote results
        finished.

    Args:
        shots (int): number of shots
        args: additional arguments for args variables.
        multiprocessing (bool): enable multi-process
        num_workers (int): number of workers to run the emulator

    Return:
        LocalBatch

    """

    batch = self._compile(shots, args, name)
    batch._run(multiprocessing=multiprocessing, num_workers=num_workers, **kwargs)
    return batch