{"id":1026,"library":"smdebug-rulesconfig","title":"SMDebug RulesConfig","description":"SMDebug RulesConfig is a Python library that provides a mapping of built-in rules with default configurations for Amazon SageMaker Debugger. It helps users specify these rules and common collection configurations without needing to handle low-level details, working in conjunction with the Amazon SageMaker Python SDK. The current version is 1.0.1, released in December 2020. While the package itself has not seen recent updates, its functionality remains an integral part of the SageMaker Debugger ecosystem.","status":"active","version":"1.0.1","language":"python","source_language":"en","source_url":"https://github.com/awslabs/sagemaker-debugger-rulesconfig","tags":["aws","sagemaker","debugger","machine-learning","mlops","model-debugging"],"install":[{"cmd":"pip install smdebug-rulesconfig","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"note":"The `rule_configs` object provides access to built-in debugger rule configurations. `Rule` and `CollectionConfig` are typically imported alongside for full rule definition within the SageMaker Python SDK.","symbol":"rule_configs","correct":"from sagemaker.debugger import Rule, CollectionConfig, rule_configs"}],"quickstart":{"code":"from sagemaker.debugger import Rule, CollectionConfig, rule_configs\nfrom sagemaker.estimator import Estimator # Placeholder for a SageMaker Estimator\nimport os\n\n# In a real scenario, replace this with your actual SageMaker Estimator setup\n# and ensure AWS credentials are configured (e.g., via environment variables or AWS CLI)\n# For example: estimator = TensorFlow(role=os.environ.get('SAGEMAKER_ROLE', 'arn:aws:iam::123456789012:role/SageMakerRole'), ...)\n# We use a placeholder here for quickstart reproducibility.\n\n# Example: Vanilla built-in rule without customization\n# This would typically be passed to a SageMaker Estimator's 'rules' parameter.\nrule_vanishing_gradient = Rule.sagemaker(rule_configs.vanishing_gradient())\nprint(f\"Vanishing Gradient Rule: {rule_vanishing_gradient.name}\")\n\n# Example: Built-in rule with customization\n# This demonstrates how to customize a rule's parameters and collections.\nrule_customized_weight_update = Rule.sagemaker(\n    base_config=rule_configs.weight_update_ratio(),\n    name=\"my_custom_wup_rule\", # Optional\n    # container_local_path=\"/local/path\", # Optional, if running locally or specific container path\n    # s3_output_path=\"s3://your-s3-bucket/debug-output/\", # Optional, overrides default\n    rule_parameters={\n        \"threshold\": \"0.001\" # Example parameter customization\n    },\n    collections_to_save=[\n        CollectionConfig(\n            name=\"weights\", # Required. Debugger will collect tensors for this collection.\n            parameters={\n                \"save_interval\": \"100\" # Example collection parameter\n            }\n        )\n    ]\n)\nprint(f\"Customized Weight Update Ratio Rule: {rule_customized_weight_update.name}\")\nprint(f\"  Rule parameters: {rule_customized_weight_update.rule_parameters}\")\nprint(f\"  Collections to save: {[c.name for c in rule_customized_weight_update.collections_to_save]}\")","lang":"python","description":"This quickstart demonstrates how to instantiate built-in SageMaker Debugger rules using `smdebug-rulesconfig` via the `sagemaker.debugger` module. It shows both a basic rule configuration and a more advanced example with custom parameters and tensor collection specifications, which are typically passed to a SageMaker Estimator."},"warnings":[{"fix":"Review SageMaker Python SDK and `smdebug` documentation for best practices when upgrading, especially concerning profiler rules and rule actions. Ensure your `sagemaker` and `smdebug` client libraries are also up-to-date.","message":"Major version 1.0.0 introduced the ability to specify profiler rules, and 1.0.1 added action classes for rules (e.g., `StopTraining`, `Email`). While older rule definitions might still work, new features and potentially updated underlying behavior for rule processing necessitate awareness of these version changes when upgrading or using new capabilities.","severity":"breaking","affected_versions":"<1.0.0"},{"fix":"Always run `pip install -U sagemaker smdebug` alongside `pip install -U smdebug-rulesconfig` to ensure all components are at compatible and recent versions.","message":"This library (smdebug-rulesconfig) is tightly integrated with the Amazon SageMaker Python SDK and the `smdebug` client library. To utilize the latest Debugger features and ensure compatibility, it is crucial to keep both `sagemaker` and `smdebug` packages updated in your environment, not just `smdebug-rulesconfig`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Set `debugger_hook_config=False` when initializing your SageMaker framework estimator, e.g., `estimator = TensorFlow(..., debugger_hook_config=False)`.","message":"The SageMaker DebuggerHookConfig is initialized by default for framework estimators (e.g., TensorFlow, PyTorch) to minimize code changes for debugging. If you do not intend to use Debugger, you must explicitly disable the hook.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Understand that `smdebug-rulesconfig` provides the rule definitions, which are then passed to a SageMaker Estimator. SageMaker handles running these rules. For local or custom analysis, the `smdebug` client library is used to read debug data. Refer to the SageMaker Debugger developer guide for a comprehensive understanding of the workflow.","message":"The `smdebug-rulesconfig` library focuses on *configuring* rules. The actual execution and analysis of these rules occur within the broader Amazon SageMaker Debugger service, often leveraging the `smdebug` client library for data retrieval and custom rule logic. Confusing these roles can lead to unexpected behavior if not properly integrated into a SageMaker training job.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-05-12T22:46:06.890Z","next_check":"2026-06-27T00:00:00.000Z","problems":[{"fix":"Install the package using pip: `pip install smdebug-rulesconfig`","cause":"The 'smdebug-rulesconfig' Python package is not installed in the current environment or is not accessible in the Python path.","error":"ModuleNotFoundError: No module named 'smdebug_rulesconfig'"},{"fix":"Import the rule from the correct submodule: `from smdebug_rulesconfig.rules import LossNotDecreasing`","cause":"Specific rules like `LossNotDecreasing` are located within the `smdebug_rulesconfig.rules` submodule, not directly under the top-level `smdebug_rulesconfig` package.","error":"ImportError: cannot import name 'LossNotDecreasing' from 'smdebug_rulesconfig'"},{"fix":"Update the import statement to use the current `rules` submodule: `from smdebug_rulesconfig.rules import Overfit` (replace `Overfit` with the desired rule name).","cause":"The `smdebug-rulesconfig` library consolidated rule definitions under the `smdebug_rulesconfig.rules` submodule. Older examples or documentation might reference the deprecated `debugger_rules` submodule.","error":"ModuleNotFoundError: No module named 'smdebug_rulesconfig.debugger_rules'"},{"fix":"Call the `.base_config()` method on the rule class to obtain the required dictionary configuration: `rules = [LossNotDecreasing.base_config()]`","cause":"The `sagemaker.debugger.Rule` constructor expects the `rule_configuration` parameter to be a dictionary, but a `smdebug-rulesconfig` rule class (or instance) was provided directly without calling its `.base_config()` method.","error":"TypeError: Parameter rule_configuration must be a dictionary. Got <class 'smdebug_rulesconfig.rules.loss_not_decreasing.LossNotDecreasing'> instead."}],"ecosystem":"pypi","meta_description":null,"install_score":0,"install_tag":"stale","quickstart_score":null,"quickstart_tag":null,"pypi_latest":"1.0.1","cli_name":"","install_checks":{"last_tested":"2026-05-12","tag":"stale","tag_description":"widespread failures or data too old to trust","installed_version":"1.0.1","pypi_latest":"1.0.1","is_stale":false,"results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"18.0M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"19M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"19.9M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.6,"import_time_s":null,"mem_mb":null,"disk_size":"20M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.7M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"11.5M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.4,"import_time_s":null,"mem_mb":null,"disk_size":"12M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":"17.5M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":0,"wheel_type":"wheel","failure_reason":null,"import_side_effects":"broken","install_time_s":1.7,"import_time_s":null,"mem_mb":null,"disk_size":"18M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"smdebug-rulesconfig","exit_code":1,"wheel_type":null,"failure_reason":null,"import_side_effects":null,"install_time_s":null,"import_time_s":null,"mem_mb":null,"disk_size":null}]},"quickstart_checks":{"last_tested":"2026-04-24","tag":null,"tag_description":null,"results":[{"runtime":"python:3.10-alpine","exit_code":1},{"runtime":"python:3.10-slim","exit_code":1},{"runtime":"python:3.11-alpine","exit_code":1},{"runtime":"python:3.11-slim","exit_code":1},{"runtime":"python:3.12-alpine","exit_code":1},{"runtime":"python:3.12-slim","exit_code":1},{"runtime":"python:3.13-alpine","exit_code":1},{"runtime":"python:3.13-slim","exit_code":1},{"runtime":"python:3.9-alpine","exit_code":1},{"runtime":"python:3.9-slim","exit_code":1}]}}