parallel 套件

類別

ParallelJob

平行作業。

RunFunction

執行函式。

函數

parallel_run_function

建立 Parallel 物件,可在 dsl.pipeline 內當做函式使用,也可以建立為獨立平行作業。

如需使用 ParallelRunStep 的範例,請參閱筆記本 https://aka.ms/parallel-example-notebook


   from azure.ai.ml import Input, Output, parallel

   parallel_run = parallel_run_function(
       name="batch_score_with_tabular_input",
       display_name="Batch Score with Tabular Dataset",
       description="parallel component for batch score",
       inputs=dict(
           job_data_path=Input(
               type=AssetTypes.MLTABLE,
               description="The data to be split and scored in parallel",
           ),
           score_model=Input(
               type=AssetTypes.URI_FOLDER, description="The model for batch score."
           ),
       ),
       outputs=dict(job_output_path=Output(type=AssetTypes.MLTABLE)),
       input_data="${{inputs.job_data_path}}",
       max_concurrency_per_instance=2,  # Optional, default is 1
       mini_batch_size="100",  # optional
       mini_batch_error_threshold=5,  # Optional, allowed failed count on mini batch items, default is -1
       logging_level="DEBUG",  # Optional, default is INFO
       error_threshold=5,  # Optional, allowed failed count totally, default is -1
       retry_settings=dict(max_retries=2, timeout=60),  # Optional
       task=RunFunction(
           code="./src",
           entry_script="tabular_batch_inference.py",
           environment=Environment(
               image="mcr.microsoft.com/azureml/openmpi3.1.2-ubuntu18.04",
               conda_file="./src/environment_parallel.yml",
           ),
           program_arguments="--model ${{inputs.score_model}}",
           append_row_to="${{outputs.job_output_path}}",  # Optional, if not set, summary_only
       ),
   )
parallel_run_function(*, name: str | None = None, description: str | None = None, tags: Dict | None = None, properties: Dict | None = None, display_name: str | None = None, experiment_name: str | None = None, compute: str | None = None, retry_settings: BatchRetrySettings | None = None, environment_variables: Dict | None = None, logging_level: str | None = None, max_concurrency_per_instance: int | None = None, error_threshold: int | None = None, mini_batch_error_threshold: int | None = None, task: RunFunction | None = None, mini_batch_size: str | None = None, partition_keys: List | None = None, input_data: str | None = None, inputs: Dict | None = None, outputs: Dict | None = None, instance_count: int | None = None, instance_type: str | None = None, docker_args: str | None = None, shm_size: str | None = None, identity: ManagedIdentity | AmlToken | None = None, is_deterministic: bool = True, **kwargs) -> Parallel

參數

name
str

建立的平行作業或元件名稱。

description
str

平行的易記描述。

tags
Dict

要附加至這個平行的標記。

properties
Dict

資產屬性字典。

display_name
str

自訂名稱。

experiment_name
str

將會在底下建立作業的實驗名稱,如果提供 None,預設值會設定為目前的目錄名稱。 將會忽略為管線步驟。

compute
str

如果使用平行處理做為元件/函式) ,則不會使用平行作業執行 (的計算名稱。

retry_settings
BatchRetrySettings

平行元件執行失敗重試

environment_variables
Dict[str, str]

環境變數名稱和值的字典。 這些環境變數會在執行使用者指令碼的程序上設定。

logging_level
str

記錄層級名稱的字串,定義於 'logging' 中。 可能的值為 'WARNING'、'INFO'和 'DEBUG'。 (選用,預設值為 'INFO'。)此值可透過 PipelineParameter 設定。

max_concurrency_per_instance
int

每個計算實例都有的最大平行處理原則。

error_threshold
int

表格式資料集的記錄失敗數目,以及應在處理期間忽略之檔案資料集的檔案失敗數目。 如果錯誤計數超過此值,則會中止作業。 錯誤臨界值適用于整個輸入,而不是傳送至執行 () 方法的個別迷你批次。 此範圍為 [-1, int.max]。 -1 表示處理期間忽略所有失敗

mini_batch_error_threshold
int

應忽略迷你批次處理失敗的數目

task
RunFunction

平行工作

mini_batch_size
str

針對 FileDataset 輸入,此欄位是使用者腳本可在一次執行 () 呼叫中處理的檔案數目。 對於 TabularDataset 輸入,此欄位是使用者腳本可在一次執行 () 呼叫中處理的資料大約大小。 範例值為 1024、1024KB、10MB 和 1GB。 (選擇性的,FileDataset 的預設值為 10 個檔案,而 TabularDataset 為 1MB。) 此值可透過 PipelineParameter 設定。

partition_keys
List

用來將資料資料集分割成迷你批次的索引鍵。 如果指定,具有相同索引鍵的資料會分割成相同的迷你批次。 如果同時指定partition_keys和mini_batch_size,分割區索引鍵將會生效。 輸入 () 必須是分割資料集 (s) ,而partition_keys必須是每個輸入資料集的索引鍵子集,才能運作

input_data
str

輸入資料。

inputs
Dict

這個平行使用的輸入 dict。

outputs
Dict

這個平行的輸出

instance_count
int

計算目標所使用的選用執行個體或節點數目。 預設值為 1

instance_type
str

計算目標所支援的選擇性 VM 類型。

docker_args
str

傳遞至 Docker run 命令的額外引數。 這會覆寫系統或本節中已設定的任何參數。 此參數僅支援 Azure ML 計算類型。

shm_size
str

Docker 容器的共用記憶體區塊大小。 這應該是 (number) (單位) 格式,其中數位大於 0,而單位可以是 b (位元組) 、k (kb) 、m (MB) 或 g (GB) 。

identity
Union[ <xref:azure.ai.ml._restclient.v2022_02_01_preview.models.ManagedIdentity>, <xref:azure.ai.ml._restclient.v2022_02_01_preview.models.AmlToken>]

在計算上執行時,定型作業將使用的身分識別。

is_deterministic
bool

指定平行是否會在指定的相同輸入下傳回相同的輸出。 如果平行 (元件) 具決定性,當它當做管線中的節點/步驟使用時,它會重複使用目前工作區中先前提交作業的結果,且該作業具有相同的輸入和設定。 在此情況下,此步驟不會使用任何計算資源。 預設值為 True,如果您想要避免這類重複使用行為,請指定 is_deterministic=False,預設值為 True。

傳回

平行節點

傳回類型

備註

若要使用parallel_run_function:

  • 建立 <xref:azure.ai.ml.entities._builders.Parallel> 物件以指定平行執行的方式,並設定參數來控制批次大小、每個計算目標的節點數目,以及自訂 Python 腳本的參考。

  • 使用平行物件作為函式來建置管線。 定義步驟的輸入和輸出。

  • 將管線加總以執行。