A data scientist is using MLflow to log a custom PyTorch model in a Databricks notebook. They want to register the model in the Databricks Model Registry and later serve it with MLflow model serving. Which function should they call within their MLflow run to log the model with the necessary signature and dependencies?
mlflow.pytorch.log_model() is the correct function to log a PyTorch model. It saves the model in MLflow format, captures dependencies, and allows specifying a signature and input example. This enables the model to be registered in the Model Registry and served with MLflow model serving. The function is part of the MLflow PyTorch flavor and is designed for this purpose.
Why this answer
To log a PyTorch model, the correct function is mlflow.pytorch.log_model. It handles saving the model in MLflow's format, capturing dependencies and signatures, and making it available for registration and serving. Other functions either don't exist, serve different purposes, or are not flavor-specific.
Exam trap
The trap here is confusing model logging with model registration or using a non-existent generic logging function.