Skip to content

Braket

BraketHardwareRoutine

Bases: RoutineBase

__call__

__call__(
    *args,
    shots=1,
    name=None,
    use_experimental=False,
    shuffle=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 src/bloqade/ir/routine/braket.py
@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,
    args=(),
    name=None,
    use_experimental=False,
    shuffle=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

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 src/bloqade/ir/routine/braket.py
@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,
    args=(),
    name=None,
    use_experimental=False,
    shuffle=False,
    **kwargs
)

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 src/bloqade/ir/routine/braket.py
@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,
    shots=1,
    name=None,
    multiprocessing=False,
    num_workers=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 src/bloqade/ir/routine/braket.py
@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,
    args=(),
    name=None,
    multiprocessing=False,
    num_workers=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

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 src/bloqade/ir/routine/braket.py
@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