Skip to content

Add optional GPU accelerator config to Vertex pipelines - #65

Merged
shlbatra merged 1 commit into
mainfrom
feat/gpu-vertex-pipelines
Aug 5, 2026
Merged

Add optional GPU accelerator config to Vertex pipelines#65
shlbatra merged 1 commit into
mainfrom
feat/gpu-vertex-pipelines

Conversation

@shlbatra

@shlbatra shlbatra commented Aug 5, 2026

Copy link
Copy Markdown
Owner

Summary

Implements Option A of plan/gpu_vertex_pipelines.md: lets specific Vertex AI pipeline steps run on GPU-accelerated hardware, configurable per-run without code changes. Default behavior is unchanged (CPU-only).

  • Adds --accelerator-type / --accelerator-count CLI args to the training and inference pipelines, wired through all four Airflow DAGs (staging + prod) as params.
  • Attaches a GPU to the training steps (decision_tree, random_forest) and the inference_model step when configured; blank accelerator = CPU-only.

Deviations from the plan (KFP 2.13 / GCPC 2.20)

  1. API. PipelineTask has no set_machine_type() / set_accelerator_count(). Used the real methods set_accelerator_type() + set_accelerator_limit(n) (n ∈ {0,1,2,4,8,16}). There's no way to pin an exact machine-type string on a lightweight component — Vertex auto-selects a compatible n1-* machine — so machine_type was dropped. Exact machine-type control (incl. g2/NVIDIA_L4) is the Option B upgrade path via create_custom_training_job_from_component.
  2. Compile timing. @kfp.dsl.pipeline builds the graph eagerly at decoration/import time, so reassigning module constants in __main__ before .compile() is ignored. The decorator is now applied programmatically in __main__ after CLI args are parsed, so the GPU config is baked into the graph. (This also makes the existing --model-name/--image-name overrides authoritative.)

Testing

Compiled both pipelines offline:

  • CPU-only run → no accelerator block in the compiled spec (no behavior change).
  • T4 run → correct accelerator: {type: NVIDIA_TESLA_T4, count: '1'} on each targeted step.

python -m py_compile passes on all 6 changed files.

Note: current Iris models are scikit-learn (no GPU benefit per plan §7); this is plumbing for when models move to XGBoost gpu_hist / deep learning.

🤖 Generated with Claude Code

…lines

Implements Option A of plan/gpu_vertex_pipelines.md: attach a GPU to the
model-training steps and the inference step via KFP's native resource API.

- Add --accelerator-type / --accelerator-count CLI args to both pipelines and
  wire them through all four Airflow DAGs (staging + prod) as params. Blank
  accelerator = CPU-only (unchanged default behavior).
- Use set_accelerator_type() + set_accelerator_limit() (real KFP 2.13 API);
  the plan's set_machine_type()/set_accelerator_count() do not exist. Vertex
  auto-selects a compatible n1-* machine, so machine_type was dropped.
- Apply @kfp.dsl.pipeline programmatically in __main__ after args are parsed:
  KFP builds the graph eagerly at decoration time, so decorating at import
  would freeze it with CPU-only config and ignore the CLI overrides.
- Validate accelerator count is one of 1/2/4/8/16 when a GPU is requested.
- Document both deviations in the plan doc.

Verified: both pipelines compile CPU-only (no accelerator block) and with a
T4 GPU (correct accelerator spec on each targeted step).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shlbatra
shlbatra merged commit bd092dd into main Aug 5, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant