翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
パイプラインステップの選択的な実行
SageMaker Pipelines を使用してワークフローを作成し、ML トレーニングステップを調整する場合、複数の実験フェーズを実施する必要がある場合があります。毎回パイプライン全体を実行する代わりに、特定のステップのみを繰り返すことをお勧めします。 SageMaker Pipelines を使用すると、パイプラインステップを選択的に実行できます。これにより、ML トレーニングを最適化できます。選択的実行は、以下のシナリオで役に立ちます。
アップストリームステップのパラメータを保持しながら、更新されたインスタンスタイプ、ハイパーパラメータ、またはその他の変数を使用して特定のステップを再起動する場合。
パイプラインは中間ステップに失敗します。データ準備や特徴量抽出などの実行前のステップを再実行するとコストがかかります。パイプラインを完了するには、修正を導入し、特定のステップを手動で再実行する必要がある場合があります。
選択的実行を使用すると、パイプラインの有向非巡回グラフ (DAG) で接続されている限り、ステップのサブセットを実行できます。次の DAG は、パイプラインワークフローの例を示しています。
![サンプルパイプラインの有向非巡回グラフ (DAG)。](images/pipeline-full.png)
選択的な実行AbaloneEval
ではステップ AbaloneTrain
と を選択できますが、これらのAbaloneMSECond
ステップは DAG に接続されていないため、 AbaloneTrain
と ステップのみを選択することはできません。ワークフローで選択されていないステップの場合、選択的実行はステップを再実行するのではなく、参照パイプライン実行からの出力を再利用します。また、選択したステップの下流にある選択されていないステップは、選択的実行では実行されません。
パイプラインで中間ステップのサブセットを実行することを選択した場合、ステップは前のステップに依存する可能性があります。 では、これらの依存関係をリソース化するリファレンスパイプラインの実行 SageMaker が必要です。例えば、ステップ AbaloneTrain
と を実行する場合はAbaloneEval
、AbaloneProcess
ステップからの出力が必要です。参照実行 ARN を指定するか、デフォルトの動作である最新のパイプライン実行を使用する SageMaker ように に指示できます。リファレンス実行がある場合は、リファレンス実行からランタイムパラメータを構築し、オーバーライドを使用して選択的エグゼクティブ実行に提供することもできます。詳細については、「参照実行からランタイムパラメータ値を再利用する」を参照してください。
詳細には、 を使用して選択的な実行パイプライン実行の設定を指定しますSelectiveExecutionConfig
。参照パイプライン実行の ARN ( source_pipeline_execution_arn
引数を指定) SageMaker を含めると、 は指定したパイプライン実行の前のステップの依存関係を使用します。ARN を含めず、最新のパイプライン実行が存在する場合、 はデフォルトでその ARN をリファレンスとして使用 SageMaker します。ARN を含めず、最新のパイプライン実行 SageMaker を使用しない場合は、 reference_latest_execution
を に設定しますFalse
。 SageMaker 最終的に が参照として使用するパイプラインの実行は、最新の かユーザー指定の かにかかわらず、 Success
または Failed
状態である必要があります。
次の表は、 が参照実行 SageMaker を選択する方法をまとめたものです。
source_pipeline_execution_arn 引数値 |
reference_latest_execution 引数値 |
使用されたリファレンス実行 |
---|---|---|
パイプライン ARN |
|
指定されたパイプライン ARN |
パイプライン ARN |
|
指定されたパイプライン ARN |
null または未指定 |
|
最新のパイプライン実行 |
null または未指定 |
|
なし — この場合、アップストリームの依存関係のないステップを選択します |
選択的実行設定要件の詳細については、sagemaker.workflow.selective_execution_config.SelectiveExecutionConfig
以下の説明では、パイプラインリファレンスの実行を指定したり、最新のパイプライン実行を参照として使用したり、リファレンスパイプラインの実行なしで選択的実行を実行したりする例を示します。
ユーザーが指定したパイプラインリファレンスを使用した選択的実行
次の例は、ステップの選択的な実行AbaloneTrain
とリファレンスパイプライン実行AbaloneEval
の使用を示しています。
from sagemaker.workflow.selective_execution_config import SelectiveExecutionConfig selective_execution_config = SelectiveExecutionConfig( source_pipeline_execution_arn="arn:aws:sagemaker:us-west-2:123123123123:pipeline/abalone/execution/123ab12cd3ef", selected_steps=["AbaloneTrain", "AbaloneEval"] ) selective_execution = pipeline.start( execution_display_name=f"Sample-Selective-Execution-1", parameters={"MaxDepth":6, "NumRound":60}, selective_execution_config=selective_execution_config, )
最新のパイプライン実行をリファレンスとして選択した実行
次の例は、ステップの選択的な実行AbaloneTrain
と、最新のパイプライン実行AbaloneEval
をリファレンスとして使用する方法を示しています。はデフォルトで最新のパイプライン実行 SageMaker を使用するため、オプションで reference_latest_execution
引数を に設定することができますTrue
。
# Prepare a new selective execution. Select only the first step in the pipeline without providing source_pipeline_execution_arn. selective_execution_config = SelectiveExecutionConfig( selected_steps=["AbaloneTrain", "AbaloneEval"], # optional reference_latest_execution=True ) # Start pipeline execution without source_pipeline_execution_arn pipeline.start( execution_display_name=f"Sample-Selective-Execution-1", parameters={"MaxDepth":6, "NumRound":60}, selective_execution_config=selective_execution_config, )
リファレンスパイプラインを使用しない選択的な実行
次の例は、リファレンス ARN を指定AbaloneProcess
AbaloneTrain
せずにステップを選択的に実行し、最新のパイプライン実行をリファレンスとして使用するオプションをオフにする方法を示しています。ステップのサブセットは前のステップに依存しないため、 はこの設定 SageMaker を許可します。
# Prepare a new selective execution. Select only the first step in the pipeline without providing source_pipeline_execution_arn. selective_execution_config = SelectiveExecutionConfig( selected_steps=["AbaloneProcess", "AbaloneTrain"], reference_latest_execution=False ) # Start pipeline execution without source_pipeline_execution_arn pipeline.start( execution_display_name=f"Sample-Selective-Execution-1", parameters={"MaxDepth":6, "NumRound":60}, selective_execution_config=selective_execution_config, )
参照実行からランタイムパラメータ値を再利用する
を使用してリファレンスパイプラインの実行からパラメータを構築しbuild_parameters_from_execution
、その結果を選択的実行パイプラインに提供できます。参照実行の元のパラメータを使用することも、 parameter_value_overrides
引数を使用してオーバーライドを適用することもできます。
次の例は、参照実行からパラメータを構築し、 MseThreshold
パラメータにオーバーライドを適用する方法を示しています。
# Prepare a new selective execution. selective_execution_config = SelectiveExecutionConfig( source_pipeline_execution_arn="arn:aws:sagemaker:us-west-2:123123123123:pipeline/abalone/execution/123ab12cd3ef", selected_steps=["AbaloneTrain", "AbaloneEval", "AbaloneMSECond"], ) # Define a new parameters list to test. new_parameters_mse={ "MseThreshold": 5, } # Build parameters from reference execution and override with new parameters to test. new_parameters = pipeline.build_parameters_from_execution( pipeline_execution_arn="arn:aws:sagemaker:us-west-2:123123123123:pipeline/abalone/execution/123ab12cd3ef", parameter_value_overrides=new_parameters_mse ) # Start pipeline execution with new parameters. execution = pipeline.start( selective_execution_config=selective_execution_config, parameters=new_parameters )