MLflow’s integration with Vertex AI is surprisingly robust, allowing you to ditch local tracking entirely and push all your experiment metadata directly to Google Cloud’s managed MLflow service.

Let’s see it in action. Imagine you’re training a simple scikit-learn model.

import mlflow
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.datasets import load_iris

# Load data
iris = load_iris()
X_train, X_test, y_train, y_test = train_test_split(iris.data, iris.target, test_size=0.2, random_state=42)

# Set MLflow tracking URI to Vertex AI
# Replace 'your-gcp-project-id' and 'your-region' with your actual values
mlflow.set_tracking_uri("databricks") # This is the default for Vertex AI Managed MLflow
mlflow.set_experiment("/your-gcp-project-id/your-region/your-experiment-name") # Or use a direct path

# Start an MLflow run
with mlflow.start_run():
    # Log parameters
    params = {"solver": "liblinear", "max_iter": 100, "random_state": 42}
    mlflow.log_params(params)

    # Train a model
    model = LogisticRegression(**params)
    model.fit(X_train, y_train)

    # Log metrics
    score = model.score(X_test, y_test)
    mlflow.log_metric("accuracy", score)

    # Log the model
    mlflow.sklearn.log_model(model, "iris_classifier")

print(f"MLflow run completed. Check Vertex AI Experiments for details.")

Here’s how this connects to Vertex AI. When you set mlflow.set_tracking_uri("databricks") (which is the default endpoint Vertex AI uses for its managed MLflow), MLflow knows to communicate with Google Cloud. The mlflow.set_experiment() call then creates or points to an experiment within your Vertex AI project. All subsequent mlflow.log_params(), mlflow.log_metric(), and mlflow.log_model() calls send data directly to Vertex AI’s managed MLflow backend. This means your experiments, runs, parameters, metrics, and model artifacts are all stored and accessible through the Vertex AI console, providing a centralized, scalable, and managed environment for your ML workflows.

The core problem this solves is the operational overhead of managing your own MLflow tracking server. You don’t need to provision VMs, install MLflow, configure databases, handle backups, or worry about scaling. Vertex AI handles all of that. You get the familiar MLflow API for logging, but the backend infrastructure is fully managed by Google Cloud. This allows data scientists to focus purely on experimentation and model development, not on infrastructure maintenance. You can easily link runs to specific datasets, models, and even deployment pipelines within Vertex AI.

Under the hood, Vertex AI’s managed MLflow service uses Google Cloud Storage for artifact storage and a managed database for metadata. When you log a model, for instance, the model files are uploaded to a GCS bucket designated for your project, and the metadata (like parameters, metrics, and the path to the artifacts) is stored in the managed database. This separation ensures scalability and reliability. The mlflow.set_experiment("/your-gcp-project-id/your-region/your-experiment-name") syntax is a convention that Vertex AI uses to map your MLflow experiments to its internal project and region structure. The "databricks" URI is a legacy identifier that Vertex AI has adopted for its managed MLflow endpoint.

A subtle but crucial detail is how artifact URIs are handled when you retrieve logged models. While you might log a model using mlflow.sklearn.log_model(model, "iris_classifier"), when you retrieve it later using mlflow.sklearn.load_model("runs:/<run_id>/iris_classifier"), the underlying artifact path will point to a Google Cloud Storage location, typically something like gs://your-vertex-ai-bucket/mlflow-artifacts/your-gcp-project-id/your-region/your-experiment-name/<run_id>/artifacts/iris_classifier. MLflow, when configured with Vertex AI, automatically translates these paths to be GCS-compatible, allowing you to load models directly from cloud storage without manual intervention.

The next step is to explore how to integrate this with Vertex AI Pipelines for automated, reproducible workflows.

Want structured learning?

Take the full Mlflow course →