optimization_jobs
Creates, updates, deletes, gets or lists an optimization_jobs resource.
Overview
| Name | optimization_jobs |
| Type | Resource |
| Id | aws.sagemaker.optimization_jobs |
Fields
The following fields are returned by SELECT queries:
- describe_optimization_job
- list_optimization_jobs
| Name | Datatype | Description |
|---|---|---|
creation_time | string (date-time) | The time when you created the optimization job. |
deployment_instance_type | string | The type of instance that hosts the optimized model that you create with the optimization job. (ml.p4d.24xlarge, ml.p4de.24xlarge, ml.p5.48xlarge, ml.p5e.48xlarge, ml.p5en.48xlarge, ml.g4dn.xlarge, ml.g4dn.2xlarge, ml.g4dn.4xlarge, ml.g4dn.8xlarge, ml.g4dn.12xlarge, ml.g4dn.16xlarge, ml.g5.xlarge, ml.g5.2xlarge, ml.g5.4xlarge, ml.g5.8xlarge, ml.g5.12xlarge, ml.g5.16xlarge, ml.g5.24xlarge, ml.g5.48xlarge, ml.g6.xlarge, ml.g6.2xlarge, ml.g6.4xlarge, ml.g6.8xlarge, ml.g6.12xlarge, ml.g6.16xlarge, ml.g6.24xlarge, ml.g6.48xlarge, ml.g6e.xlarge, ml.g6e.2xlarge, ml.g6e.4xlarge, ml.g6e.8xlarge, ml.g6e.12xlarge, ml.g6e.16xlarge, ml.g6e.24xlarge, ml.g6e.48xlarge, ml.inf2.xlarge, ml.inf2.8xlarge, ml.inf2.24xlarge, ml.inf2.48xlarge, ml.trn1.2xlarge, ml.trn1.32xlarge, ml.trn1n.32xlarge, ml.p6-b200.48xlarge, ml.g7e.2xlarge, ml.g7e.4xlarge, ml.g7e.8xlarge, ml.g7e.12xlarge, ml.g7e.24xlarge, ml.g7e.48xlarge) |
failure_reason | string | If the optimization job status is FAILED, the reason for the failure. |
last_modified_time | string (date-time) | The time when the optimization job was last updated. |
max_instance_count | integer | The maximum number of instances to use for the optimization job. |
model_source | object | The location of the source model to optimize with an optimization job. |
optimization_configs | array | Settings for each of the optimization techniques that the job applies. |
optimization_end_time | string (date-time) | The time when the optimization job finished processing. |
optimization_environment | object | The environment variables to set in the model container. |
optimization_job_arn | string | The Amazon Resource Name (ARN) of the optimization job. (pattern: <code>arn:aws[a-z-]:sagemaker:[a-z0-9-]:[0-9]{12}:optimization-job/.*</code>) |
optimization_job_name | string | The name that you assigned to the optimization job. (pattern: <code>[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}</code>) |
optimization_job_status | string | The current status of the optimization job. (INPROGRESS, COMPLETED, FAILED, STARTING, STOPPING, STOPPED) |
optimization_output | object | Output values produced by an optimization job. |
optimization_start_time | string (date-time) | The time when the optimization job started. |
output_config | object | Details for where to store the optimized model that you create with the optimization job. |
role_arn | string | The ARN of the IAM role that you assigned to the optimization job. (pattern: <code>arn:aws[a-z-]*:iam::\d{12}:role/?[a-zA-Z_0-9+=,.@-_/]+</code>) |
stopping_condition | object | Specifies a limit to how long a job can run. When the job reaches the time limit, SageMaker ends the job. Use this API to cap costs. To stop a training job, SageMaker sends the algorithm the SIGTERM signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. The training algorithms provided by SageMaker automatically save the intermediate results of a model training job when possible. This attempt to save artifacts is only a best effort case as model might not be in a state from which it can be saved. For example, if training has just started, the model might not be ready to save. When saved, this intermediate data is a valid model artifact. You can use it to create a model with CreateModel. The Neural Topic Model (NTM) currently does not support saving intermediate model artifacts. When training NTMs, make sure that the maximum runtime is sufficient for the training job to complete. |
training_plan_arns | array | The Amazon Resource Name (ARN) of the training plan associated with this optimization job. This field appears only when you specified a training plan when you created the job. Optimization jobs that use on-demand capacity don't return this field. |
vpc_config | object | A VPC in Amazon VPC that your optimized model has access to. |
| Name | Datatype | Description |
|---|---|---|
creation_time | string (date-time) | The time when you created the optimization job. |
deployment_instance_type | string | The type of instance that hosts the optimized model that you create with the optimization job. (ml.p4d.24xlarge, ml.p4de.24xlarge, ml.p5.48xlarge, ml.p5e.48xlarge, ml.p5en.48xlarge, ml.g4dn.xlarge, ml.g4dn.2xlarge, ml.g4dn.4xlarge, ml.g4dn.8xlarge, ml.g4dn.12xlarge, ml.g4dn.16xlarge, ml.g5.xlarge, ml.g5.2xlarge, ml.g5.4xlarge, ml.g5.8xlarge, ml.g5.12xlarge, ml.g5.16xlarge, ml.g5.24xlarge, ml.g5.48xlarge, ml.g6.xlarge, ml.g6.2xlarge, ml.g6.4xlarge, ml.g6.8xlarge, ml.g6.12xlarge, ml.g6.16xlarge, ml.g6.24xlarge, ml.g6.48xlarge, ml.g6e.xlarge, ml.g6e.2xlarge, ml.g6e.4xlarge, ml.g6e.8xlarge, ml.g6e.12xlarge, ml.g6e.16xlarge, ml.g6e.24xlarge, ml.g6e.48xlarge, ml.inf2.xlarge, ml.inf2.8xlarge, ml.inf2.24xlarge, ml.inf2.48xlarge, ml.trn1.2xlarge, ml.trn1.32xlarge, ml.trn1n.32xlarge, ml.p6-b200.48xlarge, ml.g7e.2xlarge, ml.g7e.4xlarge, ml.g7e.8xlarge, ml.g7e.12xlarge, ml.g7e.24xlarge, ml.g7e.48xlarge) |
last_modified_time | string (date-time) | The time when the optimization job was last updated. |
max_instance_count | integer | The maximum number of instances to use for the optimization job. |
optimization_end_time | string (date-time) | The time when the optimization job finished processing. |
optimization_job_arn | string | The Amazon Resource Name (ARN) of the optimization job. (pattern: <code>arn:aws[a-z-]:sagemaker:[a-z0-9-]:[0-9]{12}:optimization-job/.*</code>) |
optimization_job_name | string | The name that you assigned to the optimization job. (pattern: <code>[a-zA-Z0-9](-*[a-zA-Z0-9]){0,62}</code>) |
optimization_job_status | string | The current status of the optimization job. (INPROGRESS, COMPLETED, FAILED, STARTING, STOPPING, STOPPED) |
optimization_start_time | string (date-time) | The time when the optimization job started. |
optimization_types | array | The optimization techniques that are applied by the optimization job. |
Methods
The following methods are available for this resource:
| Name | Accessible by | Required Params | Optional Params | Description |
|---|---|---|---|---|
describe_optimization_job | select | region | Provides the properties of the specified optimization job. | |
list_optimization_jobs | select | region | Lists the optimization jobs in your account and their properties. | |
create_optimization_job | insert | region, OptimizationJobName, RoleArn, ModelSource, DeploymentInstanceType, OptimizationConfigs, OutputConfig, StoppingCondition | Creates a job that optimizes a model for inference performance. To create the job, you provide the location of a source model, and you provide the settings for the optimization techniques that you want the job to apply. When the job completes successfully, SageMaker uploads the new optimized model to the output destination that you specify. For more information about how to use this action, and about the supported optimization techniques, see Optimize model inference with Amazon SageMaker. | |
delete_optimization_job | delete | region | Deletes an optimization job. | |
stop_optimization_job | exec | region, OptimizationJobName | Ends a running inference optimization job. |
Parameters
Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.
| Name | Datatype | Description |
|---|---|---|
region | string | AWS region (default: us-east-1) |
SELECT examples
- describe_optimization_job
- list_optimization_jobs
Provides the properties of the specified optimization job.
SELECT
creation_time,
deployment_instance_type,
failure_reason,
last_modified_time,
max_instance_count,
model_source,
optimization_configs,
optimization_end_time,
optimization_environment,
optimization_job_arn,
optimization_job_name,
optimization_job_status,
optimization_output,
optimization_start_time,
output_config,
role_arn,
stopping_condition,
training_plan_arns,
vpc_config
FROM aws.sagemaker.optimization_jobs
WHERE region = '{{ region }}' -- required
;
Lists the optimization jobs in your account and their properties.
SELECT
creation_time,
deployment_instance_type,
last_modified_time,
max_instance_count,
optimization_end_time,
optimization_job_arn,
optimization_job_name,
optimization_job_status,
optimization_start_time,
optimization_types
FROM aws.sagemaker.optimization_jobs
WHERE region = '{{ region }}' -- required
;
INSERT examples
- create_optimization_job
- Manifest
Creates a job that optimizes a model for inference performance. To create the job, you provide the location of a source model, and you provide the settings for the optimization techniques that you want the job to apply. When the job completes successfully, SageMaker uploads the new optimized model to the output destination that you specify. For more information about how to use this action, and about the supported optimization techniques, see Optimize model inference with Amazon SageMaker.
INSERT INTO aws.sagemaker.optimization_jobs (
OptimizationJobName,
RoleArn,
ModelSource,
DeploymentInstanceType,
MaxInstanceCount,
OptimizationEnvironment,
OptimizationConfigs,
OutputConfig,
StoppingCondition,
Tags,
VpcConfig,
TrainingPlanArns,
region
)
SELECT
'{{ OptimizationJobName }}' /* required */,
'{{ RoleArn }}' /* required */,
'{{ ModelSource }}' /* required */,
'{{ DeploymentInstanceType }}' /* required */,
{{ MaxInstanceCount }},
'{{ OptimizationEnvironment }}',
'{{ OptimizationConfigs }}' /* required */,
'{{ OutputConfig }}' /* required */,
'{{ StoppingCondition }}' /* required */,
'{{ Tags }}',
'{{ VpcConfig }}',
'{{ TrainingPlanArns }}',
'{{ region }}'
RETURNING
optimization_job_arn
;
# Description fields are for documentation purposes
- name: optimization_jobs
props:
- name: region
value: "{{ region }}"
description: Required parameter for the optimization_jobs resource.
- name: OptimizationJobName
value: "{{ OptimizationJobName }}"
description: |
A custom name for the new optimization job.
- name: RoleArn
value: "{{ RoleArn }}"
description: |
The Amazon Resource Name (ARN) of an IAM role that enables Amazon SageMaker AI to perform tasks on your behalf. During model optimization, Amazon SageMaker AI needs your permission to: Read input data from an S3 bucket Write model artifacts to an S3 bucket Write logs to Amazon CloudWatch Logs Publish metrics to Amazon CloudWatch You grant permissions for all of these tasks to an IAM role. To pass this role to Amazon SageMaker AI, the caller of this API must have the iam:PassRole permission. For more information, see Amazon SageMaker AI Roles.
- name: ModelSource
description: |
The location of the source model to optimize with an optimization job.
value:
S3:
S3Uri: "{{ S3Uri }}"
ModelAccessConfig:
AcceptEula: {{ AcceptEula }}
SageMakerModel:
ModelName: "{{ ModelName }}"
- name: DeploymentInstanceType
value: "{{ DeploymentInstanceType }}"
description: |
The type of instance that hosts the optimized model that you create with the optimization job.
valid_values: ['ml.p4d.24xlarge', 'ml.p4de.24xlarge', 'ml.p5.48xlarge', 'ml.p5e.48xlarge', 'ml.p5en.48xlarge', 'ml.g4dn.xlarge', 'ml.g4dn.2xlarge', 'ml.g4dn.4xlarge', 'ml.g4dn.8xlarge', 'ml.g4dn.12xlarge', 'ml.g4dn.16xlarge', 'ml.g5.xlarge', 'ml.g5.2xlarge', 'ml.g5.4xlarge', 'ml.g5.8xlarge', 'ml.g5.12xlarge', 'ml.g5.16xlarge', 'ml.g5.24xlarge', 'ml.g5.48xlarge', 'ml.g6.xlarge', 'ml.g6.2xlarge', 'ml.g6.4xlarge', 'ml.g6.8xlarge', 'ml.g6.12xlarge', 'ml.g6.16xlarge', 'ml.g6.24xlarge', 'ml.g6.48xlarge', 'ml.g6e.xlarge', 'ml.g6e.2xlarge', 'ml.g6e.4xlarge', 'ml.g6e.8xlarge', 'ml.g6e.12xlarge', 'ml.g6e.16xlarge', 'ml.g6e.24xlarge', 'ml.g6e.48xlarge', 'ml.inf2.xlarge', 'ml.inf2.8xlarge', 'ml.inf2.24xlarge', 'ml.inf2.48xlarge', 'ml.trn1.2xlarge', 'ml.trn1.32xlarge', 'ml.trn1n.32xlarge', 'ml.p6-b200.48xlarge', 'ml.g7e.2xlarge', 'ml.g7e.4xlarge', 'ml.g7e.8xlarge', 'ml.g7e.12xlarge', 'ml.g7e.24xlarge', 'ml.g7e.48xlarge']
- name: MaxInstanceCount
value: {{ MaxInstanceCount }}
description: |
The maximum number of instances to use for the optimization job.
- name: OptimizationEnvironment
value: "{{ OptimizationEnvironment }}"
description: |
The environment variables to set in the model container.
- name: OptimizationConfigs
description: |
Settings for each of the optimization techniques that the job applies.
value:
- ModelQuantizationConfig:
Image: "{{ Image }}"
OverrideEnvironment: "{{ OverrideEnvironment }}"
ModelCompilationConfig:
Image: "{{ Image }}"
OverrideEnvironment: "{{ OverrideEnvironment }}"
ModelShardingConfig:
Image: "{{ Image }}"
OverrideEnvironment: "{{ OverrideEnvironment }}"
ModelSpeculativeDecodingConfig:
Technique: "{{ Technique }}"
TrainingDataSource:
S3Uri: "{{ S3Uri }}"
S3DataType: "{{ S3DataType }}"
- name: OutputConfig
description: |
Details for where to store the optimized model that you create with the optimization job.
value:
KmsKeyId: "{{ KmsKeyId }}"
S3OutputLocation: "{{ S3OutputLocation }}"
SageMakerModel:
ModelName: "{{ ModelName }}"
- name: StoppingCondition
description: |
Specifies a limit to how long a job can run. When the job reaches the time limit, SageMaker ends the job. Use this API to cap costs. To stop a training job, SageMaker sends the algorithm the SIGTERM signal, which delays job termination for 120 seconds. Algorithms can use this 120-second window to save the model artifacts, so the results of training are not lost. The training algorithms provided by SageMaker automatically save the intermediate results of a model training job when possible. This attempt to save artifacts is only a best effort case as model might not be in a state from which it can be saved. For example, if training has just started, the model might not be ready to save. When saved, this intermediate data is a valid model artifact. You can use it to create a model with CreateModel. The Neural Topic Model (NTM) currently does not support saving intermediate model artifacts. When training NTMs, make sure that the maximum runtime is sufficient for the training job to complete.
value:
MaxRuntimeInSeconds: {{ MaxRuntimeInSeconds }}
MaxWaitTimeInSeconds: {{ MaxWaitTimeInSeconds }}
MaxPendingTimeInSeconds: {{ MaxPendingTimeInSeconds }}
- name: Tags
description: |
A list of key-value pairs associated with the optimization job. For more information, see Tagging Amazon Web Services resources in the Amazon Web Services General Reference Guide.
value:
- Key: "{{ Key }}"
Value: "{{ Value }}"
- name: VpcConfig
description: |
A VPC in Amazon VPC that your optimized model has access to.
value:
SecurityGroupIds:
- "{{ SecurityGroupIds }}"
Subnets:
- "{{ Subnets }}"
- name: TrainingPlanArns
value:
- "{{ TrainingPlanArns }}"
description: |
The Amazon Resource Name (ARN) of the training plan to use for this optimization job. When you use reserved capacity from a training plan, the optimization job runs on that reserved capacity instead of on-demand capacity. If you omit this field, the job uses on-demand capacity. You can specify at most one training plan. For more information about how to reserve GPU capacity for your optimization jobs using Amazon SageMaker Training Plans, see Reserve capacity with training plans.
DELETE examples
- delete_optimization_job
Deletes an optimization job.
DELETE FROM aws.sagemaker.optimization_jobs
WHERE region = '{{ region }}' --required
;
Lifecycle Methods
- stop_optimization_job
Ends a running inference optimization job.
EXEC aws.sagemaker.optimization_jobs.stop_optimization_job
@region='{{ region }}' --required
@@json=
'{
"OptimizationJobName": "{{ OptimizationJobName }}"
}'
;