`HyperparameterTuner` drops `ModelTrainer` checkpoint and retry configuration
Maintainer thường phản hồi trong vòng 2 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 85/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- aws, python
- Lĩnh vực
- backend-api-design, machine-learning
Hướng nghiên cứu
Bắt đầu tại HyperparameterTuner._build_training_job_definition() và kiểm tra cách hàm này xây dựng definition_kwargs từ ModelTrainer. So sánh các trường với HyperParameterTrainingJobDefinition và các bài kiểm thử hiện có cho định nghĩa tuner. Công việc được xem là hoàn tất khi các thiết lập checkpoint và thử lại được giữ nguyên nếu được cung cấp, đồng thời được lược bỏ phù hợp nếu không có, kể cả với huấn luyện spot được quản lý.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- Python
- Star
- 2.3k
- Fork
- 1.3k
- Merge trung bình
- 2 ngày 16 giờ
- Pull request đã merge (30 ngày)
- 88
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/sagemaker-python-sdk
-
[Bug] ModelTrainer with no input channels emits InputDataConfig: [], which CreatePipeline rejects (min=1) — v2 omitted the keyCó thể đã có người làm @sagemaker-bot đã nhận 20 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
aws/sagemaker-python-sdk#6156 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
-
sagemaker-train should depend on mlflow-skinny, following sagemaker-mlflow 0.5.0Có thể đã có người làm @mohamedzeidan2021 đã nhận 21 ngày trước. Đang mở
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
aws/sagemaker-python-sdk#6152 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
[Bug] ModelTrainer drops TrainingJobName for PipelineSession, breaking use_custom_job_prefix on TrainingStepCó thể đã có người làm @mohamedzeidan2021 đã nhận 25 ngày trước. Đang mởcomponent: pipelines type: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
aws/sagemaker-python-sdk#5776 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 2 ngày
-
`ModelTrainer` bug with method to load hyperparameters from file for Amazon Nova RecipeCó thể đã có người làm @sagemaker-bot đã nhận 20 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
aws/sagemaker-python-sdk#5770 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
aws/sagemaker-python-sdk#5588 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày
Tất cả issue của aws/sagemaker-python-sdk
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 77/100
mihai-vlc/sublime-jsfmt#56 ·
-
comp/cli comp/plugins P2 type/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
NousResearch/hermes-agent#141917 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Go device SDK: Whisper transcriber keeps buffering and transcribing audio appended after Stop()Có thể đã có người làm @apoorvdarshan đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
BasedHardware/omi#22770 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug needs-acceptance wg/router-models-inference-runtime
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
vllm-project/semantic-router#5295 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
huggingface/huggingface_hub#5210 ·
Maintainer thường phản hồi trong vòng 1 ngày