設定執行作業快取

Vertex AI Pipelines 執行 pipeline 時,會檢查 Vertex 機器學習中繼資料中,是否已存在每個 pipeline 步驟的介面 (快取鍵) 執行作業

步驟的介面定義為下列項目的組合:

  1. 管道步驟的輸入內容。這些輸入內容包括輸入參數的值 (如有) 和輸入構件 ID (如有)。

  2. 管道步驟的輸出定義。這項輸出定義包含輸出參數定義 (名稱,如有) 和輸出構件定義 (名稱,如有)。

  3. 元件規格。這項規格包括使用的映像檔、指令、引數和環境變數,以及指令和引數的順序。

此外,只有管道名稱相同的管道才會共用快取。

如果 Vertex ML 中繼資料中有相符的執行作業,系統會使用該作業的輸出內容,並略過該步驟。這樣做可略過先前管道執行作業中已完成的運算,有助於降低成本。

如要在工作層級關閉執行作業快取,請設定下列項目:

eval_task.set_caching_options(False)

您可以為整個管道工作關閉執行作業快取。使用 PipelineJob() 執行管道時,可以透過 enable_caching 引數指定這個管道執行作業不使用快取。管線作業中的所有步驟都不會使用快取。 進一步瞭解如何建立管道執行作業

請使用下列範例關閉快取:

pl = PipelineJob(
    display_name="My first pipeline",

    # Whether or not to enable caching
    # True = enable the current run to use caching results from previous runs
    # False = disable the current run's use of caching results from previous runs
    # None = defer to cache option for each pipeline component in the pipeline definition
    enable_caching=False,

    # Local or Cloud Storage path to a compiled pipeline definition
    template_path="pipeline.yaml",

    # Dictionary containing input parameters for your pipeline
    parameter_values=parameter_values,

    # Cloud Storage path to act as the pipeline root
    pipeline_root=pipeline_root,
)

這項功能有以下限制:

  • 快取結果沒有存留時間 (TTL),只要項目未從 Vertex ML 中繼資料刪除,即可重複使用。如果從 Vertex 機器學習中繼資料刪除項目,工作會重新執行,再次產生結果。