qrunch.hybrid_jobs.hybrid_job_runner

Module containing logic for conveniently running jobs as Amazon Braket Hybris Job.

Classes

HybridJobRunner

Class for running a hybrid job on Amazon Braket.

class HybridJobRunner

Bases: object

Class for running a hybrid job on Amazon Braket.

To send a job to Amazon Braket Hybrid Jobs, call the .run_hybrid_job method with your function as input.

IMPORTANT: Your script MUST be placed in the root of your source module, otherwise not all parts of your module will be sent to the hybrid job, and import paths will break.

__init__(device: _IQM | _IonQ | _Rigetti | _Amazon | DeviceData, repository_name: str, result_folder: Path | None = None, docker_image: HybridJobDockerImage | None = None, region: str | None = None, cloudsmith_token: str | None = None) None

Initialize the HybridJobRunner.

Parameters:
  • device (_IQM | _IonQ | _Rigetti | _Amazon | DeviceData) – The device to run the hybrid job on. Must match the device given to the BraketBackend or must be a BraketBackendSimulators if using the LocalBraketBackend.

  • repository_name (str) – The name of the ECR repository where the Docker image is uploaded.

  • result_folder (Path | None) – The local folder to store the results in.

  • docker_image (HybridJobDockerImage | None) – A pre-built Docker image or None, in which case a standard image with standard requirements is built. Defaults to None.

  • region (str | None) – The region to run in. If None, gets the region from docker_image. Must be compatible with the device, see https://docs.aws.amazon.com/braket/latest/developerguide/braket-devices.html

  • cloudsmith_token (str | None) – The token used when downloading the QDK from the cloudsmith repository. Must be set if docker_image is None.

Return type:

None

run_hybrid_job(script_function: Callable[[], T]) T | None

Run the script method as an AWS Braket hybrid job.

Parameters:

script_function (Callable[[], T])

Return type:

T | None

static save_result(data: dict[str, Any] | None) None

Save the results so they can be downloaded to the result folder when the job is done.

Parameters:

data (dict[str, Any] | None)

Return type:

None