Configure Slurm for ML Diagnostics
You can configure the ML Diagnostics platform for machine learning (ML) workloads on Slurm clusters, including clusters managed by Cluster Director and self-managed clusters. Slurm is an open-source cluster manager and job scheduler for AI, ML, and high performance computing (HPC) workloads. Slurm automates job queuing, resource allocation, and multi-node scheduling across GPU and TPU clusters so you don't have to manage individual nodes.
Using ML Diagnostics with Slurm lets you collect workload metrics, track configurations, and capture profiles to diagnose and optimize the performance of your scheduled jobs. On Slurm clusters, ML Diagnostics supports the following features:
To enable on-demand and continuous profiling, use a Slurm prolog script to
deploy the Diagon daemon on allocated compute nodes before a job runs. The
prolog script starts the daemon automatically as a systemd service whenever
Slurm allocates a GPU or TPU node to a job.
Deploy the Diagon daemon
To deploy the Diagon daemon across your Slurm cluster, complete the steps in the following sections:
- Prepare the prolog script: create the script that
installs the daemon package from Artifact Registry and configures
diagon-daemon.serviceon compute nodes. - Add the prolog script to your cluster: configure your Cluster Director or self-managed Slurm cluster so that Slurm runs the script at job allocation.
- Verify the deployment: run a test job to confirm that the service starts and registers with the ML Diagnostics control plane.
Prepare the prolog script
The prolog script automates node-level setup so that the Diagon daemon runs on each allocated compute node to capture profiles for your jobs.
The following script authenticates with Artifact Registry, installs the
mldiagnostics-daemon package, and starts diagon-daemon.service:
#!/bin/bash
# Exit immediately if the Diagon daemon is already active on this compute node
if systemctl is-active --quiet diagon-daemon.service; then
exit 0
fi
# Authenticate Artifact Registry APT requests with the node's service account
TOKEN=$(curl -s -H "Metadata-Flavor: Google" http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/token | sed -n 's/.*"access_token":"\([^"]*\)".*/\1/p')
mkdir -p /etc/apt/auth.conf.d
echo "machine us-central1-apt.pkg.dev login oauth2accesstoken password ${TOKEN}" > /etc/apt/auth.conf.d/mldiagnostics.conf
chmod 600 /etc/apt/auth.conf.d/mldiagnostics.conf
# Configure the Artifact Registry APT repository
echo "deb [trusted=yes] https://us-central1-apt.pkg.dev/projects/hypercomputediagon-release daemon-apt main" > /etc/apt/sources.list.d/mldiagnostics-daemon.list
# Update only the Diagon repository and install mldiagnostics-daemon
apt-get -o DPkg::Lock::Timeout=60 -o Dir::Etc::sourcelist="sources.list.d/mldiagnostics-daemon.list" -o Dir::Etc::sourceparts="-" update && \
apt-get -o DPkg::Lock::Timeout=60 -o Dir::Etc::sourcelist="sources.list.d/mldiagnostics-daemon.list" -o Dir::Etc::sourceparts="-" install -y mldiagnostics-daemon
# Create the systemd service unit (the package installs the binary at
# /usr/bin/mldiagnostics_extension)
cat << 'EOF' > /etc/systemd/system/diagon-daemon.service
[Unit]
Description=Diagon Diagnostics Daemon
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
Restart=always
RestartSec=5
ExecStart=/usr/bin/mldiagnostics_extension \
-standalone=true \
-channel=hypercomputecluster.googleapis.com/diagnostics \
-alsologtostderr=true
[Install]
WantedBy=multi-user.target
EOF
# Reload systemd, start the service, and let Slurm job users read service logs
# without sudo
systemctl daemon-reload
systemctl enable --now diagon-daemon.service
chmod -R a+rX /var/log/journal /run/log/journal 2>/dev/null || true
Add the prolog script to your cluster
When you add the prolog script to your cluster, Slurm runs the script automatically on each compute node allocated to a job.
How you add the script depends on how your Slurm cluster is managed. The following sections show how to configure the prolog script for your cluster type:
- For Cluster Director clusters, you add the script to your cluster's orchestration settings in the Google Cloud console.
- For self-managed Slurm clusters, you save the script
to a shared file system and update the
/etc/slurm/slurm.conffile on the controller node.
Cluster Director clusters
To add the prolog script to a Cluster Director Slurm cluster, update your cluster's orchestration configuration:
In the Google Cloud console, go to the Cluster Director > Clusters page.
Select your cluster and click Edit.
Go to the Orchestration section and expand Advanced orchestration settings.
Under Prolog scripts (
prologBashScripts), click Add prolog script, paste the prolog script, and click Create.Click Save.
Self-managed Slurm clusters
To add the prolog script to a self-managed Slurm cluster, save the script to shared storage and reference it in your Slurm controller configuration:
- Save the prolog script to a shared file system path that all compute nodes
can access, such as
/home/slurm/diagon_prolog.sh. Make the script executable:
sudo chmod 755 /home/slurm/diagon_prolog.shOn the controller node, add the following lines to the
/etc/slurm/slurm.conffile:Prolog=/home/slurm/diagon_prolog.sh PrologFlags=AllocReload the Slurm configuration:
sudo scontrol reconfigure
Verify the deployment
Before running workloads, confirm that Slurm runs your prolog script on allocated nodes and that the Diagon daemon registers with the ML Diagnostics control plane.
From a Slurm login node, submit a test job to trigger node allocation and check
the status of diagon-daemon.service:
srun -N 1 systemctl status diagon-daemon.service --no-pager
When the daemon is active and connected to the ML Diagnostics control plane, the output includes the following log entries:
Stream established.
Received successful DaemonRegistrationResponse from backend
Sending DaemonHeartbeatRequest