aws / aws/sagemaker-python-sdk

ModelTrainer (V3) does not support output_kms_key for source code uploads

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

説明

## Describe the bug

In SageMaker SDK V2, the `Estimator` uses the `output_kms_key` when uploading user training scripts to S3 (see `_stage_user_code_in_s3`):
https://github.com/aws/sagemaker-python-sdk/blob/5b3b127a2d3d12a6ff0d877ddfd9ddf13527c27f/src/sagemaker/estimator.py#L1044-L1108

In SageMaker SDK V3, the new `ModelTrainer` does not apply any KMS key when uploading source code while creating the input data channel:
https://github.com/aws/sagemaker-python-sdk/blob/9101cef1a589cf2b44e73c5456dfa46c10e32691/sagemaker-train/src/sagemaker/train/model_trainer.py#L834-L953

Additionally, even when providing an S3 URI in the `SourceCode` object (instead of a local path), the `ModelTrainer` still uploads additional driver files whenever source code is specified:
https://github.com/aws/sagemaker-python-sdk/blob/9101cef1a589cf2b44e73c5456dfa46c10e32691/sagemaker-train/src/sagemaker/train/model_trainer.py#L684-L689

These uploads do not use a KMS key.

## Expected behavior

`ModelTrainer` should:
- either respect a user-provided KMS key (similar to `output_kms_key` in V2), OR
- allow configuration of a KMS key for all S3 uploads related to source code.

## Actual behavior

- Source code and driver files are uploaded to S3 without KMS encryption.
- There is no apparent way to configure a KMS key for these uploads.

## Impact

In restricted environments (like ours), S3 policies enforce server-side encryption with KMS.
As a result, `ModelTrainer` cannot be used with custom training scripts.

This blocks use cases that rely on custom code, such as MLflow serverless integration.

## Steps to reproduce

1. Create a `ModelTrainer` with a `SourceCode` object
2. Provide either:
- a local path, or
- an S3 URI
3. Observe that S3 uploads occur without KMS encryption

## Possible solution

Expose a parameter similar to `output_kms_key` in V2, or reuse existing encryption configuration mechanisms.

## Additional context

This is a regression compared to V2 `Estimator` behavior and impacts secure environments with strict S3 encryption policies.

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

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

調査の方向性

issueで挙げられているinput-channelおよびdriver-fileのアップロードパス付近にあるsagemaker-train/src/sagemaker/train/model_trainer.pyから開始し、その後、src/sagemaker/estimator.pyの_stage_user_code_in_s3と比較してください。既存の暗号化設定を追跡し、ローカルおよびS3 SourceCodeアップロードを対象とした集中的なカバレッジを追加してください。すべてのソース関連アップロードで設定済みのKMSキーを使用できれば完了です。

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

評価

技術スタック
aws, python
領域
cloud, machine-learning
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
68/100

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

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