`HyperparameterTuner` drops `ModelTrainer` checkpoint and retry configuration
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 85/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- aws, python
調査の方向性
HyperparameterTuner._build_training_job_definition()から始め、ModelTrainerからdefinition_kwargsをどのように構築するかを調べてください。フィールドをHyperParameterTrainingJobDefinitionおよびチューナー定義の既存テストと比較してください。チェックポイントと再試行の設定が指定されていれば保持され、指定されていなければ適切に省略されること(マネージドスポットトレーニングの場合も含む)を確認できれば完了です。
索引モデルが issue の本文から書いたものです。
説明
PySDK Version
- PySDK V2 (2.x)
- PySDK V3 (3.x)
Describe the bug
HyperparameterTuner builds a
HyperParameterTrainingJobDefinition from its ModelTrainer.
The generated shape supports checkpoint_config and retry_strategy.
However, _build_training_job_definition() does not copy either value from
the trainer.
As a result, tuned training jobs lose:
- The checkpoint S3 location and local checkpoint path.
- The training retry strategy.
This behavior is especially risky for managed spot tuning. An interrupted job
cannot resume from the configured checkpoint, and transient failures do not use
the configured retry count.
This defect is present in SageMaker Python SDK v3.25.0.
To reproduce
Run this script. It does not call a live AWS service.
from unittest.mock import patch
import boto3
from sagemaker.core.parameter import IntegerParameter
from sagemaker.core.training.configs import (
CheckpointConfig,
Compute,
OutputDataConfig,
RetryStrategy,
)
from sagemaker.core.workflow.pipeline_context import PipelineSession
from sagemaker.train import ModelTrainer
from sagemaker.train.tuner import HyperparameterTuner
role = "arn:aws:iam::123456789012:role/example"
boto_session = boto3.Session(
aws_access_key_id="test",
aws_secret_access_key="test",
region_name="us-east-2",
)
pipeline_session = PipelineSession(boto_session=boto_session)
with patch(
"sagemaker.train.defaults.resolve_and_validate_role",
return_value=role,
):
trainer = ModelTrainer(
training_image="123456789012.dkr.ecr.us-east-2.amazonaws.com/example:latest",
role=role,
sagemaker_session=pipeline_session,
compute=Compute(
instance_type="ml.m5.large",
instance_count=1,
enable_managed_spot_training=True,
),
checkpoint_config=CheckpointConfig(
s3_uri="s3://example-bucket/checkpoints/",
local_path="/opt/ml/checkpoints",
),
output_data_config=OutputDataConfig(
s3_output_path="s3://example-bucket/output/",
),
).with_retry_strategy(
RetryStrategy(maximum_retry_attempts=10)
)
tuner = HyperparameterTuner(
model_trainer=trainer,
objective_metric_name="validation:accuracy",
objective_type="Maximize",
hyperparameter_ranges={
"epochs": IntegerParameter(1, 5),
},
max_jobs=2,
max_parallel_jobs=1,
)
definition = tuner._build_training_job_definition([])
print("Trainer checkpoint:", trainer.checkpoint_config)
print("Tuning checkpoint:", definition.checkpoint_config)
print("Trainer retry:", trainer.retry_strategy)
print("Tuning retry:", definition.retry_strategy)
assert definition.checkpoint_config == trainer.checkpoint_config
assert definition.retry_strategy == trainer.retry_strategy
Both assertions fail because the tuning definition fields remain unassigned.
Expected behavior
The tuning job definition must preserve the trainer's checkpoint and retry
configuration.
Screenshots or logs
The generated shape accepts both fields:
HyperParameterTrainingJobDefinition(
# ...
checkpoint_config=...,
retry_strategy=...,
)
HyperparameterTuner._build_training_job_definition() does not pass them in
definition_kwargs.
System information
- SageMaker Python SDK version: 3.25.0
- Framework name (eg. PyTorch) or algorithm (eg. KMeans): Framework-independent
- Framework version: Not applicable
- Python version: 3.12
- CPU or GPU: CPU
- Custom Docker image (Y/N): Reproduces with either
Additional context
A possible fix is to add the assigned trainer values to
definition_kwargs:
if model_trainer.checkpoint_config is not None:
definition_kwargs["checkpoint_config"] = model_trainer.checkpoint_config
if model_trainer.retry_strategy is not None:
definition_kwargs["retry_strategy"] = model_trainer.retry_strategy
Tests must cover normal and managed spot trainers, explicit values, and omitted
values.
- 主要言語
- Python
- スター
- 2.3k
- フォーク
- 1.3k
- 平均マージ
- 2日 20時間
- マージ済み PR(30日)
- 101
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
aws/sagemaker-python-sdk のほかの issue
-
[Bug] ModelTrainer with no input channels emits InputDataConfig: [], which CreatePipeline rejects (min=1) — v2 omitted the key対応中かも @sagemaker-bot が 24 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
aws/sagemaker-python-sdk#6156 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
-
sagemaker-train should depend on mlflow-skinny, following sagemaker-mlflow 0.5.0対応中かも @mohamedzeidan2021 が 25 日前に担当しました。 オープン
難易度 2/5 半日 初心者へのやさしさ 72/100
aws/sagemaker-python-sdk#6152 ·
メンテナーはふだん 2 日以内に返信
-
`ModelTrainer` bug with method to load hyperparameters from file for Amazon Nova Recipe対応中かも @sagemaker-bot が 24 日前に担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
aws/sagemaker-python-sdk#5770 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
aws/sagemaker-python-sdk#5588 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
`RoleValidationError` false positive: `explicitDeny` from a region-conditioned permissions boundary is treated as definitive対応中かも @ani26052007 が 1 日前に担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
aws/sagemaker-python-sdk#6515 · コメント 2 件 ·
メンテナーはふだん 2 日以内に返信
aws/sagemaker-python-sdk の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
AstrBotDevs/AstrBot#10720 ·
メンテナーはふだん 1 日以内に返信
-
fix(xiaomi): curated picker list still offers six ids that return 400 (plan-limited vs retired)オープンcause/upstream comp/cli P2 provider/other tool/file type/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
NousResearch/hermes-agent#143900 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1〜3時間 初心者へのやさしさ 85/100
WLAN-Pi/wlanpi-profiler#341 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
メンテナーはふだん 1 日以内に返信