class_docstr: The SageMaker Training Compiler configuration class.
class_docstr_tok: ["The","SageMaker","Training","Compiler","configuration","class","."]
docstr: Checks if SageMaker Training Compiler is configured correctly.
  
  Args:
      estimator (:class:`sagemaker.pytorch.PyTorch`): An estimator object.
          If SageMaker Training Compiler is enabled, it will validate whether
          the estimator is configured to be compatible with Training Compiler.
  
  Raises:
      ValueError: Raised if the requested configuration is not compatible
                  with SageMaker Training Compiler.
docstr_tok: ["Checks","if","SageMaker","Training","Compiler","is","configured","correctly",".","Args",":","estimator","(",":","class",":","`","sagemaker.pytorch.PyTorch","`",")",":","An","estimator","object",".","If","SageMaker","Training","Compiler","is","enabled",",","it","will","validate","whether","the","estimator","is","configured","to","be","compatible","with","Training","Compiler",".","Raises",":","ValueError",":","Raised","if","the","requested","configuration","is","not","compatible","with","SageMaker","Training","Compiler","."]
code: def validate(
      cls,
      estimator,
  ):
      """Checks if SageMaker Training Compiler is configured correctly.
  
      Args:
          estimator (:class:`sagemaker.pytorch.PyTorch`): An estimator object.
              If SageMaker Training Compiler is enabled, it will validate whether
              the estimator is configured to be compatible with Training Compiler.
  
      Raises:
          ValueError: Raised if the requested configuration is not compatible
                      with SageMaker Training Compiler.
      """
  
      super(TrainingCompilerConfig, cls).validate(estimator)
  
      if estimator.image_uri:
          error_helper_string = (
              "Overriding the image URI is currently not supported "
              "for SageMaker Training Compiler."
              "Specify the following parameters to run the PyTorch training job "
              "with SageMaker Training Compiler enabled: "
              "framework_version, and compiler_config."
          )
          raise ValueError(error_helper_string)
  
      if estimator.distribution:
          pt_xla_present = "pytorchxla" in estimator.distribution
          pt_xla_enabled = estimator.distribution.get(
              "pytorchxla", {}
          ).get("enabled", False)
          if pt_xla_enabled:
              if estimator.framework_version:
                  if Version(
                      estimator.framework_version
                  ) in SpecifierSet("< 1.12"):
                      error_helper_string = (
                          "Distribution mechanism 'pytorchxla' is currently only supported for "
                          "PyTorch >= 1.12 when SageMaker Training Compiler is enabled."
                          " Received framework_version={} which is unsupported."
                      )
                      raise ValueError(
                          error_helper_string.format(
                              estimator.framework_version
                          )
                      )
                  if (
                      estimator.instance_type
                      not in cls.SUPPORTED_INSTANCE_TYPES_WITH_EFA
                  ):
                      logger.warning(
                          "Consider using instances with EFA support when "
                          "training with PyTorch >= 1.12 and SageMaker Training Compiler "
                          "enabled. SageMaker Training Compiler leverages EFA to provide better "
                          "performance for distributed training."
                      )
          if not pt_xla_present:
              if estimator.framework_version:
                  if Version(
                      estimator.framework_version
                  ) in SpecifierSet(">= 1.12"):
                      error_helper_string = (
                          "'pytorchxla' is the only distribution mechanism currently supported "
                          "for PyTorch >= 1.12 when SageMaker Training Compiler is enabled."
                          " Received distribution={} which is unsupported."
                      )
                      raise ValueError(
                          error_helper_string.format(
                              estimator.distribution
                          )
                      )
      elif estimator.instance_count and estimator.instance_count > 1:
          if estimator.framework_version:
              if Version(estimator.framework_version) in SpecifierSet(
                  ">= 1.12"
              ):
                  logger.warning(
                      "Consider setting 'distribution' to 'pytorchxla' for distributed "
                      "training with PyTorch >= 1.12 and SageMaker Training Compiler enabled."
                  )
  
file_path: sagemaker-python-sdk/src/sagemaker/pytorch/training_compiler/config.py
imports: from __future__ import absolute_import
  import logging
  from typing import Union
  from packaging.specifiers import SpecifierSet
  from packaging.version import Version
  from sagemaker.training_compiler.config import TrainingCompilerConfig
  from sagemaker.workflow.entities import PipelineVariable
label_desc: Use image node_id 2 for calling the TrainingCompilerConfig obj's underlying member method code with example usage: obj.validate(cls, estimator) without return types