mqt.qudits.simulation.jobs

Submodules

Package Contents

class Job(backend: Backend | None, job_id: str = 'auto', **kwargs: dict[str, Any])[source]

Class to handle jobs.

This first version of the Backend abstract class is written to be mostly backwards compatible with the legacy providers interface. This was done to ease the transition for users and provider maintainers to the new versioned providers. Expect future versions of this abstract class to change the data model and interface.

version = 1
metadata
job_id() → str[source]

Return a unique id identifying the job.

backend() → Backend[source]

Return the backend where this job was executed.

done() → bool[source]

Return whether the job has successfully run.

running() → bool[source]

Return whether the job is actively running.

cancelled() → bool[source]

Return whether the job has been cancelled.

in_final_state() → bool[source]

Return whether the job is in a final job state such as DONE or ERROR.

wait_for_final_state(timeout: float | None = None, wait: float = 5, callback: Callable[[str, str, Job], None] | None = None) → None[source]

Poll the job status until it progresses to a final state such as DONE or ERROR.

Parameters:
  • timeout – Seconds to wait for the job. If None, wait indefinitely.

  • wait – Seconds between queries.

  • callback – Callback function invoked after each query.

Raises:

JobTimeoutError – If the job does not reach a final state before the specified timeout.

abstractmethod submit() → NoReturn[source]

Submit the job to the backend for execution.

result() → JobResult[source]

Return the results of the job.

set_result(result: JobResult) → None[source]
abstractmethod cancel() → NoReturn[source]

Attempt to cancel the job.

abstractmethod status() → str[source]

Return the status of the job, among the values of BackendStatus.

class JobResult(state_vector: numpy.typing.NDArray[numpy.complex128], counts: list[int])[source]
state_vector
counts
get_counts() → list[int][source]
get_state_vector() → numpy.typing.NDArray[numpy.complex128][source]
class JobStatus[source]

Bases: enum.StrEnum

Enumeration for job status.

INITIALIZING = 'initializing'
QUEUED = 'queued'
VALIDATING = 'validating'
RUNNING = 'running'
CANCELLED = 'cancelled'
DONE = 'done'
ERROR = 'error'
__str__() → str[source]

Return a human-readable description of the status.

property description: str

A detailed description of the job status.

classmethod from_string(status_str: str) → JobStatus[source]

Create a JobStatus from a string.

Parameters:

status_str (str) – The string representation of the status.

Returns:

The corresponding JobStatus enum.

Return type:

JobStatus

Raises:

ValueError – If the string doesn’t match any JobStatus.

property is_final: bool

Check if the status is a final state.

classmethod non_final_states() → list[JobStatus][source]

Return a list of all non-final states.