Exams / GCP-PMLE / D1 Scaling prototypes into ML models
D1.1
Scaling prototypes into ML models (part 1 of 3)
- Exam domain: Scaling prototypes into ML models
You are reading a free preview. The rest of the GCP-PMLE course unlocks with an Exam pass or All access.See plans
Choosing how to scale training
| Situation | Choice | Why |
|---|---|---|
| Several GPUs on one machine, least effort | One Vertex AI worker pool, MirroredStrategy |
No multi-worker cluster configuration |
| Several machines with GPUs | MultiWorkerMirroredStrategy |
Synchronous multi-worker training |
| Custom TensorFlow ops | GPUs, not TPU | Cloud TPU supports only a documented list of TensorFlow Python APIs and graph operators |
| Debuggable TPU training | TPU VM | You can connect by SSH directly to the VM physically attached to the TPU |
| PyTorch at scale | Vertex AI custom training with a prebuilt training container | Managed, no cluster to operate |
| No speed-up from more GPUs | Increase the global batch size | Each replica receives a share of the global batch |
Input-bound training
If the accelerator idles while CPU transforms and network loads run in sequence, the job is input-bound. Parallelize file reads, parallelize map() and add prefetch(); a faster TPU or GPU only waits more.
For very large structured data, convert CSVs to sharded TFRecords in Cloud Storage so reads are parallel.
Hyperparameter tuning on Vertex AI
| Hyperparameter | Scale |
|---|---|
| Bounded integer (e.g. embedding size) | UNIT_LINEAR_SCALE |
| Learning rate across orders of magnitude | UNIT_LOG_SCALE |
Bayesian optimization (the default) uses earlier trials to choose later ones, so fewer parallel trials give better results when elapsed time does not matter.
Data and metrics
| Problem | Remedy |
|---|---|
| Rare positive class | Downsample and upweight the majority class |
| Missing numeric values, rows needed | Impute (e.g. predict with a regression model) |
| Time-sensitive tabular data in AutoML | Chronological split on the Time column |
| Features on different ranges | Normalize |
| Missing fraud (false negatives) | Lower the classification threshold; add positive examples |
| Many uninformative linear features | L1 regularization (sparse weights) |
| Overfitting | Tune L2 / dropout on validation data |
| City-specific effects | Cross binned latitude x binned longitude x category |
| Imbalanced binary classes | F1 / precision-recall, not accuracy |
Experiments, tooling and exploration
- Link a Vertex AI PipelineJob to a Vertex AI Experiment to compare runs and be ready for production.
- Recommendations: Frequently Bought Together targets basket size; Others You May Like defaults to click-through rate.
- One-off, flexible EDA: Workbench notebook. Large aggregates: BigQuery. Time plots: Looker Studio.
- Spark notebooks: Workbench instance with the Dataproc JupyterLab extension.
Exam traps
- Custom TensorFlow ops rule out TPU.
- A faster accelerator does not fix an input-bound trace.
- ModelValidator (TFX) is now the Evaluator component; AI Platform Training is now Vertex AI custom training.
- Random splits leak the future on time-sensitive data.
- A suspiciously perfect metric early on points to leakage, not a great model.
- Recall protects against false negatives; precision against false positives.
Docs
- https://docs.cloud.google.com/tpu/docs/tensorflow-ops
- https://cloud.google.com/vertex-ai/docs/training/hyperparameter-tuning-overview
- https://cloud.google.com/vertex-ai/docs/training/distributed-training
- https://cloud.google.com/tpu/docs/performance-guide
- https://cloud.google.com/tpu/docs/troubleshooting/trouble-tf
- https://cloud.google.com/tpu/docs/system-architecture-tpu-vm
- https://docs.cloud.google.com/vertex-ai/docs/tabular-data/data-splits
- https://developers.google.com/machine-learning/crash-course/overfitting/imbalanced-datasets
- https://developers.google.com/machine-learning/crash-course/categorical-data/feature-crosses
- https://developers.google.com/machine-learning/crash-course/numerical-data/normalization
- https://docs.cloud.google.com/retail/docs/models