Cert EspressoLearn. Practise. Find your flow.

A LITTLE FOCUS.
A BIG NEXT STEP.

Your pace. Your space.
Google Cloud · Professional Machine Learning Engineer

Training failures and tuning

Professional Machine Learning Engineer · Lesson 10 of 19 · 1:13:00

YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗

Learning with these videos? Subscribe for new courses and exam-style questions.

In this lesson

Prepare for the Google Cloud Professional Machine Learning Engineer exam, on the official exam guide. In this lesson: troubleshooting training failures (out of memory, GPU stockouts, permission errors), hyperparameter tuning (trials, metrics, Bayesian optimization, grid and random search), and tuning foundation models (prompting first, then supervised, preference, and parameter-efficient tuning). Includes three original practice questions, with Cymbal Insurance, a fictional car and home insurer, as the example.

Study notes

The text of this lesson, to read at your own pace. Information as of November 2026.

A bad week

Monday, Cymbal Insurance's weekly training job failed overnight. Tuesday, it ran, but the new model was no better than last month's. Wednesday, the letter assistant still broke the required format, despite a very long prompt.

Troubleshooting training failures

Start with the logs: the custom training logs show each worker's stack trace, and in distributed training, one failing worker fails the whole job. When a replica runs out of memory, check the memory use, then lower the batch size, optimize the code, or choose a machine type with more memory. When a region has no free GPUs of the type you asked for, Agent Platform retries the job up to three times, and then you switch the GPU type or the region, because this is not a quota problem. A permission denied error from your code usually means the job's service account lacks a role. And since most failures come from the training code itself, test it locally or on a small machine first.

Hyperparameter tuning

Hyperparameters are settings chosen before training, like the learning rate, the tree depth, or the batch size. A hyperparameter tuning job runs many trials of your training code, each with different values within the ranges that you set. Your code reports a numeric metric, with the hypertune Python package, and the job maximizes or minimizes it. The default algorithm, Bayesian optimization, learns from earlier trials to choose the next values, while grid search and random search do not learn. Each extra hyperparameter can raise the number of trials needed, and you pay for the time that the trials run.

Prompting or tuning

With a foundation model, start with prompt design: clear instructions and a few examples, which need little labeled data and are fast to change. Consider tuning when long prompts, full of examples, still miss a strict output format, a domain style, or a classification. Supervised tuning then teaches the model from your own examples, and shorter prompts lower the cost and the latency of every request. In short, prompt first, measure with an evaluation, and tune only when prompting reaches its limit.

Fine tuning foundation models

Agent Platform offers several tuning methods. Supervised fine tuning learns from hundreds to thousands of labeled input and output examples, in a JSONL file in Cloud Storage. Preference tuning learns from pairs of answers, one chosen and one rejected, to match human preferences such as tone. Parameter efficient tuning changes only a small part of the model, with less data and less compute, while full fine tuning changes every weight, for complex tasks, at a higher cost. Open models in Model Garden can be tuned through ready notebooks or pipelines, and a tuned Gemini model is served from a shared public endpoint.

Recap

Let's recap. Troubleshoot with the logs: lower memory use or choose a bigger machine, switch the GPU type or the region on a stockout, and check the service account's roles. Hyperparameter tuning runs trials, and the code reports a metric to maximize or minimize. Bayesian optimization, the default, learns from earlier trials. Prompt first, and tune when prompts get long and still fail. Supervised tuning learns from examples, preference tuning from pairs, and parameter efficient tuning costs less than full fine tuning.

Quick checks for this lesson

The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.

  1. A serverless training job fails with “replica ran out of memory”. Each run uses a small machine type, and the batch size has just been doubled. What should the team try first?

    • Resubmit the same job unchanged
    • Request a higher GPU quota
    • Lower the batch size, or pick more memory
    • Run the same job in another region
    Show the answer

    Lower the batch size, or pick more memory

    A smaller batch size, or a machine type with more memory, removes the memory pressure that the bigger batch created. “Resubmit the same job unchanged” would make the job fail the same way, every time. “Request a higher GPU quota” is about quotas, and memory is not a quota. And “Run the same job in another region” would only move the same memory problem to another region.

  2. The letter assistant's prompt holds forty examples, costs a lot on every request, and still breaks the strict letter format. The team has two thousand approved letters. What should it do next?

    • Supervised tuning on the approved letters
    • Add forty more examples to the prompt
    • Train a new language model from scratch
    • Switch to batch inference
    Show the answer

    Supervised tuning on the approved letters

    Supervised tuning on the approved letters teaches the format, and the prompt can then drop its forty examples. “Add forty more examples to the prompt” would make every request even longer and more costly. “Train a new language model from scratch” would take a huge effort, and needs far more data than two thousand letters. And “Switch to batch inference” would lower the cost, but the format would still break.

  3. Adjusters compared pairs of chatbot answers, and marked which one they preferred for tone and helpfulness. The team has three thousand of these pairs. Which tuning method fits?

    • Supervised fine-tuning on the pairs
    • Full fine-tuning of every weight
    • Hyperparameter tuning
    • Preference tuning
    Show the answer

    Preference tuning

    Preference tuning learns from chosen and rejected pairs, which is exactly what the adjusters produced. “Supervised fine-tuning on the pairs” needs one correct output for each input, not a preferred one out of two. “Full fine-tuning of every weight” would change every weight, at a higher cost, and still needs a method for pairs. And “Hyperparameter tuning” searches training settings, and does not change the model's tone.