Skip to content

create_training_session

create_training_session(
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    training_session_name: Optional[TrainingSessionName] = None,
    model_package_group_arn: Optional[ModelPackageGroupArn] = None,
    lora_config: Optional[LoraConfig] = None,
    role_arn: Optional[RoleArn] = None,
    vpc_config: Optional[VpcConfig] = None,
    model_config: Optional[TrainingSessionModelConfig] = None,
    output_config: Optional[TrainingSessionOutputConfig] = None,
    tags: Optional[TagList] = None,
) -> CreateTrainingSessionResponse

Creates a training session in Amazon SageMaker. A training session provisions compute resources for fine-tuning a foundation model using Low-Rank Adaptation (LoRA). After the session is created, you can submit training operations and sample inference requests through the Amazon SageMaker Training Session Runtime API.

The following operations are related to CreateTrainingSession:

  • DescribeTrainingSession

  • ListTrainingSessions

  • StopTrainingSession

  • DeleteTrainingSession

Parameters:

  • training_session_name (Optional[TrainingSessionName], default: None ) –

    The name of the training session.

  • model_package_group_arn (Optional[ModelPackageGroupArn], default: None ) –

    The Amazon Resource Name (ARN) of the model package group where checkpoints and fine-tuned model artifacts are published.

  • lora_config (Optional[LoraConfig], default: None ) –

    The Low-Rank Adaptation (LoRA) configuration for the training session, including the rank and alpha parameters.

  • role_arn (Optional[RoleArn], default: None ) –

    The Amazon Resource Name (ARN) of the IAM role that Amazon SageMaker assumes to access resources on your behalf. The role must have permissions to access the output S3 path and model package group.

  • vpc_config (Optional[VpcConfig], default: None ) –

    The Virtual Private Cloud (VPC) configuration for the training session. Specify subnets and security groups to run the training session in your VPC.

  • model_config (Optional[TrainingSessionModelConfig], default: None ) –

    The configuration for the base model, including the model ARN and end-user license agreement (EULA) acceptance.

  • output_config (Optional[TrainingSessionOutputConfig], default: None ) –

    The output configuration for the training session, including the S3 location and optional encryption settings.

  • tags (Optional[TagList], default: None ) –

    An array of key-value pairs to apply to the training session as tags. For more information, see Tagging Amazon Web Services Resources.

Raises:

Source code in docs_src/capo_sagemaker/_services/sage_maker.py
def create_training_session(
    self,
    *,
    config_overrides: Optional[SageMakerClientConfig] = None,
    training_session_name: Optional[
        "capo_sagemaker.types.training_session_name.TrainingSessionName"
    ] = None,
    model_package_group_arn: Optional[
        "capo_sagemaker.types.model_package_group_arn.ModelPackageGroupArn"
    ] = None,
    lora_config: Optional["capo_sagemaker.types.lora_config.LoraConfig"] = None,
    role_arn: Optional["capo_sagemaker.types.role_arn.RoleArn"] = None,
    vpc_config: Optional["capo_sagemaker.types.vpc_config.VpcConfig"] = None,
    model_config: Optional[
        "capo_sagemaker.types.training_session_model_config.TrainingSessionModelConfig"
    ] = None,
    output_config: Optional[
        "capo_sagemaker.types.training_session_output_config.TrainingSessionOutputConfig"
    ] = None,
    tags: Optional["capo_sagemaker.types.tag_list.TagList"] = None,
) -> "capo_sagemaker.types.create_training_session_response.CreateTrainingSessionResponse":
    """<p>Creates a training session in Amazon SageMaker. A training session provisions compute resources for fine-tuning a foundation model using Low-Rank Adaptation (LoRA). After the session is created, you can submit training operations and sample inference requests through the Amazon SageMaker Training Session Runtime API.</p> <p>The following operations are related to <code>CreateTrainingSession</code>:</p> <ul> <li> <p> <code>DescribeTrainingSession</code> </p> </li> <li> <p> <code>ListTrainingSessions</code> </p> </li> <li> <p> <code>StopTrainingSession</code> </p> </li> <li> <p> <code>DeleteTrainingSession</code> </p> </li> </ul>

    Args:
        training_session_name: <p>The name of the training session.</p>
        model_package_group_arn: <p>The Amazon Resource Name (ARN) of the model package group where checkpoints and fine-tuned model artifacts are published.</p>
        lora_config: <p>The Low-Rank Adaptation (LoRA) configuration for the training session, including the rank and alpha parameters.</p>
        role_arn: <p>The Amazon Resource Name (ARN) of the IAM role that Amazon SageMaker assumes to access resources on your behalf. The role must have permissions to access the output S3 path and model package group.</p>
        vpc_config: <p>The Virtual Private Cloud (VPC) configuration for the training session. Specify subnets and security groups to run the training session in your VPC.</p>
        model_config: <p>The configuration for the base model, including the model ARN and end-user license agreement (EULA) acceptance.</p>
        output_config: <p>The output configuration for the training session, including the S3 location and optional encryption settings.</p>
        tags: <p>An array of key-value pairs to apply to the training session as tags. For more information, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html">Tagging Amazon Web Services Resources</a>.</p>

    Raises:
        capo_sagemaker.errors.resource_in_use.ResourceInUse: <p>Resource being accessed is in use.</p>
        capo_sagemaker.errors.resource_limit_exceeded.ResourceLimitExceeded: <p> You have exceeded an SageMaker resource limit. For example, you might have too many training jobs created. </p>
        capo_sagemaker.errors.resource_not_found.ResourceNotFound: <p>Resource being access is not found.</p>
        capo_sagemaker.errors.UnknownServiceError: The service returned an error code this client does not model.
    """

    def _handler(
        req: "OperationRequest[capo_sagemaker.types.create_training_session_request.CreateTrainingSessionRequest]",
    ) -> OperationResponse[
        "capo_sagemaker.types.create_training_session_response.CreateTrainingSessionResponse"
    ]:
        import capo_sagemaker._operations.sage_maker.create_training_session

        output, http_response = (
            capo_sagemaker._operations.sage_maker.create_training_session.create_training_session(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateTrainingSession")
    )
    input_: capo_sagemaker.types.create_training_session_request.CreateTrainingSessionRequest = {}
    if training_session_name is not None:
        input_["training_session_name"] = training_session_name
    if model_package_group_arn is not None:
        input_["model_package_group_arn"] = model_package_group_arn
    if lora_config is not None:
        input_["lora_config"] = lora_config
    if role_arn is not None:
        input_["role_arn"] = role_arn
    if vpc_config is not None:
        input_["vpc_config"] = vpc_config
    if model_config is not None:
        input_["model_config"] = model_config
    if output_config is not None:
        input_["output_config"] = output_config
    if tags is not None:
        input_["tags"] = tags

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output