Upgrade to Pro — share decks privately, control downloads, hide ads and more …

機械学習パイプラインの要件と Vertex Pipelines / Kubeflow Pipelines V2 による実装

機械学習パイプラインの要件と Vertex Pipelines / Kubeflow Pipelines V2 による実装

Asei Sugiyama

August 25, 2021
Tweet

More Decks by Asei Sugiyama

Other Decks in Technology

Transcript

  1. 自己紹介 杉山 阿聖 (@K_Ryuichirou) Software Engineer @ Repro 機械学習基盤の設計構 築

    Advisor @ moneyforward TensorFlow User Group TFX & Kubeflow Pipeline 機械学習図鑑 共著
  2. ML Pipelines for Software Engineers ML Pipelines のこれまでの経緯の振り返り MLOps :

    ML & DevOps Hidden Technical Debt in Machine Learning Systems TensorFlow Extended ML systems break. All the time. Continuous Training Recap
  3. MLOps : ML & DevOps MLOps は ML とソフトウェア開発の間の 対立を解消する取り組み

    具体的なプラクティスはいくつか出てき たものの、プラクティスに従うことでは なく自分たちの問題解決が重要 (自分たち が考える MLOps で良い) 言い換えると、機械学習により顧客に価 値提供ができるチーム作りだと言える
  4. Hidden Technical Debt in Machine Learning Systems 機械学習システムはとにかく複雑 Sculley, D.

    and Holt, Gary and Golovin, Daniel and Davydov, Eugene and Phillips, Todd and Ebner, Dietmar and Chaudhary, Vinay and Young, Michael and Crespo, Jean-Fran\c{c}ois and Dennison, Dan (2015) Hidden Technical Debt in Machine Learning Systems, Advances in Neural Information Processing Systems 28 (NIPS 2015) https://proceedings.neurips.cc/paper/2015/hash/86df7dcfd896fcaf2674f757a2463eba-Abstract.html
  5. TFX (TensorFlow Extended) Akshay Naresh Modi and Chiu Yuen Koo

    and Chuan Yu Foo and Clemens Mewald and Denis M. Baylor and Eric Breck and Heng-Tze Cheng and Jarek Wilkiewicz and Levent Koc and Lukasz Lew and Martin A. Zinkevich and Martin Wicke and Mustafa Ispir and Neoklis Polyzotis and Noah Fiedel and Salem Elie Haykal and Steven Whang and Sudip Roy and Sukriti Ramesh and Vihan Jain and Xin Zhang and Zakaria Haque TFX: A TensorFlow-Based Production- Scale Machine Learning Platform, KDD 2017 (2017) https://proceedings.neurips.cc/paper/2015/hash/86df7dcfd896fcaf2674f757a2463eba-Abstract.html
  6. Case Study : Alphabet 毎時間〜毎日更新される機 械学習モデルが数多くある このような間隔で学習する ためには自動化が必須 Denis Baylor

    and Kevin Haas and Konstantinos Katsiapis and Sammy Leong and Rose Liu and Clemens Menwald and Hui Miao and Neoklis Polyzotis and Mitchell Trott and Martin Zinkevich, Continuous Training for Production ML in the TensorFlow Extended (TFX) Platform, 2019 {USENIX} Conference on Operational Machine Learning (OpML 19) (2019) https://www.usenix.org/conference/opml19/presentation/baylor
  7. ML systems break. All the time. (1/2) 機械学習システムはしょっ ちゅう壊れる 原因は

    ML だけにとどまら ない Daniel Papasian and Todd Underwood, How ML Breaks: A Decade of Outages for One Large ML Pipeline, USENIX Association 2020 https://www.usenix.org/conference/opml20/presentation/papasian
  8. ML systems break. All the time. (2/2) 結局はチームづ くり Daniel

    Papasian and Todd Underwood, How of Outages for One Large ML Pipeline, USEN https://www.usenix.org/conference/opml20/p
  9. Vertex Pipelines / Kubeflow Pipelines V2 Kubeflow Pipelines Kubeflow Pipelines

    Pros & Cons Vertex Pipelines Vertex Pipelines & KFP v2 SDK Lab Sample Pipeline How To Build Components How To Build Pipeline Vertex Pipeline Pros & Cons
  10. Kubeflow Pipelines Pros & Cons Pros コンテナベースで開発しやすい パイプラインを Python で定義できる

    主要な要件を満たす Cons Kubeflow Pipelines のデプロイが複雑 (アップデートはほぼ不可能) 運用のために Kubernetes の知識やスキルが必要
  11. Vertex Pipelines & KFP v2 SDK Vertex Pipelines は KFP

    v2 SDK を用いる KFP v2 SDK は KFP v1 SDK と非互換 KFP v2 (バックエンド) は実装が進行中 ドキュメントやサンプルが乏しい 仕様を知りたかったらソースコードを読む & 記述方法を知りたかったら テストコードを読む
  12. Lab Sample Pipeline Vertex Pipelines で動作する サンプルパイプライン ETL - 前処理

    - 訓練 - 評価と いう典型的なパイプライン を実装 解説記事 Vertex Pipelines で動く Kubeflow Pipelines のサンプルを公開しました - Repro Tech Blog
  13. ComponentSpec コンポーネントの入出力を定義した YAML ファイル name: trainer inputs: - {name: transformed_train_data_path,

    type: {GCPPath: {data_type: CSV}}} - {name: suffix, type: String} outputs: - {name: trained_model_path, type: {GCPPath: {data_type: PKL}}} implementation: container: image: gcr.io/kfp-sample-trainer:v0.0.0 args: - {inputPath: transformed_train_data_path} - {inputValue: suffix} - {outputPath: trained_model_path}
  14. #1 Load Component 記述した ComponentSpec を元に Component を作成する ファイルパスから作成も可能 from

    kfp.components import load_component_from_text # ComponentSpec を文字列として取得 component_spec = get_component_spec(name) # ComponentSpec からコンポーネントを生成するファクトリ関数を作成 data_generator_op = load_component_from_text(component_spec) # ファクトリ関数からコンポーネントを生成 data_generator = data_generator_op()
  15. #3 Compile SDK を用いてコンパイルする 出力は PipelineSpec というスキーマに従う JSON (KFP IR

    とも) compiler.Compiler().compile( pipeline_func=kfp_sample_pipeline, package_path="kfp_sample_pipeline.json", )
  16. Vertex Pipeline Pros & Cons (2/2) Cons Kubeflow Pipelines v2

    についてのドキュメントやサンプルが乏しく、ソ ースコードの完全理解が必要 可視化周りは今手を出すのは時期尚早 ( ExecutorInput , ExecutorOutput というドキュメント化されていないものの仕様と、 Vertex Pipelines での扱いを理解する必要がある)
  17. まとめ Kubeflow Pipelines (KFP) は ML パイプラインを実行するオーケストレ ーター Vertex Pipelines

    は KFP と同じパイプラインをサーバーレスに動かせる クラウドサービス Vertex Pipelines / KFP v2 ともに基本機能は実際に利用できるものの、 可視化周りは開発中 サンプルも解説も公開済み