Skip to content

AbstractRemoteTask dataclass

AbstractRemoteTask(
    kernel: Method[Params, RetType],
    args: tuple[Any, ...],
    kwargs: dict[str, Any],
)

Bases: AbstractTask[Params, RetType]

Base class for tasks generated by the devices.

run_async abstractmethod

run_async(*, shots: int = 1) -> BatchFuture[RetType]

Executes the kernel asynchronously and returns a Future object.

Source code in .venv/lib/python3.12/site-packages/bloqade/task.py
73
74
75
@abc.abstractmethod
def run_async(self, *, shots: int = 1) -> BatchFuture[RetType]:
    """Executes the kernel asynchronously and returns a Future object."""

AbstractSimulatorTask dataclass

AbstractSimulatorTask(
    kernel: Method[Params, RetType],
    args: tuple[Any, ...],
    kwargs: dict[str, Any],
)

Bases: AbstractTask[Params, RetType], Generic[Params, RetType, StateType]

Base class for tasks generated by local simulators.

state abstractmethod property

state: StateType

Returns the state of the simulator after running the task.

run abstractmethod

run() -> RetType

Executes the kernel and returns the result.

Source code in .venv/lib/python3.12/site-packages/bloqade/task.py
87
88
89
@abc.abstractmethod
def run(self) -> RetType:
    """Executes the kernel and returns the result."""

BatchFuture

Bases: ABC, Generic[RetType]

Protocol for future objects that can be awaited.

cancel

cancel()

Attempts to cancel the execution of the future.

Source code in .venv/lib/python3.12/site-packages/bloqade/task.py
28
29
30
31
32
def cancel(self):
    """Attempts to cancel the execution of the future."""
    raise NotImplementedError(
        f"cancel method not implemented for {self.__class__.__name__}"
    )

cancelled

cancelled() -> bool

Returns True if the future was cancelled, False otherwise.

Source code in .venv/lib/python3.12/site-packages/bloqade/task.py
34
35
36
37
38
def cancelled(self) -> bool:
    """Returns True if the future was cancelled, False otherwise."""
    raise NotImplementedError(
        f"cancelled method not implemented for {self.__class__.__name__}"
    )

fetch abstractmethod

fetch() -> None

Fetches the result of the future that are currently available.

Source code in .venv/lib/python3.12/site-packages/bloqade/task.py
24
25
26
@abc.abstractmethod
def fetch(self) -> None:
    """Fetches the result of the future that are currently available."""

partial_result abstractmethod

partial_result() -> list[RetType | MISSING_RESULT]

Return all results that are available so far, or MISSING_RESULT for those that are not yet available.

Source code in .venv/lib/python3.12/site-packages/bloqade/task.py
20
21
22
@abc.abstractmethod
def partial_result(self) -> list[RetType | MISSING_RESULT]:
    """Return all results that are available so far, or MISSING_RESULT for those that are not yet available."""

result abstractmethod

result(timeout: float | None) -> list[RetType]

Returns the result of the future, blocking until it is available or the timeout expires.

Source code in .venv/lib/python3.12/site-packages/bloqade/task.py
16
17
18
@abc.abstractmethod
def result(self, timeout: float | None) -> list[RetType]:
    """Returns the result of the future, blocking until it is available or the timeout expires."""

DeviceTaskExpectMixin dataclass

DeviceTaskExpectMixin(
    kernel: Method[Params, RetType],
    args: tuple[Any, ...],
    kwargs: dict[str, Any],
)

Bases: AbstractTask

expect abstractmethod

expect(
    observable: Method[[RetType], ObsType], shots: int
) -> ObsType

Returns the expectation value of the given observable after running the task.

Source code in .venv/lib/python3.12/site-packages/bloqade/task.py
61
62
63
@abc.abstractmethod
def expect(self, observable: ir.Method[[RetType], ObsType], shots: int) -> ObsType:
    """Returns the expectation value of the given observable after running the task."""