aws / aws/sagemaker-python-sdk

`ModelTrainer` bug with method to load hyperparameters from file for Amazon Nova Recipe

オープン 初心者向け
#5,770 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
2.3k
フォーク
1.3k
平均マージ
1日 22時間
マージ済み PR(30日)
35

説明

`**PySDK` Version**
- [ ] PySDK V2 (2.x)
- [x ] PySDK V3 (3.x)

**Describe the bug**
[Code](https://github.com/aws/sagemaker-python-sdk/blob/98683ac4cf5fcb0e734ff46ec046d32ade44494e/sagemaker-train/src/sagemaker/train/model_trainer.py#L1215-L1220) is using method `self._validate_and_load_hyperparameters_file` instead of self._validate_and_fetch_hyperparameters_file`:
```
if is_nova:
if hyperparameters and isinstance(hyperparameters, str):
hyperparameters = cls._validate_and_load_hyperparameters_file(hyperparameters) # bug
model_trainer_args["hyperparameters"].update(hyperparameters)
elif hyperparameters and isinstance(hyperparameters, dict):
model_trainer_args["hyperparameters"].update(hyperparameters)
```

**To reproduce**
```
from sagemaker.train.model_trainer import ModelTrainer
from sagemaker.train.configs import Compute

model_trainer = ModelTrainer.from_recipe(
training_image="327873000638.dkr.ecr.us-east-1.amazonaws.com/hyperpod-recipes:verl-v1.0.0-smtj",
training_recipe="training/nova/nova_1_0/nova_lite/CPT/nova_lite_1_0_p5x16_gpu_pretrain",
compute=Compute(instance_type="ml.m5.xlarge"),
hyperparameters="test",
)
```
```
│ │
│ 287 │ │ │ private_attributes = self.__dict__.get('__private_attributes__') │
│ 288 │ │ │ if private_attributes and item in private_attributes: │
│ 289 │ │ │ │ return private_attributes[item] │
│ ❱ 290 │ │ │ raise AttributeError(item) │
│ 291 │ │
│ 292 │ @classmethod │
│ 293 │ def __prepare__(cls, *args: Any, **kwargs: Any) -> dict[str, object]: │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: _validate_and_load_hyperparameters_file
```
**Expected behavior**
No `AttributeError` to be raised when using hyperparameter file (string).

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

sagemaker-train/src/sagemaker/train/model_trainer.py の、1215-1220行付近にある ModelTrainer.from_recipe のロジックから始めます。文字列ハイパーパラメータの経路をたどり、参照されている検証メソッドを比較します。Amazon Nova Recipe でハイパーパラメータファイルを示す文字列が AttributeError を発生させなくなり、意図されたメソッドを通じて取得されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
machine-learning
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
静か
明瞭さ
明確に書かれている
初心者へのやさしさ
82/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。