Workload monitoring with ML Diagnostics
Workload Monitoring is a built-in capability within the ML Diagnostics platform to detect and diagnose issues affecting AI/ML workloads running on TPUs on Google Cloud. For every Google Kubernetes Engine (GKE) job, ML Diagnostics Workload monitoring automatically creates an ML run and monitors TPU duty cycle across the workload to detect events that affect workload performance.
Key features
ML Diagnostics workload monitoring includes the following generally available features:
- Workload-to-node mapping: Automatically identify the Google Cloud nodes your workload is using. This is available by default for all TPU workloads on GKE.
- Status tracking: Monitor workload statuses for multiple states,
including
performance degradation,hang,orchestrator interruption, andtermination. - Metric-based problem detection: Detect workload problems (performance degradation, hangs, orchestrator interruption, and terminations) by monitoring the Aggregated TPU duty cycle. By default, a 15% drop in duty cycle indicates a performance degradation and triggers analysis. For other events, other indicators are used to detect hangs, orchestrator interruptions, and terminations.
- Automated diagnosis: If a problem is detected, automated analyzers run
to find potential infrastructure, orchestrator, or framework causes.
Analyzers include:
- Infrastructure: ICI Link, Thermal, TPU throttling, HBM capacity, HBM bandwidth, Host memory utilization, CPU utilization, ToR uplink congestion, ToR NIC link, ToR NIC link FEC error.
- Orchestrator: GKE nodepool interruption, GKE slice interruption.
- Framework: Megascale XLA hang, Megascale network transfer latency, PyGrain, Orbax async checkpointing.
- Issue localization: Pinpoint the specific nodes and instances affected by detected issues.
- Suggested actions: Recommended steps for recovery or further investigation, such as restarting a job, removing a potentially faulty node, or collecting XProf profiles.
- Event timeline: Display a timeline of workload events alongside the TPU duty cycle metric to help correlate events with metric time series.
- Analysis details: Detailed reports for analyzers run for each event.
- System metrics: System metrics are recorded automatically at 1-minute
intervals for every workload monitoring ML Run. These system metrics provide
additional information to correlate with workload events for deeper
analysis. System metrics include:
- TPU device: duty cycle, tensorcore utilization.
- Host device: host CPU utilization, host memory utilization.
- HBM: memory bandwidth utilization, HBM memory total, HBM memory used.
- Megascale XLA: MXLA DCN transfer latency, MXLA inbound transfer latency, MXLA compute latency, MXLA e2e collective latency, MXLA d2h latency, MXLA h2d latency.
ML Diagnostics Workload Monitoring also includes the following preview feature:
- Automatic profile capture: Automatically capture an XProf profile when a
performance degradation event is detected and one of the analyzers is
triggered in a
"bad"state. Analyzers covered by this feature include Host Memory Utilization, HBM Capacity, HBM Bandwidth, CPU Utilization, PyGrain, Orbax Async Checkpointing, Thermal, TPU Throttling, ICI Link, ToR Uplink Congestion, ToR NIC Link, ToR NIC Link FEC Error, and Megascale Network Transfer Latency.
Prerequisites
To use ML Diagnostics workload monitoring, enable the Cluster Director API and add the required IAM permissions. For more information, see ML Diagnostics prerequisites.
Get started
When you submit your TPU job on GKE, the ML Diagnostics system automatically begins tracking your workload without requiring any manual code instrumentation. Diagnostic information is displayed in the ML Diagnostics Google Cloud console and can be retrieved using the ML Diagnostics CLI or API. Diagnostic information is listed for each Machine Learning Run (ML run).
Workload monitoring is automatically enabled for GKE versions 1.36.4-gke.1247000 and later. Megascale XLA hang and Megascale XLA metrics are available with LibTPU versions 0.40.0 and later.
Workload monitoring analyzers
ML Diagnostics continuously monitors your workload performance by monitoring TPU duty cycle and how it relates to the underlying infrastructure. By default, a 15% drop in duty cycle indicates a performance degradation and triggers analysis. For other events, other indicators are used to detect hangs, orchestrator interruptions, and terminations.
The workload states are tracked automatically and assigned one of the following values:
running: The workload is actively executing. This state is not directly displayed in the Google Cloud console.termination: The workload terminated and is no longer running. This can be due to an expected orchestrator interruption (which results in a restart), a successful completion, or a failed job.hang: Detected by a prolonged period of minimal to no TPU activity without workload completion.performance degradation: Triggered by a significant drop in performance metrics like aggregated TPU duty cycle.orchestrator interruption: Detected GKE interruption of the orchestrator. This includes slice interruptions for TPU7x (Ironwood), and nodepool interruptions for earlier versions.
For problems detected in the workload, ML Diagnostics triggers a set of analyzers to help diagnose potential problems with the workload at the infrastructure, orchestrator, and framework layers. These analyzers identify infrastructure, orchestrator, or framework problems, pinpoint which nodes are affected, and suggest troubleshooting steps.
ICI Link Analyzer
The ICI Link Analyzer detects issues with the Inter-Chip Interconnect (ICI) links that connect TPUs within a slice. This analyzer detects potential ICI networking issues on the links between TPU processors. The analyzer locates the specific nodes on which the problematic workloads are running.
The ICI Link Analyzer uses the following metrics and detection criteria:
- Metric used: Internal ICI link status metric.
- Detection criteria: The analyzer counts how many times each active ICI port on a TPU host disconnects and reconnects (link flaps) over the last five minutes, ignoring disabled ports. If the port with the highest flap count on any host exceeds 50 flaps in 5 minutes, the analyzer reports a "bad" state and lists the specific nodes affected.
Thermal Analyzer
The Thermal Analyzer monitors and detects TPU nodes that are overheating. Excessive temperatures can negatively affect workload performance. The analyzer identifies the specific nodes experiencing thermal problems, which can be caused by overheating in the tensor cores or High Bandwidth Memory (HBM).
The Thermal Analyzer uses the following metrics and detection criteria:
- Metric used: Internal TPU thermal metric.
- Detection criteria: For each TPU host, the analyzer finds the maximum temperature of the HBM and TensorCore sensors over 5 minutes intervals. If the HBM maximum exceeds 75°C or the TensorCore maximum exceeds 95°C, the analyzer reports a "bad" state and writes a list of the affected resources to the details field of the AnalyzerReport message.
TPU Throttling Analyzer
The TPU Throttling Analyzer detects when TPU chip throttling occurs. This can be due to power, thermal, or other hardware constraints. The analyzer pinpoints the specific nodes where throttling is occurring.
The TPU Throttling Analyzer uses the following metrics and detection criteria:
- Metric used: Internal TPU chip counter metric.
- Detection criteria: For each TPU chip, the analyzer computes the
percentage of clock cycles skipped over the last 1 minute (
clocks_skipped / cycle_count). If any chip's total exceeds the warning threshold of 10% of cycles skipped, the analyzer reports a"bad"state and lists the specific nodes affected.
HBM Capacity Analyzer
The HBM Capacity Analyzer monitors the High Bandwidth Memory (HBM) utilization of TPU nodes. This analyzer detects TPU nodes where HBM utilization is either approaching the limit (around 90%) or causing out-of-memory (OOM) errors. Potential troubleshooting actions include collecting XProf profiling traces for detailed HBM memory usage analysis. You should also consider modifying workload configurations to optimize HBM usage, such as reducing the batch size or adjusting model parameters.
The HBM Capacity Analyzer uses the following metrics and detection criteria:
- Metric used:
node/accelerator/memory_total - Detection criteria: For each container in the workload, the analyzer
computes accelerator (HBM) memory used divided by total memory over 1
minute. If any container exceeds the threshold of 95%, the analyzer reports
a
"bad"state and lists the specific nodes affected. If your workload is close to using all HBM capacity, you run the risk of OOM errors.
HBM Bandwidth Analyzer
The HBM Bandwidth Analyzer detects TPU instances where high bandwidth memory (HBM) is being throttled, which indicates that HBM operations are being restricted. This is likely due to bandwidth limits or hardware issues, like high TPU chip temperature. The analyzer pinpoints the specific instances where throttling is occurring.
The HBM Bandwidth Analyzer uses the following metrics and detection criteria:
- Metric used: Internal HBM hardware counters.
Detection criteria: For each TPU chip over the last 5 minutes, the analyzer computes two ratios:
- Read throttling:
read_bytes_throttle / bytes_read - Write throttling:
write_bytes_throttle / bytes_written
A ratio is computed only when more than 1 MiB of traffic flows in that direction. If either ratio reaches the threshold of 5% of bytes throttled, the analyzer reports a
"bad"state and lists the specific nodes affected. HBM bandwidth is throttled, typically because the chip temperature is high.- Read throttling:
Host Memory Utilization Analyzer
The Host Memory Utilization Analyzer monitors the non-evictable host memory utilization of TPU nodes and instances. This analyzer detects TPU instances where non-evictable host memory utilization is running close to its limit, which can degrade performance and increase the risk of Out-of-Memory (OOM) events. This can be caused by excessive prefetching or buffering in the data pipeline, temporary RAM spikes during checkpoint operations, or memory leaks in custom loaders. For GKE workloads, see GKE best practices for identifying workloads and configuring appropriate memory requests and limits.
The Host Memory Utilization Analyzer uses the following metrics and detection criteria:
- Metric used:
node/memory/allocatable_utilization - Detection criteria: For each container, the analyzer computes
non-evictable host RAM used divided by the container memory limit over 1
minute. If any container exceeds the threshold of 95%, the analyzer reports
a
"bad"state and lists the specific nodes affected.
CPU Utilization Analyzer
The CPU Utilization Analyzer monitors the host CPU utilization of TPU nodes and instances. This analyzer detects TPU instances where host CPU utilization is running close to the allocated limit. This can negatively impact application performance, potentially causing slowdowns or unresponsiveness. Potential troubleshooting actions include using Cloud Profiler for detailed CPU usage analysis. For GKE workloads, see GKE best practices for identifying workloads and configuring appropriate memory requests and limits.
The CPU Utilization Analyzer uses the following metrics and detection criteria:
- Metric used:
node/cpu/allocatable_utilization - Detection criteria: For each container, the analyzer computes the CPU
usage rate divided by the CPU limit over 1 minute. If any container exceeds
the threshold of 100%, the analyzer reports a
"bad"state and lists the specific nodes affected, indicating that the CPU is at or over its allocated limit, which can starve the input pipeline or the host runtime.
ToR NIC Link Analyzer
The ToR NIC Link Analyzer detects networking issues on Top-of-Rack (ToR) switch and Network Interface Card (NIC) links. The analyzer locates the specific instances on which the problematic workloads are running.
The ToR NIC Link Analyzer uses the following metrics and detection criteria:
- Metric used: Internal ToR-NIC link networking metrics.
- Detection criteria: The analyzer maps each workload node to its rack and
ToR switch. It fetches internal network flapping alerts for those ToR
switches over the last 20 minutes and sums the flap count per host
NIC-to-ToR link. It keeps links at or above the threshold (top 10), and only
those whose host NIC interface is actively carrying traffic. If any link
remains, the analyzer reports a
"bad"state and lists the specific nodes affected.
ToR Uplink Congestion Analyzer
The ToR Uplink Congestion Analyzer detects issues with ToR switches experiencing network path congestion. This analyzer indicates high utilization on specific uplink ports. The analyzer locates the specific instances on which the congestion is happening.
The ToR Uplink Congestion Analyzer uses the following metrics and detection criteria:
- Metric used: Internal ToR link networking metrics.
- Detection criteria: The analyzer maps each workload node to its physical
cell and rack. The rack is derived from the node's underlying hostname. For
each rack, it collects the effective utilization of the ToR switch's uplinks
(ToR to middle block) over the last 10 minutes. If any rack exceeds the
threshold of 80%, the analyzer reports a
"bad"state and lists the affected instances.
ToR NIC Link FEC Error Analyzer
The ToR NIC Link FEC Error Analyzer detects ToR switch and NIC link Forward Error Correction (FEC) errors on network interfaces. This analyzer indicates physical optical network link signal degradation or noise, or issues with host transceivers that aren't correctable by FEC capability in network cards, causing physical frame drops or CRC checksum errors. The analyzer locates the specific instances on which the errors are detected.
The ToR NIC Link FEC Error Analyzer uses the following metrics and detection criteria:
- Metric used: Internal kernel NIC metric.
- Detection criteria: For each host NIC interface, the analyzer computes
the per-second rate of FEC uncorrectable codewords over the last 5 minutes.
If any interface reaches the threshold of 0.01 uncorrectable codewords per
second, the analyzer reports a
"bad"state, which points to degradation of the optical link or the host transceiver.
Orbax Async Checkpointing Analyzer
The Orbax Async Checkpointing Analyzer detects if Orbax asynchronous checkpointing is taking too long or stalling. This indicates that either the total time spent blocking the main training thread has exceeded 20% of the last 5 minutes, or checkpoints have started but stalled without completing the blocking portion of the save.
The Orbax Async Checkpointing Analyzer uses the following metrics and detection criteria:
- Metrics used:
/jax/checkpoint/write/async/blocking_duration_secs,/jax/orbax/write/async/start - Detection criteria: The analyzer reports a
"bad"state if either of the following conditions is true:- Blocking too long: The main training thread was blocked by asynchronous checkpointing for at least 20% of the last 5 minutes (60 seconds or more).
- Checkpoint stalled: The analyzer looks back 1 hour minute by minute. There has been no checkpoint activity in the last 2 minutes, and the most recent active minute shows more asynchronous saves started than blocking phases completed (a save began and never finished).
PyGrain Analyzer
The PyGrain Analyzer detects high PyGrain data loading latency. This indicates that the host CPU is spending excessive time waiting for data to be loaded or preprocessed before feeding it to the TPU, causing training to block. This can be caused by I/O bottlenecks, inefficient data pipeline configurations, or cross-region network delays.
The PyGrain Analyzer uses the following metrics and detection criteria:
- Metric used:
/grain/python/dataset/next_duration_ns - Detection criteria: For each container, the analyzer measures total time
spent in Grain's
DatasetIterator.nextover the last 1 minute (the time the training loop spent waiting for input data). If that time exceeds the threshold of 30 seconds, the analyzer reports a"bad"state, indicating that the job is input-bound on the Grain pipeline.
Megascale Network Transfer Latency Analyzer
The Megascale Network Transfer Latency Analyzer detects high Megascale network transfer latency. This indicates that network slowness was detected during host-to-host (DCN), host-to-device (H2D), or device-to-host (D2H) transfers. As a result, some instances lag behind as stragglers and stall the overall workload.
The Megascale Network Transfer Latency Analyzer uses the following metrics and detection criteria:
- Metrics used:
container/multislice/network/dcn_transfer_latencies,container/multislice/network/collective_end_to_end_latencies,container/multislice/accelerator/device_to_host_transfer_latencies,container/multislice/accelerator/host_to_device_transfer_latencies Detection criteria: For multislice workloads, the analyzer runs four checks comparing every container against the cluster as a whole:
- Collective barrier inversion: Flags a container whose median (P50) collective end-to-end latency is below 0.5 times the cluster median. A slice waiting noticeably less is likely the slow one that others are waiting on.
- DCN transfer latency: Flags a container whose P95 DCN transfer latency is above 2.5 times the cluster median and above an absolute noise floor.
- Host-to-device (H2D) transfer latency: Flags a container whose P95 H2D transfer latency is above 2.5 times the cluster median and above an absolute noise floor.
- Device-to-host (D2H) transfer latency: Flags a container whose P95 D2H transfer latency is above 2.5 times the cluster median and above an absolute noise floor.
For the transfer latency checks, the analyzer keeps the top 10 streams over 15 minutes. If any check triggers, the analyzer reports a
"bad"state and lists the affected instances.
GKE Orchestrator Slice Interruption Analyzer
The GKE Orchestrator Slice Interruption Analyzer detects slice-level interruption events at the GKE orchestrator layer. When a slice interruption is detected, the analyzer identifies the affected slice and pinpoints the underlying sub-block as the potential root cause of the interruption. This analyzer works at the level of each slice in the workload, so you get slice interruption events for each slice individually.
GKE Orchestrator Nodepool Interruption Analyzer
The GKE Orchestrator Nodepool Interruption Analyzer detects nodepool interruption events occurring at the GKE orchestrator layer. For TPU generations TPU v6e (Trillium) and before, GKE does not register a unified "Slice" resource. It only registers standard, individual Compute Engine VMs (nodes) bound together as nodepools.
When a node goes down due to a planned interruption (maintenance, preemption, or
host error) or an unplanned failure, GKE automatically applies
taints (like node.kubernetes.io/unreachable) and changes the node's condition
to NotReady. The Nodepool Interruption analyzer uses these indicators to
detect orchestrator interruptions.
Megascale XLA (MXLA) Hang Analyzer
The Megascale XLA (MXLA) Hang Analyzer detects hangs affecting multi-slice TPU
workloads at the MXLA framework layer. Cloud TPU multi-slice environments are
composed of multiple TPU slices that communicate over the Data Center Network
(DCN). Multi-slice workloads use Megascale collectives to communicate over DCN.
A Megascale hang occurs when a worker has waited on a Megascale communication
operation for a set timeout period. In these cases, you receive a Megascale
HANG_DETECTED message in your Cloud TPU logs.
The analyzer typically detects and reports hangs, since it is responsible for
communicating over DCN. However, this does not necessarily mean that the error
is caused by Megascale. Often, hang detection is a symptom of a problem in
another part of the system. For this reason, the Megascale HANG_DETECTED
message is a catch-all indication that a workload is not progressing properly.
This could be caused by third-party software, Google-owned software, or an issue
with the hardware itself.
Rather than manually going through user logs, this analyzer is automatically triggered when hangs occur and provides analyzer reports on potential causes of the hang within the ML Diagnostics system. The analyzer identifies the following potential causes:
BAD_TPU_CHIP: The MXLA hang was likely caused by a TPU tensorcore issue. The analyzer also reports the specific instances that are showing issues.BAD_SC_CHIP: The MXLA hang was likely caused by a TPU sparsecore issue. The analyzer also reports the specific instances that are showing issues.NETWORKING_ISSUE: The MXLA hang was likely caused by a networking issue in the DCN. The analyzer also reports the specific instances that are showing issues.DIFFERENT_MODULE: The MXLA hang was likely caused by running different HLO modules on different VMs. To identify the cause, inspect the digest printed by the analyzer in the logs.FINGERPRINT_MISMATCH: The MXLA hang was likely caused by inconsistent HLO module compilation across VMs. This is likely a bug in JAX tracing or the XLA compiler. To identify the cause, inspect the digest printed by the analyzer in the logs. Dump your HLO and share the output with the Google XLA compiler team to further debug. For more, see Dump HLO Computations.DATA_INPUT_STALL: The MXLA hang was likely caused by a data input stall. The analyzer also reports the specific instances that are showing issues.ICI_ERROR: The MXLA hang was likely caused by an ICI error. The analyzer also reports the specific instances that are showing issues.PROGRAM_NOT_QUEUED: The MXLA hang was likely caused by a VM not queuing programs to the TPU. Check if your application is blocked or crashing, which prevents JAX from queuing the next TPU program (jitted functions).LAUNCHES_ORDER_INCONSISTENT: The MXLA hang was likely caused by an inconsistent launch order across VMs. To identify the cause, inspect the digest printed by the analyzer in the logs.UNRECOVERABLE_ERROR: The MXLA hang was caused by an unrecoverable error. The analyzer also reports the specific instances that are showing issues. Inspect the error logs of the instances with unrecoverable errors. If the error appears to be specific to the given machine (for example, failure to copy data from TPU to host), then you need to configure your job to avoid those hosts. If the error logs don't indicate this is related to a given machine, then the problem is likely at the application level.UNKNOWN: The MXLA hang was detected but a potential cause is not determined.
System metrics
For every workload monitoring ML run, system metrics are automatically collected by Cloud Monitoring at 1-minute intervals. These system metrics provide additional information to correlate with workload events and for deeper analysis alongside the analyzer results. The system metrics include:
- TPU device metrics: duty cycle (
node/accelerator/duty_cycle), tensorcore utilization (node/accelerator/tensorcore_utilization). - Host device metrics: host CPU utilization
(
node/cpu/allocatable_utilization), host memory utilization (node/memory/allocatable_utilization). - HBM metrics: memory bandwidth utilization
(
node/accelerator/memory_bandwidth_utilization), HBM memory total (node/accelerator/memory_total), HBM memory used (node/accelerator/memory_used). - MXLA metrics for multi-slice workloads: MXLA DCN transfer latency
(
container/multislice/network/dcn_transfer_latencies), MXLA inbound transfer latency (container/multislice/network/dcn_inbound_transfer_latencies), MXLA compute latency (container/multislice/accelerator/compute_latencies), MXLA e2e collective latency (container/multislice/network/collective_end_to_end_latencies), MXLA d2h latency (container/multislice/accelerator/device_to_host_transfer_latencies), MXLA h2d latency (container/multislice/accelerator/host_to_device_transfer_latencies).
For information on system metrics, see GKE system metrics.
To log system metrics at finer-grained intervals, use the ML Diagnostics SDK and
set log_system_metrics=true. For a list of system metrics logged at the
10-second interval by the SDK, see the ML Diagnostics
(google-cloud-mldiagnostics)
SDK
documentation. By default, system metrics collected at the 1-minute interval are
automatically pulled into the ML Diagnostics system.
Automatic XProf profile capture (Preview)
ML Diagnostics can automatically capture an
XProf profile when a performance degradation
analyzer reports a "bad" state. Instead of waiting for you to view the
analyzer result and manually trigger an on-demand profile capture, automatic
profile capture records a profile when the degradation occurs. This helps you
accurately diagnose the root cause of the event using a profile captured at the
time of the issue.
The automatic profile capture is either an on-demand capture or a continuous profiling snapshot. The two differ in the time window they capture:
- On-demand capture (default): records forward in time, starting when the event occurs.
- Continuous profiling snapshot: saves the most recent 2GB of data from the continuous profiling buffer. This covers the time leading up to the event. Only available if continuous profiling is enabled.
Prerequisites
To use automatic profile capture, start an XProf server on port 9999 in your
workload so that it can listen for profile capture triggers. You can start the
XProf server in either of the following ways:
Directly in your workload code: Call the
profiler.start_servermethod on port9999:profiler.start_server(port=9999)ML Diagnostics SDK: Set
on_demand_xprof=Truewhen defining yourmachinelearning_run.
Automatic managed XProf and storage provisioning
When automatic profile capture runs for the first time, the ML Diagnostics platform automatically provisions the required profiling and storage resources if they aren't already configured:
- Managed XProf instance: Since workload monitoring doesn't enable managed XProf by default, the ML Diagnostics platform automatically provisions and enables one managed XProf instance in your project the first time a profile session is triggered for automatic capture.
- Cloud Storage bucket: Capturing and storing XProf profiles requires a
Cloud Storage bucket associated with the ML run. If a
Cloud Storage bucket isn't specified for the ML run, the ML Diagnostics
platform automatically provisions a regional bucket in your project using
the format
gs://diagon-PROJECT_NUMBER-REGION-01(incrementing the suffix from01to99, if needed).
To configure a custom Cloud Storage bucket path for an ML run, update the
ML run by sending the following PATCH request:
PROJECT_ID="PROJECT_ID"
LOCATION="LOCATION"
RUN_ID="RUN_ID"
BASE_URL="https://hypercomputecluster.googleapis.com/v1alpha/projects/${PROJECT_ID}/locations/${LOCATION}"
curl -s -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"${BASE_URL}/machineLearningRuns/${RUN_ID}?updateMask=artifacts" \
-d '{
"artifacts": {
"gcsPath": "gs://BUCKET_NAME/runs/RUN_ID"
}
}' | jq .
Replace the following:
PROJECT_ID: your Google Cloud project ID.LOCATION: the region of your ML run.RUN_ID: the ID of your ML run.BUCKET_NAME: the name of your Cloud Storage bucket.
You can also update the Cloud Storage bucket attached to the ML run by using the Google Cloud CLI:
gcloud alpha mldiagnostics machine-learning-run update RUN_ID \
--location="LOCATION" \
--gcs-path="gs://BUCKET_NAME/runs/RUN_ID" \
--etag="ETAG"
Replace the following:
RUN_ID: the ID of your ML run.LOCATION: the region of your ML run.BUCKET_NAME: the name of your Cloud Storage bucket.ETAG: the latest ETag value for the ML run resource, which you can retrieve withgcloud alpha mldiagnostics machine-learning-run describe.
For the full list of required update flags and more information about managing ML runs, see Get started with the ML Diagnostics CLI.
Configure automatic profile capture
Automatic profile capture is enabled by default for new ML runs after your project is added to the allowlist. You can turn it on or off at any time in the Google Cloud console or by using the REST API.
Google Cloud console
To turn automatic profile capture on or off in the Google Cloud console, complete the following steps:
- In the Google Cloud console, go to Cluster Director or GKE > AI/ML > Run Diagnostics, and select your ML run.
- Open the Monitoring overview tab.
- Click the Enable/Disable auto-capture toggle on the top of the events table to turn automatic profile capture On or Off.
REST API (curl)
You can use the REST API to disable automatic profile capture or customize its settings for an ML run.
To disable automatic profile capture on an ML run, send the following PATCH
request with enabled set to false:
PROJECT_ID="PROJECT_ID"
LOCATION="LOCATION"
RUN_ID="RUN_ID"
BASE_URL="https://hypercomputecluster.googleapis.com/v1alpha/projects/${PROJECT_ID}/locations/${LOCATION}"
curl -s -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"${BASE_URL}/machineLearningRuns/${RUN_ID}?updateMask=auto_capture_settings" \
-d '{
"autoCaptureSettings": {
"enabled": false
}
}' | jq .
Replace the following:
PROJECT_ID: your Google Cloud project ID.LOCATION: the region of your ML run.RUN_ID: the ID of your ML run.
To enable automatic profile capture and customize its configuration on an ML
run, send the following PATCH request:
PROJECT_ID="PROJECT_ID"
LOCATION="LOCATION"
RUN_ID="RUN_ID"
BASE_URL="https://hypercomputecluster.googleapis.com/v1alpha/projects/${PROJECT_ID}/locations/${LOCATION}"
curl -s -X PATCH \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"${BASE_URL}/machineLearningRuns/${RUN_ID}?updateMask=auto_capture_settings" \
-d '{
"autoCaptureSettings": {
"enabled": true,
"defaultDuration": "10s",
"captureType": "SNAPSHOT_OVER_ON_DEMAND",
"defaultProfilerTargets": [
"projects/${PROJECT_ID}/locations/${LOCATION}/machineLearningRuns/${RUN_ID}/profilerTargets/node-0",
"projects/${PROJECT_ID}/locations/${LOCATION}/machineLearningRuns/${RUN_ID}/profilerTargets/node-1"
],
"hostTracerLevel": "HOST_TRACER_LEVEL_INFO",
"deviceTracerLevel": "DEVICE_TRACER_LEVEL_ENABLED",
"pythonTracerLevel": "PYTHON_TRACER_LEVEL_DISABLED",
"maxSessionCountPerEvent": 100
}
}' | jq .
Replace the following:
PROJECT_ID: your Google Cloud project ID.LOCATION: the region of your ML run.RUN_ID: the ID of your ML run.
The following table describes the autoCaptureSettings fields:
| Field | Options and default | Description |
|---|---|---|
enabled |
true (default for projects on the allowlist) |
Enables automatic profile capture on the ML run. |
false |
Disables automatic profile capture on the ML run. | |
defaultDuration |
10s (default) |
Capture duration for ON_DEMAND sessions. |
captureType |
SNAPSHOT_OVER_ON_DEMAND (default) |
Takes a continuous profiling snapshot first; falls back to on-demand capture if continuous profiling is inactive. |
ON_DEMAND_OVER_SNAPSHOT |
Feature not supported. | |
ONLY_ON_DEMAND |
Captures only an on-demand session. | |
ONLY_SNAPSHOT |
Captures only a continuous profiling snapshot. | |
defaultProfilerTargets |
All targets in the ML run (default) | Profiles all target nodes when the analyzer report doesn't specify affected hosts. |
Custom ProfilerTarget list |
Profiles only the specified subset of nodes when the analyzer report doesn't specify affected hosts. | |
hostTracerLevel |
HOST_TRACER_LEVEL_INFO (default) |
Standard host CPU step and operation events. |
HOST_TRACER_LEVEL_CRITICAL |
Essential host events only (lowest overhead). | |
HOST_TRACER_LEVEL_VERBOSE |
Detailed host CPU trace events. | |
HOST_TRACER_LEVEL_DISABLED |
No host CPU tracing. | |
deviceTracerLevel |
DEVICE_TRACER_LEVEL_ENABLED (default) |
Traces TPU or GPU device execution. |
DEVICE_TRACER_LEVEL_DISABLED |
No device tracing. | |
pythonTracerLevel |
PYTHON_TRACER_LEVEL_DISABLED (default) |
No Python tracing (avoids runtime overhead). |
PYTHON_TRACER_LEVEL_ENABLED |
Traces Python function calls on the host. | |
maxSessionCountPerEvent |
500 (default) |
Maximum auto-captured sessions allowed per
MonitoredEvent. |
Note the following behavior when configuring autoCaptureSettings:
- Snapshot compared to on-demand settings:
defaultDuration,hostTracerLevel,deviceTracerLevel, andpythonTracerLevelapply only when automatic profile capture triggers an on-demand (KIND_ON_DEMAND) session. When automatic profile capture takes a snapshot (KIND_SNAPSHOT), it inherits the tracer levels and XProf port from the active continuous profiling session. - Snapshot target filtering: When capturing a snapshot, ML Diagnostics
profiles the intersection of the target nodes (the affected nodes from the
analyzer report, or
defaultProfilerTargetsif none are specified) and the nodes in the active continuous profiling session.
View captured profiles
When automatic profile capture is enabled, ML Diagnostics automatically captures
an XProf profile whenever a performance degradation event is detected and one of
the following analyzers reports a "BAD" state and recommends collecting an
XProf profile:
- Infrastructure analyzers: CPU Utilization, HBM Bandwidth, HBM Capacity, Host Memory Utilization, ICI Link, Thermal, ToR NIC Link, ToR NIC Link FEC Error, ToR Uplink Congestion, and TPU Throttling.
- Framework analyzers: Megascale Network Transfer Latency, Orbax Async Checkpointing, and PyGrain.
You can view automatically captured profiles in the Google Cloud console or by using the gcloud CLI and REST API:
- Google Cloud console: On the workload monitoring page, click View details for the associated performance degradation event to open the analyzer report, and then click the link to the captured profile session.
gcloud CLI and REST API: List the
monitored-eventsfor the ML run to find the performance degradation event, and then describe the event to get the analyzer report and the profile session resource name:PROJECT_ID="PROJECT_ID" LOCATION="LOCATION" RUN_ID="RUN_ID" BASE_URL="https://hypercomputecluster.googleapis.com/v1alpha/projects/${PROJECT_ID}/locations/${LOCATION}" # 1. List MonitoredEvents on the ML run to get the EVENT_ID: gcloud alpha mldiagnostics monitored-events list \ --machine-learning-run="${RUN_ID}" \ --location="${LOCATION}" \ --project="${PROJECT_ID}" # 2. Describe a specific MonitoredEvent to inspect analyzerReports[].autoCaptureDetails[]: EVENT_ID="EVENT_ID" gcloud alpha mldiagnostics monitored-events describe "${EVENT_ID}" \ --machine-learning-run="${RUN_ID}" \ --location="${LOCATION}" \ --project="${PROJECT_ID}" \ --format="json(name,type,analyzerReports[].analyzer,analyzerReports[].autoCaptureDetails)" # 3. List only auto-captured ProfilerSessions and their linked MonitoredEvents: curl -s -H "Authorization: Bearer $(gcloud auth print-access-token)" \ "${BASE_URL}/machineLearningRuns/${RUN_ID}/profilerSessions" \ | jq '.profilerSessions[] | select(.autoCaptured == true) | {name, kind, state, dashboardUri, monitoredEvents}'Replace the following:
PROJECT_ID: your Google Cloud project ID.LOCATION: the region of your ML run.RUN_ID: the ID of your ML run.EVENT_ID: the ID of theMonitoredEventresource.
For more information about using the CLI, see Get started with the ML Diagnostics CLI.
View Workload Monitoring in Google Cloud console
You can view your runs monitored by ML Diagnostics workload monitoring in the Google Cloud console under both Cluster Director and GKE.
Google Cloud console under both Cluster Director and GKE.
- In the Google Cloud console, go to the Cluster Director page.
- Click the Run Diagnostics tab.
Go to Cluster Director Run Diagnostics
To view all your machine learning runs in Google Kubernetes Engine:
- In the Google Cloud console, go to the Kubernetes page.
- In the navigation menu, click AI/ML.
- Click the Run Diagnostics tab.
Go to GKE AI/ML Run Diagnostics
The Cluster Director and GKE consoles display the following information:
Run Summaries: The table contains the name of each run created by Workload Monitoring for a GKE job. Runs are automatically named using the
job-name-timestampformat.Run Details (Monitoring Overview): Select an ML run to see detailed information within the "Monitoring Overview" tab. This tab contains:
- Aggregated TPU duty cycle: A graph of the aggregated TPU duty cycle for your ML run.
- Events timeline: A timeline of all events that have affected the ML run, including performance degradations, hangs, orchestrator interruptions, and terminations.
- Events Table: This table summarizes events that affected the ML run.
For each event, it includes:
- Event name and event type.
- Start time and end time of event.
- Links to details from analyzers.
- Event Details: Select View details for an event to see all analyzer results for that event.
- System metrics: A list of system metrics pulled automatically at a 1-minute interval from Cloud Monitoring or logged at a more granular level by the ML Diagnostics SDK.
Access workload monitoring information through gcloud CLI
For every GKE job, Workload Monitoring automatically creates a
Machine Learning Run within ML Diagnostics with an ML run name using the
job-name-timestamp format. You can use ML Diagnostics gcloud CLI
commands such as Describe, List, Delete, and Update to view all ML runs
created in a project, get details of those runs, and delete or update properties
of the ML run.
In addition, you can use monitored-events gcloud CLI commands to
list all the events detected by workload monitoring and retrieve analyzer
details of each event. For more information, see Get started with the ML
Diagnostics CLI.
Access Workload Monitoring information through the API
You can access the events detected by Workload Monitoring through the GET
method for the MonitoredEvent API.
List all monitored events
To list all monitored events (MonitoredEvent) for a given ML run, use the
"GET" method with the
/v1alpha/{parent=projects/*/locations/*/machineLearningRuns/*}/monitoredEvents
endpoint.
The following is an example request:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://hypercomputecluster.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/machineLearningRuns/ML_RUN_ID/monitoredEvents"
Replace the following:
PROJECT_ID: your Google Cloud project ID.LOCATION: the region of your ML run.ML_RUN_ID: the ID of your ML run.
The output is a ListMonitoredEventsResponse object, which is a JSON object
that contains a list of MonitoredEvent summaries. The summaries provide an
overview of event timestamps and details.
The following is an example of a ListMonitoredEventsResponse object:
{
"monitoredEvents": [
{
"name": "projects/user-project-id/locations/us-central1/machineLearningRuns/my-tpu-job-20260327T073000/monitoredEvents/event-id-456",
"type": "PERFORMANCE_DEGRADATION",
"displayName": "Performance degradation - 2026-03-27T07:45:10Z ",
"startTime": "2026-03-27T07:45:10Z",
"endTime": "2026-03-27T08:00:00Z",
"analyzerReports": [
{
"analyzer": "TPU Throttling Analyzer",
"detectionState": "NOT_DETECTED"
}
// ... additional analyzer reports
]
},
{
"name": "projects/user-project-id/locations/us-central1/machineLearningRuns/my-tpu-job-20260327T073000/monitoredEvents/event-id-123",
"type": "PERFORMANCE_DEGRADATION",
"displayName": "Performance degradation - 2026-03-27T07:35:00Z ",
"startTime": "2026-03-27T07:35:00Z",
"endTime": "2026-03-27T08:15:00Z",
"analyzerReports": [
// ... analyzer reports
]
}
// ... other events
]
}
Get monitored events
To retrieve details of a specific monitored event (MonitoredEvent), send a
GET request to the
/v1alpha/{parent=projects/*/locations/*/machineLearningRuns/*}/monitoredEvents/*
endpoint.
The following is an example request:
curl -X GET \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json" \
"https://hypercomputecluster.googleapis.com/v1alpha/projects/PROJECT_ID/locations/LOCATION/machineLearningRuns/ML_RUN_ID/monitoredEvents/EVENT_ID"
Replace the following:
PROJECT_ID: your Google Cloud project ID.LOCATION: the region of your ML run.ML_RUN_ID: the ID of your ML run.EVENT_ID: the ID of theMonitoredEventresource.
The output is a MonitoredEvent object, which is a JSON object that contains
information about the specified event. The analyzerReports array within this
object contains the detailed findings, status, and suggestions from each
analyzer (ICI Link, Thermal, TPU Throttling, HBM Capacity) that was run in
response to the detected event.
The following is an example of a MonitoredEvent object:
{
"name": "projects/user-project-id/locations/us-central1/machineLearningRuns/my-tpu-job-20260327T073000/monitoredEvents/event-id-456",
"type": "PERFORMANCE_DEGRADATION",
"displayName": "Performance degradation - 2026-03-27T07:45:10Z ",
"startTime": "2026-03-27T07:45:10Z",
"endTime": "2026-03-27T08:15:00Z",
"analyzerReports": [
{
"analyzer": "ICI Link Analyzer",
"detectionState": "DETECTED",
"details": "ICI Link issues detected in <instance_ids>: This indicates networking issues on ICI links connected between TPU processors.",
"recommendedActions": [
{
"description": "Contact Google team for further diagnosis. Potential action could be to Outkast affected nodes, but there could be other causes that need further investigation.",
"documentationUrl": "https://docs.cloud.google.com/tpu/docs/ml-diagnostics/workload-monitoring"
}
]
},
{
"analyzer": "TPU Throttling analyzer",
// ... results from TPU Throttling analyzer
}
// ... other analyzer reports
]
}