AWS Security ChangesHomeSearch

AWS sagemaker documentation change

Service: sagemaker · 2026-06-28 · Documentation low

File: sagemaker/latest/dg/debugger-built-in-rules-example.md

Summary

Added SageMaker Python SDK v3 code examples for using built-in rules and modifying rule parameters

Security assessment

The changes only add new SDK usage examples for Debugger rules. There is no mention of security vulnerabilities, patches, or security features.

Diff

diff --git a/sagemaker/latest/dg/debugger-built-in-rules-example.md b/sagemaker/latest/dg/debugger-built-in-rules-example.md
index d9945f953..896987bf7 100644
--- a//sagemaker/latest/dg/debugger-built-in-rules-example.md
+++ b//sagemaker/latest/dg/debugger-built-in-rules-example.md
@@ -46,0 +47,42 @@ The following code sample shows how to set the Debugger built-in rules using the
+SageMaker Python SDK v3
+    
+    
+    
+    import boto3
+    import sagemaker
+    from sagemaker.train import ModelTrainer
+    from sagemaker.core.debugger import Rule, CollectionConfig, rule_configs
+    from sagemaker.core.helper.session_helper import get_execution_role
+    **built_in_rules** =[ 
+                Rule.sagemaker(rule_configs.vanishing_gradient()),
+                Rule.sagemaker(rule_configs.loss_not_decreasing())
+    ]
+    
+    from sagemaker.core import image_uris
+    from sagemaker.train.configs import SourceCode, Compute
+    
+    training_image = image_uris.retrieve(
+        framework="tensorflow",
+        region=boto3.Session().region_name,
+        version="2.9.0",
+        py_version="py39",
+        instance_type="ml.p3.2xlarge",
+        image_scope="training"
+    )
+    
+    # construct a SageMaker AI ModelTrainer with the Debugger built-in rules
+    sagemaker_model_trainer=ModelTrainer(
+        training_image=training_image,
+        source_code=SourceCode(entry_script='directory/to/your_training_script.py'),
+        role=get_execution_role(),
+        base_job_name='debugger-built-in-rules-demo',
+        compute=Compute(instance_type="ml.p3.2xlarge", instance_count=1),
+    
+        **# debugger-specific arguments below**
+        **rules=built_in_rules**
+    )
+    sagemaker_model_trainer.train()
+
+SageMaker Python SDK v2 (Legacy)
+    
+    
@@ -84,0 +127,63 @@ The following code example shows the structure of built-in rules to adjust param
+SageMaker Python SDK v3
+    
+    
+    
+    import boto3
+    import time
+    import sagemaker
+    from sagemaker.train import ModelTrainer
+    from sagemaker.core.debugger import Rule, CollectionConfig, rule_configs
+    from sagemaker.core.helper.session_helper import get_execution_role
+    
+    # call the built-in rules and modify the CollectionConfig parameters
+    
+    base_job_name_prefix= 'smdebug-stalled-demo-' + str(int(time.time()))
+    
+    **built_in_rules_modified** =[
+        Rule.sagemaker(
+            base_config=rule_configs.stalled_training_rule(),
+            rule_parameters={
+                    'threshold': '120',
+                    'training_job_name_prefix': base_job_name_prefix,
+                    'stop_training_on_fire' : 'True'
+            },
+            collections_to_save=[ 
+                CollectionConfig(
+                    name="losses", 
+                    parameters={
+                          "train.save_interval": "50",
+                          "eval.save_interval": "10"
+                    } 
+                )
+            ]
+        )
+    ]
+    
+    from sagemaker.core import image_uris
+    from sagemaker.train.configs import SourceCode, Compute
+    
+    training_image = image_uris.retrieve(
+        framework="tensorflow",
+        region=boto3.Session().region_name,
+        version="2.9.0",
+        py_version="py39",
+        instance_type="ml.p3.2xlarge",
+        image_scope="training"
+    )
+    
+    # construct a SageMaker AI ModelTrainer with the modified Debugger built-in rule
+    sagemaker_model_trainer=ModelTrainer(
+        training_image=training_image,
+        source_code=SourceCode(entry_script='directory/to/your_training_script.py'),
+        role=get_execution_role(),
+        base_job_name=base_job_name_prefix,
+        compute=Compute(instance_type="ml.p3.2xlarge", instance_count=1),
+    
+        # debugger-specific arguments below
+        **rules=built_in_rules_modified**
+    )
+    sagemaker_model_trainer.train()
+
+SageMaker Python SDK v2 (Legacy)
+    
+