sagemaker-core 1.0.62__py3-none-any.whl → 2.3.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. sagemaker/__init__.py +2 -0
  2. sagemaker/core/__init__.py +16 -0
  3. sagemaker/core/_studio.py +116 -0
  4. sagemaker/core/_version.py +11 -0
  5. sagemaker/core/accept_types.py +131 -0
  6. sagemaker/core/analytics.py +744 -0
  7. sagemaker/core/apiutils/__init__.py +13 -0
  8. sagemaker/core/apiutils/_base_types.py +228 -0
  9. sagemaker/core/apiutils/_boto_functions.py +130 -0
  10. sagemaker/core/apiutils/_utils.py +34 -0
  11. sagemaker/core/base_deserializers.py +35 -0
  12. sagemaker/core/base_serializers.py +35 -0
  13. sagemaker/core/clarify/__init__.py +2898 -0
  14. sagemaker/core/collection.py +467 -0
  15. sagemaker/core/common_utils.py +2399 -0
  16. sagemaker/core/compute_resource_requirements/__init__.py +18 -0
  17. sagemaker/core/compute_resource_requirements/resource_requirements.py +94 -0
  18. sagemaker/core/config/__init__.py +181 -0
  19. sagemaker/core/config/config.py +238 -0
  20. sagemaker/core/config/config_manager.py +595 -0
  21. sagemaker/core/config/config_schema.py +1220 -0
  22. sagemaker/core/config/config_utils.py +297 -0
  23. {sagemaker_core/main → sagemaker/core}/config_schema.py +408 -3
  24. sagemaker/core/constants.py +73 -0
  25. sagemaker/core/content_types.py +137 -0
  26. sagemaker/core/debugger/__init__.py +39 -0
  27. sagemaker/core/debugger/debugger.py +945 -0
  28. sagemaker/core/debugger/framework_profile.py +292 -0
  29. sagemaker/core/debugger/metrics_config.py +468 -0
  30. sagemaker/core/debugger/profiler.py +42 -0
  31. sagemaker/core/debugger/profiler_config.py +190 -0
  32. sagemaker/core/debugger/profiler_constants.py +40 -0
  33. sagemaker/core/debugger/utils.py +148 -0
  34. sagemaker/core/deprecations.py +254 -0
  35. sagemaker/core/deserializers/__init__.py +10 -0
  36. sagemaker/core/deserializers/base.py +424 -0
  37. sagemaker/core/deserializers/implementations.py +157 -0
  38. sagemaker/core/drift_check_baselines.py +106 -0
  39. sagemaker/core/enums.py +51 -0
  40. sagemaker/core/environment_variables.py +101 -0
  41. sagemaker/core/exceptions.py +108 -0
  42. sagemaker/core/experiments/__init__.py +53 -0
  43. sagemaker/core/experiments/_api_types.py +251 -0
  44. sagemaker/core/experiments/_environment.py +124 -0
  45. sagemaker/core/experiments/_helper.py +294 -0
  46. sagemaker/core/experiments/_metrics.py +333 -0
  47. sagemaker/core/experiments/_run_context.py +58 -0
  48. sagemaker/core/experiments/_utils.py +216 -0
  49. sagemaker/core/experiments/experiment.py +247 -0
  50. sagemaker/core/experiments/run.py +970 -0
  51. sagemaker/core/experiments/trial.py +296 -0
  52. sagemaker/core/experiments/trial_component.py +387 -0
  53. sagemaker/core/explainer/__init__.py +24 -0
  54. sagemaker/core/explainer/clarify_explainer_config.py +298 -0
  55. sagemaker/core/explainer/explainer_config.py +44 -0
  56. sagemaker/core/fw_utils.py +1220 -0
  57. sagemaker/core/git_utils.py +415 -0
  58. sagemaker/core/helper/pipeline_variable.py +82 -0
  59. sagemaker/core/helper/session_helper.py +2977 -0
  60. sagemaker/core/hyperparameters.py +172 -0
  61. sagemaker/core/image_retriever/__init__.py +3 -0
  62. sagemaker/core/image_retriever/image_retriever.py +640 -0
  63. sagemaker/core/image_retriever/image_retriever_utils.py +509 -0
  64. sagemaker/core/image_retriever/test.py +7 -0
  65. sagemaker/core/image_uri_config/autogluon.json +1335 -0
  66. sagemaker/core/image_uri_config/blazingtext.json +50 -0
  67. sagemaker/core/image_uri_config/chainer.json +104 -0
  68. sagemaker/core/image_uri_config/clarify.json +39 -0
  69. sagemaker/core/image_uri_config/coach-mxnet.json +70 -0
  70. sagemaker/core/image_uri_config/coach-tensorflow.json +186 -0
  71. sagemaker/core/image_uri_config/data-wrangler.json +91 -0
  72. sagemaker/core/image_uri_config/debugger.json +34 -0
  73. sagemaker/core/image_uri_config/detailed-profiler.json +18 -0
  74. sagemaker/core/image_uri_config/djl-deepspeed.json +385 -0
  75. sagemaker/core/image_uri_config/djl-fastertransformer.json +167 -0
  76. sagemaker/core/image_uri_config/djl-lmi.json +136 -0
  77. sagemaker/core/image_uri_config/djl-neuronx.json +258 -0
  78. sagemaker/core/image_uri_config/djl-tensorrtllm.json +262 -0
  79. sagemaker/core/image_uri_config/factorization-machines.json +50 -0
  80. sagemaker/core/image_uri_config/forecasting-deepar.json +50 -0
  81. sagemaker/core/image_uri_config/huggingface-llm-neuronx.json +770 -0
  82. sagemaker/core/image_uri_config/huggingface-llm.json +1267 -0
  83. sagemaker/core/image_uri_config/huggingface-neuron.json +52 -0
  84. sagemaker/core/image_uri_config/huggingface-neuronx.json +686 -0
  85. sagemaker/core/image_uri_config/huggingface-tei-cpu.json +298 -0
  86. sagemaker/core/image_uri_config/huggingface-tei.json +298 -0
  87. sagemaker/core/image_uri_config/huggingface-training-compiler.json +195 -0
  88. sagemaker/core/image_uri_config/huggingface-vllm-neuronx.json +38 -0
  89. sagemaker/core/image_uri_config/huggingface.json +2287 -0
  90. sagemaker/core/image_uri_config/hyperpod-recipes-neuron.json +52 -0
  91. sagemaker/core/image_uri_config/image-classification-neo.json +43 -0
  92. sagemaker/core/image_uri_config/image-classification.json +50 -0
  93. sagemaker/core/image_uri_config/inferentia-mxnet.json +88 -0
  94. sagemaker/core/image_uri_config/inferentia-pytorch.json +127 -0
  95. sagemaker/core/image_uri_config/inferentia-tensorflow.json +88 -0
  96. sagemaker/core/image_uri_config/instance_gpu_info.json +782 -0
  97. sagemaker/core/image_uri_config/ipinsights.json +50 -0
  98. sagemaker/core/image_uri_config/kmeans.json +50 -0
  99. sagemaker/core/image_uri_config/knn.json +50 -0
  100. sagemaker/core/image_uri_config/lda.json +26 -0
  101. sagemaker/core/image_uri_config/linear-learner.json +50 -0
  102. sagemaker/core/image_uri_config/model-monitor.json +42 -0
  103. sagemaker/core/image_uri_config/mxnet.json +1154 -0
  104. sagemaker/core/image_uri_config/neo-mxnet.json +64 -0
  105. sagemaker/core/image_uri_config/neo-pytorch.json +341 -0
  106. sagemaker/core/image_uri_config/neo-tensorflow.json +109 -0
  107. sagemaker/core/image_uri_config/ntm.json +50 -0
  108. sagemaker/core/image_uri_config/object-detection.json +50 -0
  109. sagemaker/core/image_uri_config/object2vec.json +50 -0
  110. sagemaker/core/image_uri_config/pca.json +50 -0
  111. sagemaker/core/image_uri_config/pytorch-neuron.json +43 -0
  112. sagemaker/core/image_uri_config/pytorch-smp.json +218 -0
  113. sagemaker/core/image_uri_config/pytorch-training-compiler.json +80 -0
  114. sagemaker/core/image_uri_config/pytorch.json +3101 -0
  115. sagemaker/core/image_uri_config/randomcutforest.json +50 -0
  116. sagemaker/core/image_uri_config/ray-pytorch.json +46 -0
  117. sagemaker/core/image_uri_config/ray-tensorflow.json +194 -0
  118. sagemaker/core/image_uri_config/sagemaker-base-python.json +46 -0
  119. sagemaker/core/image_uri_config/sagemaker-distribution.json +37 -0
  120. sagemaker/core/image_uri_config/sagemaker-geospatial.json +13 -0
  121. sagemaker/core/image_uri_config/sagemaker-tritonserver.json +252 -0
  122. sagemaker/core/image_uri_config/semantic-segmentation.json +50 -0
  123. sagemaker/core/image_uri_config/seq2seq.json +50 -0
  124. sagemaker/core/image_uri_config/sklearn.json +494 -0
  125. sagemaker/core/image_uri_config/spark.json +280 -0
  126. sagemaker/core/image_uri_config/sparkml-serving.json +97 -0
  127. sagemaker/core/image_uri_config/stabilityai.json +53 -0
  128. sagemaker/core/image_uri_config/tensorflow.json +5086 -0
  129. sagemaker/core/image_uri_config/vw.json +25 -0
  130. sagemaker/core/image_uri_config/xgboost-neo.json +43 -0
  131. sagemaker/core/image_uri_config/xgboost.json +972 -0
  132. sagemaker/core/image_uris.py +816 -0
  133. sagemaker/core/inference_config.py +144 -0
  134. sagemaker/core/inference_recommender/__init__.py +18 -0
  135. sagemaker/core/inference_recommender/inference_recommender_mixin.py +622 -0
  136. sagemaker/core/inputs.py +366 -0
  137. sagemaker/core/instance_group.py +61 -0
  138. sagemaker/core/instance_types.py +164 -0
  139. sagemaker/core/instance_types_gpu_info.py +43 -0
  140. sagemaker/core/interactive_apps/__init__.py +41 -0
  141. sagemaker/core/interactive_apps/base_interactive_app.py +204 -0
  142. sagemaker/core/interactive_apps/detail_profiler_app.py +139 -0
  143. sagemaker/core/interactive_apps/tensorboard.py +149 -0
  144. sagemaker/core/iterators.py +197 -0
  145. sagemaker/core/job.py +380 -0
  146. sagemaker/core/jumpstart/__init__.py +156 -0
  147. sagemaker/core/jumpstart/accessors.py +390 -0
  148. sagemaker/core/jumpstart/artifacts/__init__.py +69 -0
  149. sagemaker/core/jumpstart/artifacts/environment_variables.py +252 -0
  150. sagemaker/core/jumpstart/artifacts/hyperparameters.py +120 -0
  151. sagemaker/core/jumpstart/artifacts/image_uris.py +139 -0
  152. sagemaker/core/jumpstart/artifacts/incremental_training.py +87 -0
  153. sagemaker/core/jumpstart/artifacts/instance_types.py +223 -0
  154. sagemaker/core/jumpstart/artifacts/kwargs.py +289 -0
  155. sagemaker/core/jumpstart/artifacts/metric_definitions.py +117 -0
  156. sagemaker/core/jumpstart/artifacts/model_packages.py +202 -0
  157. sagemaker/core/jumpstart/artifacts/model_uris.py +252 -0
  158. sagemaker/core/jumpstart/artifacts/payloads.py +96 -0
  159. sagemaker/core/jumpstart/artifacts/predictors.py +540 -0
  160. sagemaker/core/jumpstart/artifacts/resource_names.py +86 -0
  161. sagemaker/core/jumpstart/artifacts/resource_requirements.py +162 -0
  162. sagemaker/core/jumpstart/artifacts/script_uris.py +172 -0
  163. sagemaker/core/jumpstart/cache.py +663 -0
  164. sagemaker/core/jumpstart/configs.py +50 -0
  165. sagemaker/core/jumpstart/constants.py +198 -0
  166. sagemaker/core/jumpstart/deserializers.py +81 -0
  167. sagemaker/core/jumpstart/document.py +76 -0
  168. sagemaker/core/jumpstart/enums.py +168 -0
  169. sagemaker/core/jumpstart/exceptions.py +236 -0
  170. sagemaker/core/jumpstart/factory/utils.py +833 -0
  171. sagemaker/core/jumpstart/filters.py +597 -0
  172. sagemaker/core/jumpstart/hub/constants.py +16 -0
  173. sagemaker/core/jumpstart/hub/hub.py +291 -0
  174. sagemaker/core/jumpstart/hub/interfaces.py +936 -0
  175. sagemaker/core/jumpstart/hub/parser_utils.py +70 -0
  176. sagemaker/core/jumpstart/hub/parsers.py +288 -0
  177. sagemaker/core/jumpstart/hub/types.py +35 -0
  178. sagemaker/core/jumpstart/hub/utils.py +260 -0
  179. sagemaker/core/jumpstart/models.py +501 -0
  180. sagemaker/core/jumpstart/notebook_utils.py +575 -0
  181. sagemaker/core/jumpstart/parameters.py +20 -0
  182. sagemaker/core/jumpstart/payload_utils.py +239 -0
  183. sagemaker/core/jumpstart/region_config.json +171 -0
  184. sagemaker/core/jumpstart/search.py +171 -0
  185. sagemaker/core/jumpstart/serializers.py +81 -0
  186. sagemaker/core/jumpstart/session_utils.py +234 -0
  187. sagemaker/core/jumpstart/types.py +3044 -0
  188. sagemaker/core/jumpstart/utils.py +1731 -0
  189. sagemaker/core/jumpstart/validators.py +257 -0
  190. sagemaker/core/lambda_helper.py +312 -0
  191. sagemaker/core/lineage/__init__.py +42 -0
  192. sagemaker/core/lineage/_api_types.py +239 -0
  193. sagemaker/core/lineage/_utils.py +49 -0
  194. sagemaker/core/lineage/action.py +345 -0
  195. sagemaker/core/lineage/artifact.py +646 -0
  196. sagemaker/core/lineage/association.py +190 -0
  197. sagemaker/core/lineage/context.py +505 -0
  198. sagemaker/core/lineage/lineage_trial_component.py +191 -0
  199. sagemaker/core/lineage/query.py +732 -0
  200. sagemaker/core/lineage/visualizer.py +346 -0
  201. sagemaker/core/local/__init__.py +18 -0
  202. sagemaker/core/local/data.py +423 -0
  203. sagemaker/core/local/entities.py +678 -0
  204. sagemaker/core/local/exceptions.py +17 -0
  205. sagemaker/core/local/image.py +1243 -0
  206. sagemaker/core/local/local_session.py +739 -0
  207. sagemaker/core/local/utils.py +246 -0
  208. sagemaker/core/logs.py +181 -0
  209. sagemaker/core/metadata_properties.py +56 -0
  210. sagemaker/core/metric_definitions.py +91 -0
  211. sagemaker/core/mlflow/__init__.py +38 -0
  212. sagemaker/core/mlflow/forward_sagemaker_metrics.py +44 -0
  213. sagemaker/core/model_card/__init__.py +26 -0
  214. sagemaker/core/model_life_cycle.py +51 -0
  215. sagemaker/core/model_metrics.py +160 -0
  216. sagemaker/core/model_monitor/__init__.py +66 -0
  217. sagemaker/core/model_monitor/clarify_model_monitoring.py +1497 -0
  218. sagemaker/core/model_monitor/cron_expression_generator.py +82 -0
  219. sagemaker/core/model_monitor/data_capture_config.py +115 -0
  220. sagemaker/core/model_monitor/data_quality_monitoring_config.py +66 -0
  221. sagemaker/core/model_monitor/dataset_format.py +102 -0
  222. sagemaker/core/model_monitor/model_monitoring.py +4266 -0
  223. sagemaker/core/model_monitor/monitoring_alert.py +76 -0
  224. sagemaker/core/model_monitor/monitoring_files.py +506 -0
  225. sagemaker/core/model_monitor/utils.py +793 -0
  226. sagemaker/core/model_registry.py +480 -0
  227. sagemaker/core/model_uris.py +97 -0
  228. sagemaker/core/modules/__init__.py +19 -0
  229. sagemaker/core/modules/configs.py +239 -0
  230. sagemaker/core/modules/constants.py +37 -0
  231. sagemaker/core/modules/distributed.py +182 -0
  232. sagemaker/core/modules/local_core/local_container.py +605 -0
  233. sagemaker/core/modules/templates.py +83 -0
  234. sagemaker/core/modules/train/__init__.py +14 -0
  235. sagemaker/core/modules/train/container_drivers/__init__.py +14 -0
  236. sagemaker/core/modules/train/container_drivers/common/__init__.py +14 -0
  237. sagemaker/core/modules/train/container_drivers/common/utils.py +205 -0
  238. sagemaker/core/modules/train/container_drivers/distributed_drivers/__init__.py +14 -0
  239. sagemaker/core/modules/train/container_drivers/distributed_drivers/basic_script_driver.py +81 -0
  240. sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_driver.py +123 -0
  241. sagemaker/core/modules/train/container_drivers/distributed_drivers/mpi_utils.py +302 -0
  242. sagemaker/core/modules/train/container_drivers/distributed_drivers/torchrun_driver.py +129 -0
  243. sagemaker/core/modules/train/container_drivers/scripts/__init__.py +14 -0
  244. sagemaker/core/modules/train/container_drivers/scripts/environment.py +305 -0
  245. sagemaker/core/modules/train/sm_recipes/__init__.py +0 -0
  246. sagemaker/core/modules/train/sm_recipes/utils.py +330 -0
  247. sagemaker/core/modules/types.py +19 -0
  248. sagemaker/core/modules/utils.py +194 -0
  249. sagemaker/core/network.py +185 -0
  250. sagemaker/core/parameter.py +173 -0
  251. sagemaker/core/payloads.py +185 -0
  252. sagemaker/core/processing.py +1599 -0
  253. sagemaker/core/remote_function/__init__.py +19 -0
  254. sagemaker/core/remote_function/checkpoint_location.py +47 -0
  255. sagemaker/core/remote_function/client.py +1310 -0
  256. sagemaker/core/remote_function/core/__init__.py +0 -0
  257. sagemaker/core/remote_function/core/_custom_dispatch_table.py +72 -0
  258. sagemaker/core/remote_function/core/pipeline_variables.py +347 -0
  259. sagemaker/core/remote_function/core/serialization.py +410 -0
  260. sagemaker/core/remote_function/core/stored_function.py +223 -0
  261. sagemaker/core/remote_function/custom_file_filter.py +128 -0
  262. sagemaker/core/remote_function/errors.py +102 -0
  263. sagemaker/core/remote_function/invoke_function.py +167 -0
  264. sagemaker/core/remote_function/job.py +2121 -0
  265. sagemaker/core/remote_function/logging_config.py +38 -0
  266. sagemaker/core/remote_function/runtime_environment/__init__.py +14 -0
  267. sagemaker/core/remote_function/runtime_environment/bootstrap_runtime_environment.py +605 -0
  268. sagemaker/core/remote_function/runtime_environment/mpi_utils_remote.py +252 -0
  269. sagemaker/core/remote_function/runtime_environment/runtime_environment_manager.py +554 -0
  270. sagemaker/core/remote_function/runtime_environment/spark_app.py +18 -0
  271. sagemaker/core/remote_function/spark_config.py +149 -0
  272. sagemaker/core/resource_requirements.py +168 -0
  273. {sagemaker_core/main → sagemaker/core}/resources.py +19098 -10895
  274. sagemaker/core/s3/__init__.py +41 -0
  275. sagemaker/core/s3/client.py +367 -0
  276. sagemaker/core/s3/utils.py +175 -0
  277. sagemaker/core/script_uris.py +93 -0
  278. sagemaker/core/serializers/__init__.py +11 -0
  279. sagemaker/core/serializers/base.py +510 -0
  280. sagemaker/core/serializers/implementations.py +159 -0
  281. sagemaker/core/serializers/utils.py +223 -0
  282. sagemaker/core/serverless_inference_config.py +63 -0
  283. sagemaker/core/session_settings.py +55 -0
  284. sagemaker/core/shapes/__init__.py +3 -0
  285. sagemaker/core/shapes/model_card_shapes.py +159 -0
  286. {sagemaker_core/main → sagemaker/core/shapes}/shapes.py +5810 -1806
  287. sagemaker/core/spark/__init__.py +16 -0
  288. sagemaker/core/spark/defaults.py +16 -0
  289. sagemaker/core/spark/processing.py +1380 -0
  290. sagemaker/core/telemetry/__init__.py +23 -0
  291. sagemaker/core/telemetry/constants.py +82 -0
  292. sagemaker/core/telemetry/telemetry_logging.py +285 -0
  293. sagemaker/core/tools/__init__.py +1 -0
  294. {sagemaker_core → sagemaker/core}/tools/codegen.py +4 -4
  295. {sagemaker_core → sagemaker/core}/tools/constants.py +23 -15
  296. {sagemaker_core → sagemaker/core}/tools/data_extractor.py +1 -1
  297. {sagemaker_core → sagemaker/core}/tools/method.py +1 -1
  298. sagemaker/core/tools/model_card/generate_model_card_from_schema.py +562 -0
  299. {sagemaker_core → sagemaker/core}/tools/resources_codegen.py +165 -98
  300. {sagemaker_core → sagemaker/core}/tools/resources_extractor.py +5 -13
  301. {sagemaker_core → sagemaker/core}/tools/shapes_codegen.py +16 -17
  302. {sagemaker_core → sagemaker/core}/tools/shapes_extractor.py +29 -67
  303. {sagemaker_core → sagemaker/core}/tools/templates.py +39 -17
  304. sagemaker/core/training/__init__.py +14 -0
  305. sagemaker/core/training/configs.py +345 -0
  306. sagemaker/core/training/constants.py +37 -0
  307. sagemaker/core/training/utils.py +77 -0
  308. sagemaker/core/training_compiler/__init__.py +16 -0
  309. sagemaker/core/training_compiler/config.py +197 -0
  310. sagemaker/core/training_compiler_config.py +197 -0
  311. sagemaker/core/transformer.py +793 -0
  312. sagemaker/core/user_agent.py +76 -0
  313. sagemaker/core/utilities/__init__.py +24 -0
  314. sagemaker/core/utilities/cache.py +169 -0
  315. sagemaker/core/utilities/search_expression.py +133 -0
  316. sagemaker/core/utils/__init__.py +48 -0
  317. sagemaker/core/utils/code_injection/__init__.py +0 -0
  318. {sagemaker_core/main → sagemaker/core/utils}/code_injection/codec.py +2 -2
  319. {sagemaker_core/main → sagemaker/core/utils}/code_injection/shape_dag.py +5979 -176
  320. {sagemaker_core/main → sagemaker/core/utils}/exceptions.py +8 -8
  321. sagemaker_core/main/default_configs_helper.py → sagemaker/core/utils/intelligent_defaults_helper.py +5 -6
  322. {sagemaker_core/main → sagemaker/core/utils}/logs.py +1 -2
  323. {sagemaker_core/main → sagemaker/core/utils}/utils.py +27 -22
  324. sagemaker/core/workflow/__init__.py +152 -0
  325. sagemaker/core/workflow/conditions.py +313 -0
  326. sagemaker/core/workflow/entities.py +58 -0
  327. sagemaker/core/workflow/execution_variables.py +89 -0
  328. sagemaker/core/workflow/functions.py +193 -0
  329. sagemaker/core/workflow/parameters.py +222 -0
  330. sagemaker/core/workflow/pipeline_context.py +394 -0
  331. sagemaker/core/workflow/pipeline_definition_config.py +31 -0
  332. sagemaker/core/workflow/properties.py +285 -0
  333. sagemaker/core/workflow/step_outputs.py +65 -0
  334. sagemaker/core/workflow/utilities.py +514 -0
  335. sagemaker/lineage/__init__.py +33 -0
  336. sagemaker/lineage/action.py +28 -0
  337. sagemaker/lineage/artifact.py +28 -0
  338. sagemaker/lineage/context.py +28 -0
  339. sagemaker/lineage/lineage_trial_component.py +28 -0
  340. {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/METADATA +28 -9
  341. sagemaker_core-2.3.1.dist-info/RECORD +351 -0
  342. sagemaker_core-2.3.1.dist-info/top_level.txt +1 -0
  343. sagemaker_core/_version.py +0 -3
  344. sagemaker_core/helper/session_helper.py +0 -769
  345. sagemaker_core/resources/__init__.py +0 -1
  346. sagemaker_core/shapes/__init__.py +0 -1
  347. sagemaker_core/tools/__init__.py +0 -1
  348. sagemaker_core-1.0.62.dist-info/RECORD +0 -35
  349. sagemaker_core-1.0.62.dist-info/top_level.txt +0 -1
  350. {sagemaker_core → sagemaker/core/helper}/__init__.py +0 -0
  351. {sagemaker_core/helper → sagemaker/core/jumpstart/factory}/__init__.py +0 -0
  352. {sagemaker_core/main → sagemaker/core/jumpstart/hub}/__init__.py +0 -0
  353. {sagemaker_core/main/code_injection → sagemaker/core/modules/local_core}/__init__.py +0 -0
  354. {sagemaker_core/main → sagemaker/core/utils}/code_injection/base.py +0 -0
  355. {sagemaker_core/main → sagemaker/core/utils}/code_injection/constants.py +0 -0
  356. {sagemaker_core/main → sagemaker/core/utils}/user_agent.py +0 -0
  357. {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/WHEEL +0 -0
  358. {sagemaker_core-1.0.62.dist-info → sagemaker_core-2.3.1.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,345 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+ """This module provides the configuration classes used in ``sagemaker.modules``.
14
+
15
+ Some of these classes are re-exported from ``sagemaker.core.shapes``. For convinence,
16
+ users can import these classes directly from ``sagemaker.modules.configs``.
17
+
18
+ For more documentation on ``sagemaker.core.shapes``, see:
19
+ - https://sagemaker-core.readthedocs.io/en/stable/#sagemaker-core-shapes
20
+ """
21
+
22
+ from __future__ import absolute_import
23
+
24
+ from typing import Optional, Union, List
25
+ from pydantic import BaseModel, model_validator, ConfigDict
26
+
27
+ import sagemaker.core.shapes as shapes
28
+ from sagemaker.core.helper.pipeline_variable import StrPipeVar
29
+
30
+ # TODO: Can we add custom logic to some of these to set better defaults?
31
+ from sagemaker.core.shapes import (
32
+ StoppingCondition,
33
+ RetryStrategy,
34
+ Channel,
35
+ ShuffleConfig,
36
+ DataSource,
37
+ S3DataSource,
38
+ FileSystemDataSource,
39
+ TrainingImageConfig,
40
+ TrainingRepositoryAuthConfig,
41
+ Tag,
42
+ InfraCheckConfig,
43
+ RemoteDebugConfig,
44
+ SessionChainingConfig,
45
+ InstanceGroup,
46
+ HubAccessConfig,
47
+ ModelAccessConfig,
48
+ MetricDefinition,
49
+ DatasetSource,
50
+ )
51
+
52
+ from sagemaker.core.training.utils import convert_unassigned_to_none
53
+
54
+ __all__ = [
55
+ "BaseConfig",
56
+ "SourceCode",
57
+ "StoppingCondition",
58
+ "RetryStrategy",
59
+ "OutputDataConfig",
60
+ "Channel",
61
+ "ShuffleConfig",
62
+ "DataSource",
63
+ "S3DataSource",
64
+ "FileSystemDataSource",
65
+ "TrainingImageConfig",
66
+ "TrainingRepositoryAuthConfig",
67
+ "Tag",
68
+ "InfraCheckConfig",
69
+ "RemoteDebugConfig",
70
+ "SessionChainingConfig",
71
+ "InstanceGroup",
72
+ "TensorBoardOutputConfig",
73
+ "CheckpointConfig",
74
+ "HubAccessConfig",
75
+ "ModelAccessConfig",
76
+ "Compute",
77
+ "Networking",
78
+ "InputData",
79
+ "MetricDefinition",
80
+ "DatasetSource",
81
+ ]
82
+
83
+
84
+ class BaseConfig(BaseModel):
85
+ """BaseConfig"""
86
+
87
+ model_config = ConfigDict(validate_assignment=True, extra="forbid")
88
+
89
+
90
+ class SourceCode(BaseConfig):
91
+ """SourceCode.
92
+
93
+ The SourceCode class allows the user to specify the source code location, dependencies,
94
+ entry script, or commands to be executed in the training job container.
95
+
96
+ Parameters:
97
+ source_dir (Optional[StrPipeVar]):
98
+ The local directory, s3 uri, or path to tar.gz file stored locally or in s3 that
99
+ contains the source code to be used in the training job container.
100
+ requirements (Optional[StrPipeVar]):
101
+ The path within ``source_dir`` to a ``requirements.txt`` file. If specified, the listed
102
+ requirements will be installed in the training job container.
103
+ entry_script (Optional[StrPipeVar]):
104
+ The path within ``source_dir`` to the entry script that will be executed in the training
105
+ job container. If not specified, command must be provided.
106
+ command (Optional[StrPipeVar]):
107
+ The command(s) to execute in the training job container. Example: "python my_script.py".
108
+ If not specified, entry_script must be provided.
109
+ ignore_patterns: (Optional[List[str]]) :
110
+ The ignore patterns to ignore specific files/folders when uploading to S3. If not specified,
111
+ default to: ['.env', '.git', '__pycache__', '.DS_Store', '.cache', '.ipynb_checkpoints'].
112
+ """
113
+
114
+ source_dir: Optional[StrPipeVar] = None
115
+ requirements: Optional[StrPipeVar] = None
116
+ entry_script: Optional[StrPipeVar] = None
117
+ command: Optional[StrPipeVar] = None
118
+ ignore_patterns: Optional[List[str]] = [
119
+ ".env",
120
+ ".git",
121
+ "__pycache__",
122
+ ".DS_Store",
123
+ ".cache",
124
+ ".ipynb_checkpoints",
125
+ ]
126
+
127
+ class OutputDataConfig(shapes.OutputDataConfig):
128
+ """OutputDataConfig.
129
+
130
+ Provides the configuration for the output data location of the training job
131
+ (will not be carried over to any model repository or deployment).
132
+
133
+ Parameters:
134
+ s3_output_path (Optional[StrPipeVar]):
135
+ The S3 URI where the output data will be stored. This is the location where the
136
+ training job will save its output data, such as model artifacts and logs.
137
+ kms_key_id (Optional[StrPipeVar]):
138
+ The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that
139
+ SageMaker uses to encrypt the model artifacts at rest using Amazon S3 server-side
140
+ encryption.
141
+ compression_type (Optional[StrPipeVar]):
142
+ The model output compression type. Select None to output an uncompressed model,
143
+ recommended for large model outputs. Defaults to gzip.
144
+ """
145
+
146
+ s3_output_path: Optional[StrPipeVar] = None
147
+ kms_key_id: Optional[StrPipeVar] = None
148
+ compression_type: Optional[StrPipeVar] = None
149
+
150
+
151
+ class Compute(shapes.ResourceConfig):
152
+ """Compute.
153
+
154
+ The Compute class is a subclass of ``sagemaker.core.shapes.ResourceConfig``
155
+ and allows the user to specify the compute resources for the training job.
156
+
157
+ Parameters:
158
+ instance_type (Optional[StrPipeVar]):
159
+ The ML compute instance type. For information about available instance types,
160
+ see https://aws.amazon.com/sagemaker/pricing/.
161
+ instance_count (Optional[int]): The number of ML compute instances to use. For distributed
162
+ training, provide a value greater than 1.
163
+ volume_size_in_gb (Optional[int]):
164
+ The size of the ML storage volume that you want to provision. ML storage volumes store
165
+ model artifacts and incremental states. Training algorithms might also use the ML
166
+ storage volume for scratch space. Default: 30
167
+ volume_kms_key_id (Optional[StrPipeVar]):
168
+ The Amazon Web Services KMS key that SageMaker uses to encrypt data on the storage
169
+ volume attached to the ML compute instance(s) that run the training job.
170
+ keep_alive_period_in_seconds (Optional[int]):
171
+ The duration of time in seconds to retain configured resources in a warm pool for
172
+ subsequent training jobs.
173
+ instance_groups (Optional[List[InstanceGroup]]):
174
+ A list of instance groups for heterogeneous clusters to be used in the training job.
175
+ training_plan_arn (Optional[StrPipeVar]):
176
+ The Amazon Resource Name (ARN) of the training plan to use for this resource configuration.
177
+ enable_managed_spot_training (Optional[bool]):
178
+ To train models using managed spot training, choose True. Managed spot training
179
+ provides a fully managed and scalable infrastructure for training machine learning
180
+ models. this option is useful when training jobs can be interrupted and when there
181
+ is flexibility when the training job is run.
182
+ """
183
+
184
+ volume_size_in_gb: Optional[int] = 30
185
+ enable_managed_spot_training: Optional[bool] = None
186
+
187
+ @model_validator(mode="after")
188
+ def _model_validator(self) -> "Compute":
189
+ """Convert Unassigned values to None."""
190
+ return convert_unassigned_to_none(self)
191
+
192
+ def _to_resource_config(self) -> shapes.ResourceConfig:
193
+ """Convert to a sagemaker.core.shapes.ResourceConfig object."""
194
+ compute_config_dict = self.model_dump()
195
+ resource_config_fields = set(shapes.ResourceConfig.__annotations__.keys())
196
+ filtered_dict = {
197
+ k: v
198
+ for k, v in compute_config_dict.items()
199
+ if k in resource_config_fields and v is not None
200
+ }
201
+ if not filtered_dict:
202
+ return None
203
+ return shapes.ResourceConfig(**filtered_dict)
204
+
205
+
206
+ class Networking(shapes.VpcConfig):
207
+ """Networking.
208
+
209
+ The Networking class is a subclass of ``sagemaker.core.shapes.VpcConfig`` and
210
+ allows the user to specify the networking configuration for the training job.
211
+
212
+ Parameters:
213
+ security_group_ids (Optional[List[StrPipeVar]]):
214
+ The VPC security group IDs, in the form sg-xxxxxxxx. Specify the
215
+ security groups for the VPC that is specified in the Subnets field.
216
+ subnets (Optional[List[StrPipeVar]]):
217
+ The ID of the subnets in the VPC to which you want to connect your
218
+ training job or model.
219
+ enable_network_isolation (Optional[bool]):
220
+ Isolates the training container. No inbound or outbound network calls can be made,
221
+ except for calls between peers within a training cluster for distributed training.
222
+ If you enable network isolation for training jobs that are configured to use a VPC,
223
+ SageMaker downloads and uploads customer data and model artifacts through the
224
+ specified VPC, but the training container does not have network access.
225
+ enable_inter_container_traffic_encryption (Optional[bool]):
226
+ To encrypt all communications between ML compute instances in distributed training
227
+ choose True. Encryption provides greater security for distributed training, but
228
+ training might take longer. How long it takes depends on the amount of
229
+ communication between compute instances, especially if you use a deep learning
230
+ algorithm in distributed training.
231
+ """
232
+
233
+ security_group_ids: Optional[list[StrPipeVar]] = None
234
+ subnets: Optional[list[StrPipeVar]] = None
235
+ enable_network_isolation: Optional[bool] = None
236
+ enable_inter_container_traffic_encryption: Optional[bool] = None
237
+
238
+ @model_validator(mode="after")
239
+ def _model_validator(self) -> "Networking":
240
+ """Convert Unassigned values to None."""
241
+ return convert_unassigned_to_none(self)
242
+
243
+ def _to_vpc_config(self) -> shapes.VpcConfig:
244
+ """Convert to a sagemaker.core.shapes.VpcConfig object."""
245
+ compute_config_dict = self.model_dump()
246
+ vpc_config_fields = set(shapes.VpcConfig.__annotations__.keys())
247
+ filtered_dict = {
248
+ k: v for k, v in compute_config_dict.items() if k in vpc_config_fields and v is not None
249
+ }
250
+ if not filtered_dict:
251
+ return None
252
+ return shapes.VpcConfig(**filtered_dict)
253
+
254
+
255
+ class InputData(BaseConfig):
256
+ """InputData.
257
+
258
+ This config allows the user to specify an input data source for the training job.
259
+
260
+ Will be found at ``/opt/ml/input/data/<channel_name>`` within the training container.
261
+ For convience, can be referenced inside the training container like:
262
+
263
+ .. code:: python
264
+
265
+ import os
266
+ input_data_dir = os.environ['SM_CHANNEL_<channel_name>']
267
+
268
+ Parameters:
269
+ channel_name (StrPipeVar):
270
+ The name of the input data source channel.
271
+ data_source (Union[StrPipeVar, S3DataSource, FileSystemDataSource, DatasetSource]):
272
+ The data source for the channel. Can be an S3 URI string, local file path string,
273
+ S3DataSource object, FileSystemDataSource object, DatasetSource object, or a
274
+ pipeline variable (Properties) from a previous step.
275
+ content_type (StrPipeVar):
276
+ The MIME type of the data.
277
+ """
278
+
279
+ channel_name: StrPipeVar = None
280
+ data_source: Union[StrPipeVar, FileSystemDataSource, S3DataSource, DatasetSource] = None
281
+ content_type: StrPipeVar = None
282
+
283
+
284
+ class OutputDataConfig(shapes.OutputDataConfig):
285
+ """OutputDataConfig.
286
+
287
+ The OutputDataConfig class is a subclass of ``sagemaker.core.shapes.OutputDataConfig``
288
+ and allows the user to specify the output data configuration for the training job
289
+ (will not be carried over to any model repository or deployment).
290
+
291
+ Parameters:
292
+ s3_output_path (Optional[StrPipeVar]):
293
+ The S3 URI where the output data will be stored. This is the location where the
294
+ training job will save its output data, such as model artifacts and logs.
295
+ kms_key_id (Optional[StrPipeVar]):
296
+ The Amazon Web Services Key Management Service (Amazon Web Services KMS) key that
297
+ SageMaker uses to encrypt the model artifacts at rest using Amazon S3 server-side
298
+ encryption.
299
+ compression_type (Optional[StrPipeVar]):
300
+ The model output compression type. Select `NONE` to output an uncompressed model,
301
+ recommended for large model outputs. Defaults to `GZIP`.
302
+ """
303
+
304
+ s3_output_path: Optional[StrPipeVar] = None
305
+ kms_key_id: Optional[StrPipeVar] = None
306
+ compression_type: Optional[StrPipeVar] = None
307
+
308
+
309
+ class TensorBoardOutputConfig(shapes.TensorBoardOutputConfig):
310
+ """TensorBoardOutputConfig.
311
+
312
+ The TensorBoardOutputConfig class is a subclass of ``sagemaker.core.shapes.TensorBoardOutputConfig``
313
+ and allows the user to specify the storage locations for the Amazon SageMaker
314
+ Debugger TensorBoard.
315
+
316
+ Parameters:
317
+ s3_output_path (Optional[StrPipeVar]):
318
+ Path to Amazon S3 storage location for TensorBoard output. If not specified, will
319
+ default to
320
+ ``s3://<default_bucket>/<default_prefix>/<base_job_name>/<job_name>/tensorboard-output``
321
+ local_path (Optional[StrPipeVar]):
322
+ Path to local storage location for tensorBoard output. Defaults to /opt/ml/output/tensorboard.
323
+ """
324
+
325
+ s3_output_path: Optional[StrPipeVar] = None
326
+ local_path: Optional[StrPipeVar] = "/opt/ml/output/tensorboard"
327
+
328
+
329
+ class CheckpointConfig(shapes.CheckpointConfig):
330
+ """CheckpointConfig.
331
+
332
+ The CheckpointConfig class is a subclass of ``sagemaker.core.shapes.CheckpointConfig``
333
+ and allows the user to specify the checkpoint configuration for the training job.
334
+
335
+ Parameters:
336
+ s3_uri (Optional[StrPipeVar]):
337
+ Path to Amazon S3 storage location for the Checkpoint data. If not specified, will
338
+ default to
339
+ ``s3://<default_bucket>/<default_prefix>/<base_job_name>/<job_name>/checkpoints``
340
+ local_path (Optional[StrPipeVar]):
341
+ The local directory where checkpoints are written. The default directory is /opt/ml/checkpoints.
342
+ """
343
+
344
+ s3_uri: Optional[StrPipeVar] = None
345
+ local_path: Optional[StrPipeVar] = "/opt/ml/checkpoints"
@@ -0,0 +1,37 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+ """Constants module."""
14
+ from __future__ import absolute_import
15
+ import os
16
+
17
+ DEFAULT_INSTANCE_TYPE = "ml.m5.xlarge"
18
+
19
+ SM_CODE = "code"
20
+ SM_CODE_CONTAINER_PATH = "/opt/ml/input/data/code"
21
+
22
+ SM_DRIVERS = "sm_drivers"
23
+ SM_DRIVERS_CONTAINER_PATH = "/opt/ml/input/data/sm_drivers"
24
+ SM_DRIVERS_LOCAL_PATH = os.path.join(
25
+ os.path.dirname(os.path.abspath(__file__)), "container_drivers"
26
+ )
27
+
28
+ SOURCE_CODE_JSON = "sourcecode.json"
29
+ DISTRIBUTED_JSON = "distributed.json"
30
+ TRAIN_SCRIPT = "sm_train.sh"
31
+
32
+ DEFAULT_CONTAINER_ENTRYPOINT = ["/bin/bash"]
33
+ DEFAULT_CONTAINER_ARGUMENTS = [
34
+ "-c",
35
+ f"chmod +x {SM_DRIVERS_CONTAINER_PATH}/{TRAIN_SCRIPT} "
36
+ + f"&& {SM_DRIVERS_CONTAINER_PATH}/{TRAIN_SCRIPT}",
37
+ ]
@@ -0,0 +1,77 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+ """Training utilities."""
14
+ from __future__ import absolute_import
15
+
16
+ import os
17
+ from typing import Any, Literal
18
+ from sagemaker.core.utils.utils import Unassigned
19
+
20
+
21
+ def convert_unassigned_to_none(instance) -> Any:
22
+ """Convert Unassigned values to None for any instance."""
23
+ for name, value in instance.__dict__.items():
24
+ if isinstance(value, Unassigned):
25
+ setattr(instance, name, None)
26
+ return instance
27
+
28
+
29
+ def _is_valid_path(path: str, path_type: Literal["File", "Directory", "Any"] = "Any") -> bool:
30
+ """Check if the path is a valid local path.
31
+
32
+ Args:
33
+ path (str): Local path to validate
34
+ path_type (Optional(Literal["File", "Directory", "Any"])): The type of the path to validate.
35
+ Defaults to "Any".
36
+
37
+ Returns:
38
+ bool: True if the path is a valid local path, False otherwise
39
+ """
40
+ if not os.path.exists(path):
41
+ return False
42
+
43
+ if path_type == "File":
44
+ return os.path.isfile(path)
45
+ if path_type == "Directory":
46
+ return os.path.isdir(path)
47
+
48
+ return path_type == "Any"
49
+
50
+
51
+ def _is_valid_s3_uri(path: str, path_type: Literal["File", "Directory", "Any"] = "Any") -> bool:
52
+ """Check if the path is a valid S3 URI.
53
+
54
+ This method checks if the path is a valid S3 URI. If the path_type is specified,
55
+ it will also check if the path is a file or a directory.
56
+ This method does not check if the S3 bucket or object exists.
57
+
58
+ Args:
59
+ path (str): S3 URI to validate
60
+ path_type (Optional(Literal["File", "Directory", "Any"])): The type of the path to validate.
61
+ Defaults to "Any".
62
+
63
+ Returns:
64
+ bool: True if the path is a valid S3 URI, False otherwise
65
+ """
66
+ # Check if the path is a valid S3 URI
67
+ if not path.startswith("s3://"):
68
+ return False
69
+
70
+ if path_type == "File":
71
+ # If it's a file, it should not end with a slash
72
+ return not path.endswith("/")
73
+ if path_type == "Directory":
74
+ # If it's a directory, it should end with a slash
75
+ return path.endswith("/")
76
+
77
+ return path_type == "Any"
@@ -0,0 +1,16 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+ """Training Compiler configuration for SageMaker Python SDK."""
14
+ from __future__ import absolute_import
15
+
16
+ from sagemaker.core.training_compiler.config import TrainingCompilerConfig # noqa: F401
@@ -0,0 +1,197 @@
1
+ # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License"). You
4
+ # may not use this file except in compliance with the License. A copy of
5
+ # the License is located at
6
+ #
7
+ # http://aws.amazon.com/apache2.0/
8
+ #
9
+ # or in the "license" file accompanying this file. This file is
10
+ # distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
+ # ANY KIND, either express or implied. See the License for the specific
12
+ # language governing permissions and limitations under the License.
13
+ """Configuration for the SageMaker Training Compiler."""
14
+ from __future__ import absolute_import
15
+ import logging
16
+
17
+ from sagemaker.core.workflow import is_pipeline_variable
18
+
19
+ logger = logging.getLogger(__name__)
20
+
21
+
22
+ class TrainingCompilerConfig(object):
23
+ """The SageMaker Training Compiler configuration class."""
24
+
25
+ DEBUG_PATH = "/opt/ml/output/data/compiler/"
26
+ SUPPORTED_INSTANCE_CLASS_PREFIXES = ["p3", "p3dn", "g4dn", "p4d", "g5"]
27
+
28
+ HP_ENABLE_COMPILER = "sagemaker_training_compiler_enabled"
29
+ HP_ENABLE_DEBUG = "sagemaker_training_compiler_debug_mode"
30
+
31
+ def __init__(self, enabled=True, debug=False):
32
+ """This class initializes a ``TrainingCompilerConfig`` instance.
33
+
34
+ `Amazon SageMaker Training Compiler
35
+ <https://docs.aws.amazon.com/sagemaker/latest/dg/training-compiler.html>`_
36
+ is a feature of SageMaker Training
37
+ and speeds up training jobs by optimizing model execution graphs.
38
+
39
+ You can compile Hugging Face models
40
+ by passing the object of this configuration class to the ``compiler_config``
41
+ parameter of the :class:`~sagemaker.huggingface.HuggingFace`
42
+ estimator.
43
+
44
+ Args:
45
+ enabled (bool): Optional. Switch to enable SageMaker Training Compiler.
46
+ The default is ``True``.
47
+ debug (bool): Optional. Whether to dump detailed logs for debugging.
48
+ This comes with a potential performance slowdown.
49
+ The default is ``False``.
50
+
51
+ **Example**: The following code shows the basic usage of the
52
+ :class:`sagemaker.huggingface.TrainingCompilerConfig()` class
53
+ to run a HuggingFace training job with the compiler.
54
+
55
+ .. code-block:: python
56
+
57
+ from sagemaker.huggingface import HuggingFace, TrainingCompilerConfig
58
+
59
+ huggingface_estimator=HuggingFace(
60
+ ...
61
+ compiler_config=TrainingCompilerConfig()
62
+ )
63
+
64
+ .. seealso::
65
+
66
+ For more information about how to enable SageMaker Training Compiler
67
+ for various training settings such as using TensorFlow-based models,
68
+ PyTorch-based models, and distributed training,
69
+ see `Enable SageMaker Training Compiler
70
+ <https://docs.aws.amazon.com/sagemaker/latest/dg/training-compiler-enable.html>`_
71
+ in the `Amazon SageMaker Training Compiler developer guide
72
+ <https://docs.aws.amazon.com/sagemaker/latest/dg/training-compiler.html>`_.
73
+
74
+ """
75
+
76
+ self.enabled = enabled
77
+ self.debug = debug
78
+
79
+ self.disclaimers_and_warnings()
80
+
81
+ def __nonzero__(self):
82
+ """Evaluates to 0 if SM Training Compiler is disabled."""
83
+ return self.enabled
84
+
85
+ def disclaimers_and_warnings(self):
86
+ """Disclaimers and warnings.
87
+
88
+ Logs disclaimers and warnings about the
89
+ requested configuration of SageMaker Training Compiler.
90
+
91
+ """
92
+
93
+ if self.enabled and self.debug:
94
+ logger.warning(
95
+ "Debugging is enabled."
96
+ "This will dump detailed logs from compilation to %s"
97
+ "This might impair training performance.",
98
+ self.DEBUG_PATH,
99
+ )
100
+
101
+ def _to_hyperparameter_dict(self):
102
+ """Converts configuration object into hyperparameters.
103
+
104
+ Returns:
105
+ dict: A portion of the hyperparameters passed to the training job as a dictionary.
106
+
107
+ """
108
+
109
+ compiler_config_hyperparameters = {
110
+ self.HP_ENABLE_COMPILER: self.enabled,
111
+ self.HP_ENABLE_DEBUG: self.debug,
112
+ }
113
+
114
+ return compiler_config_hyperparameters
115
+
116
+ @classmethod
117
+ def validate(cls, estimator):
118
+ """Checks if SageMaker Training Compiler is configured correctly.
119
+
120
+ Args:
121
+ estimator (:class:`sagemaker.estimator.Estimator`): An estimator object.
122
+ When SageMaker Training Compiler is enabled, it validates if
123
+ the estimator is configured to be compatible with Training Compiler.
124
+
125
+
126
+ Raises:
127
+ ValueError: Raised if the requested configuration is not compatible
128
+ with SageMaker Training Compiler.
129
+ """
130
+ if is_pipeline_variable(estimator.instance_type):
131
+ warn_msg = (
132
+ "Estimator instance_type is a PipelineVariable (%s), "
133
+ "which has to be interpreted as one of the "
134
+ "%s classes in execution time."
135
+ )
136
+ logger.warning(
137
+ warn_msg,
138
+ type(estimator.instance_type),
139
+ str(cls.SUPPORTED_INSTANCE_CLASS_PREFIXES).replace(",", ""),
140
+ )
141
+ elif estimator.instance_type:
142
+ if "local" not in estimator.instance_type:
143
+ requested_instance_class = estimator.instance_type.split(".")[
144
+ 1
145
+ ] # Expecting ml.class.size
146
+ if not any(
147
+ [requested_instance_class == i for i in cls.SUPPORTED_INSTANCE_CLASS_PREFIXES]
148
+ ):
149
+ error_helper_string = (
150
+ "Unsupported Instance class {}."
151
+ "SageMaker Training Compiler only supports {}"
152
+ )
153
+ error_helper_string = error_helper_string.format(
154
+ requested_instance_class, cls.SUPPORTED_INSTANCE_CLASS_PREFIXES
155
+ )
156
+ raise ValueError(error_helper_string)
157
+ elif estimator.instance_type == "local":
158
+ error_helper_string = (
159
+ "SageMaker Training Compiler doesn't support local mode."
160
+ "It only supports the following GPU instances: {}"
161
+ )
162
+ error_helper_string = error_helper_string.format(
163
+ cls.SUPPORTED_INSTANCE_CLASS_PREFIXES
164
+ )
165
+ raise ValueError(error_helper_string)
166
+
167
+ if estimator.distribution and "smdistributed" in estimator.distribution:
168
+ raise ValueError(
169
+ "SageMaker distributed training configuration is currently not compatible with "
170
+ "SageMaker Training Compiler."
171
+ )
172
+
173
+ if estimator.debugger_hook_config or (not estimator.disable_profiler):
174
+ helper_string = (
175
+ "Using Debugger and/or Profiler with SageMaker Training Compiler "
176
+ "might add recompilation overhead and degrade"
177
+ "performance. Found debugger_hook_config={} "
178
+ "disable_profiler={}. Please set "
179
+ "debugger_hook_config=None and disable_profiler=True for optimal "
180
+ "performance. For more information, see Training Compiler "
181
+ "Performance Considerations "
182
+ "(https://docs.aws.amazon.com/sagemaker/latest/dg/training-compiler-tips-pitfalls.html"
183
+ "#training-compiler-tips-pitfalls-considerations)."
184
+ )
185
+ helper_string = helper_string.format(
186
+ estimator.debugger_hook_config, estimator.disable_profiler
187
+ )
188
+ logger.warning(helper_string)
189
+
190
+ if estimator.instance_groups:
191
+ raise ValueError(
192
+ "SageMaker Training Compiler currently only supports homogeneous clusters of "
193
+ "the following GPU instance families: {}. Please use the 'instance_type' "
194
+ "and 'instance_count' parameters instead of 'instance_groups'".format(
195
+ cls.SUPPORTED_INSTANCE_CLASS_PREFIXES
196
+ )
197
+ )