翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
パイプラインステップの選択的実行
Pipelines を使用してワークフローを作成し、ML トレーニングステップのオーケストレーションを行いながら、複数の実験フェーズを実行する必要がある場合があります。毎回完全なパイプラインを実行する代わりに、特定のステップのみを繰り返す必要がある場合があります。Pipelines を使用すると、パイプラインステップを選択的に実行できます。これにより、ML トレーニングを最適化できます。選択的実行は、以下のシナリオで役に立ちます。
アップストリームステップのパラメータを保持したまま、インスタンスタイプ、ハイパーパラメータ、またはその他の変数を使用して特定のステップを再起動する必要がある場合
パイプラインが中間ステップで失敗した場合。データ準備や特徴量抽出などの実行前のステップを再実行するとコストがかかります。パイプラインを完了するには、修正を適用して特定のステップを手動で再実行する必要がある場合もあります。
選択的実行を使用すると、パイプラインの有向非巡回グラフ (DAG) で接続されている限り、任意のステップのサブセットを実行できます。次の DAG は、パイプラインワークフローの例を説明しています。

選択的実行では、AbaloneTrain
ステップと AbaloneEval
ステップを選択できます。ただしこれらのステップは DAG 内で接続されていないため、AbaloneTrain
ステップと AbaloneMSECond
ステップのみを選択して選択的実行を実行することはできません。選択的実行は、ワークフロー内の選択されていないステップについて、ステップを再計算するのではなく、リファレンスパイプライン実行からの出力を再利用します。また、選択したステップの下流にある選択されていないステップは、選択的実行では実行されません。
パイプラインで中間ステップのサブセットを実行する場合、ステップが前のステップに依存している場合があります。SageMaker AI には、これらの依存関係をリソース化するためのリファレンスパイプラインの実行が必要です。例えば、AbaloneTrain
ステップと AbaloneEval
ステップを実行する場合は、AbaloneProcess
ステップからの出力が必要です。リファレンス実行 ARN を指定するか、SageMaker AI にデフォルトの動作である最新のパイプライン実行を使用するように指示できます。リファレンス実行がある場合は、リファレンス実行からランタイムパラメータを構築し、上書きして選択的実行に提供することもできます。詳細については、「リファレンス実行からランタイムパラメータ値を再使用する」を参照してください。
詳細には、SelectiveExecutionConfig
を使用して選択的実行パイプライン実行の設定を指定します。参照パイプライン実行の ARN を含めると ( source_pipeline_execution_arn
引数を指定)、SageMaker AI は指定したパイプライン実行の前のステップの依存関係を使用します。ARN を含めず、最新のパイプライン実行が存在する場合、SageMaker AI はデフォルトでその ARN をリファレンスとして使用します。ARN を含めず、SageMaker AI で最新のパイプライン実行を使用しない場合は、 reference_latest_execution
を に設定しますFalse
。SageMaker AI が最終的にリファレンスとして使用するパイプラインの実行は、最新またはユーザーが指定したかどうかにかかわらず、 Success
または Failed
状態である必要があります。
次の表は、SageMaker AI がリファレンス実行を選択する方法をまとめたものです。
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 AI はデフォルトで最新のパイプライン実行を使用するため、オプションで 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 AI では、このステップのサブセットは前のステップに依存しないため、この設定が許可されます。
# 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 )