Machine Learning Associate · 23% of the exam

Training ML Models: free practice questions

5 sample questions from our 58-question bank for this domain — answers and explanations included. These are the same scenario-based style as the real Databricks exam.

1. A data scientist uses `TorchDistributor` to run distributed PyTorch training on a Databricks cluster that has 4 worker nodes, each with 2 GPUs. They want to use all available GPUs for training. How should they configure `TorchDistributor`?

  • A. TorchDistributor(num_processes=4, local_mode=False, use_gpu=True)
  • B. TorchDistributor(num_processes=8, local_mode=False, use_gpu=True)✓ Correct
  • C. TorchDistributor(num_processes=8, local_mode=True, use_gpu=True)
  • D. TorchDistributor(num_processes=2, local_mode=False, use_gpu=True)
Explanation

To use all available GPUs across the cluster, num_processes should equal the total number of GPUs: 4 workers × 2 GPUs = 8 processes. local_mode=False is required to distribute training across multiple nodes (local_mode=True would restrict training to the driver node only, using at most 2 GPUs). use_gpu=True ensures GPU resources are allocated. Option A uses num_processes=4, which would only use one GPU per worker — underutilizing the hardware. Option C uses num_processes=8 but local_mode=True, which confines execution to the driver node and cannot access 8 GPUs. Option D uses num_processes=2, which only uses 2 GPUs total regardless of available hardware.

2. A team is using Hyperopt with SparkTrials to perform distributed hyperparameter tuning for a LightGBM model on a Databricks cluster. The team notices that only one trial runs at a time despite having multiple workers. What is the MOST likely cause?

  • A. The parallelism parameter in SparkTrials was not set, so it defaults to 1.✓ Correct
  • B. LightGBM is not compatible with SparkTrials and requires plain Trials instead.
  • C. fmin() must be called inside a with mlflow.start_run() block to enable parallelism.
  • D. SparkTrials requires the loss function to return a dictionary rather than a scalar to enable parallel evaluation.
Explanation

Correct (A): SparkTrials accepts a parallelism argument (e.g., SparkTrials(parallelism=4)) that controls how many trials run concurrently on Spark workers. If parallelism is not specified, it defaults to 1, meaning trials run sequentially. (B) is wrong — LightGBM is fully compatible with SparkTrials; any Python-based objective function can be used. (C) is wrong — while wrapping fmin() in an MLflow run is a best practice for tracking, it does not affect parallelism. (D) is wrong — while Hyperopt recommends returning a dictionary (with 'loss' and 'status' keys) for richer reporting, returning a scalar is still valid and does not affect parallelism.

3. A data scientist is training a PyTorch model on a Databricks cluster using `TorchDistributor`. They call `TorchDistributor(num_processes=4, local_world_size=2, use_gpu=True).run(train_fn)`. The cluster has 2 worker nodes, each with 2 GPUs. Which of the following BEST describes what this configuration achieves?

  • A. It launches 4 total training processes across 2 worker nodes, with 2 processes (and 2 GPUs) per node, performing data-parallel distributed training.✓ Correct
  • B. It launches 4 training processes all on the driver node using 4 GPUs attached to the driver.
  • C. It launches 2 training processes per worker node, but only the first worker node participates because `local_world_size=2`.
  • D. It launches 8 total processes because each GPU spawns 2 processes — one for data loading and one for gradient computation.
Explanation

`num_processes=4` sets the total number of training processes across the entire cluster, and `local_world_size=2` specifies how many processes (GPUs) to use per node. With 2 worker nodes and `local_world_size=2`, this means 2 processes per node × 2 nodes = 4 total processes, each using one GPU. This is standard data-parallel distributed training. Option B is wrong because TorchDistributor distributes across worker nodes, not just the driver. Option C misinterprets `local_world_size` as limiting participation to one node. Option D is a fabricated behavior — TorchDistributor does not spawn separate data-loading and gradient processes per GPU.

4. A data scientist is training a PyTorch model on a Databricks GPU cluster and wants to track training loss after each epoch using MLflow. They call `mlflow.log_metric('train_loss', loss.item(), step=epoch)` inside the training loop. After training, they notice only the final epoch's metric appears in the MLflow UI. What is the most likely cause?

  • A. MLflow `log_metric` does not support the `step` parameter for PyTorch runs.
  • B. The MLflow run was started inside the training loop, creating a new run each epoch and overwriting the previous one.✓ Correct
  • C. The `loss.item()` call detaches the tensor but truncates the value to an integer, so all intermediate values appear identical.
  • D. The Databricks MLflow autologging for PyTorch captured the metrics and overwrote the manually logged ones.
Explanation

If `mlflow.start_run()` is called inside the training loop without proper context management, a new MLflow run is created on each epoch. The UI would only surface the most recently active or completed run, making it appear that only the final metric was logged. Option A is false; `mlflow.log_metric` fully supports the `step` parameter for time-series metrics. Option C is incorrect; `loss.item()` returns a Python float, not an integer — it does not truncate values. Option D is plausible but misleading; PyTorch autologging does not automatically overwrite manual `log_metric` calls within the same run, and the described symptom (only one run visible) points to multiple runs being created.

5. A data scientist is training a scikit-learn model on a Databricks cluster. The dataset is small enough to fit entirely in the driver's memory, and no distributed processing is needed. Which of the following statements BEST describes the appropriate cluster configuration for this workload?

  • A. Use a single-node cluster with no worker nodes, since scikit-learn runs on the driver and does not utilize Spark workers.✓ Correct
  • B. Use a cluster with at least 4 worker nodes to ensure parallel model training across executors.
  • C. Use a GPU-enabled multi-node cluster, because scikit-learn automatically leverages CUDA for faster training.
  • D. Use a cluster with autoscaling enabled and a minimum of 2 workers, so Spark can distribute the training data.
Explanation

Scikit-learn is a single-node library that runs entirely on the driver node and does not distribute computation across Spark workers. For small datasets, a single-node cluster (driver only, zero workers) is sufficient and cost-effective. Option B is wrong because scikit-learn cannot distribute model training to Spark executors. Option C is wrong because scikit-learn does not natively support CUDA/GPU acceleration. Option D is wrong for the same reason as B — autoscaling workers provides no benefit for scikit-learn training.

53 more questions in this domain

Practice the full bank with instant grading, flashcards, and a timed mock exam.

Start practicing free