syne_tune.remote.remote_launcher module

class syne_tune.remote.remote_launcher.RemoteLauncher(tuner, role=None, instance_type='ml.c5.4xlarge', dependencies=None, store_logs_localbackend=False, log_level=None, s3_path=None, no_tuner_logging=False, publish_tuning_metrics=True, **estimator_kwargs)[source]

Bases: object

This class allows to launch a tuning job remotely. The remote tuning job may use either the local backend (in which case the remote instance will be used to evaluate trials) or the Sagemaker backend in which case the remote instance will spawn one Sagemaker job per trial.

Parameters:
  • tuner (Tuner) – Tuner that should be run remotely on a instance_type instance. Note that StoppingCriterion should be used for the Tuner rather than a lambda function to ensure serialization.

  • role (Optional[str]) – SageMaker role to be used to launch the remote tuning instance.

  • instance_type (str) – Instance where the tuning is going to happen. Defaults to “ml.c5.4xlarge”

  • dependencies (Optional[List[str]]) – List of folders that should be included as dependencies for the backend script to run

  • estimator_kwargs – Extra arguments for creating the SageMaker estimator for the tuning code.

  • store_logs_localbackend (bool) – Whether to sync logs and checkpoints to S3 when using the local backend. When using SageMaker backend, logs are persisted by SageMaker. Using True can lead to failure with large checkpoints. Defauls to False

  • log_level (Optional[int]) – Logging level. Default is logging.INFO, while logging.DEBUG gives more messages

  • s3_path (Optional[str]) – S3 base path used for checkpointing, outputs of tuning will be stored under {s3_path}/{tuner_name}. The logs of the local backend are only stored if store_logs_localbackend is True. Defaults to s3_experiment_path()

  • no_tuner_logging (bool) – If True, the logging level for syne_tune.tuner is set to logging.ERROR. Defaults to False

  • publish_tuning_metrics (bool) – If True, a number of tuning metrics (see RemoteTuningMetricsCallback) are reported and displayed in the SageMaker training job console. This is modifying tuner, in the sense that a callback is appended to tuner.callbacks. Defaults to True.

is_lambda(f)[source]
Parameters:

f – Object to test

Returns:

True iff f is a lambda function

run(wait=True)[source]
Parameters:

wait (bool) – Whether the call should wait until the job completes (default: True). If False the call returns once the tuning job is scheduled on SageMaker.

prepare_upload()[source]

Prepares the files that needs to be uploaded by SageMaker so that the tuning job can happen. This includes, 1) the entrypoint script of the backend and 2) the tuner that needs to run remotely.

get_source_dir()[source]
Return type:

Path

is_source_dir_specified()[source]
Return type:

bool

update_backend_with_remote_paths()[source]

Update the paths of the backend of the endpoint script and source dir with their remote location.

upload_dir()[source]
Return type:

Path

remote_script_dir()[source]
Return type:

Path

launch_tuning_job_on_sagemaker(wait)[source]
clean_requirements_file()[source]
syne_tune.remote.remote_launcher.syne_tune_image_uri()[source]
Return type:

str

Returns:

syne tune docker uri, if not present try to build it and returns an error if this failed.