SkillAgentSearch skills...

gke-ai-troubleshooting-tpu-mxla-hang

Diagnose GKE Cloud TPU multi-slice training hangs (Megascale `HANG_DETECTED` logs and hang monitored events) using the ML Diagnostics `Megascale XLA (MXLA) Hang Analyzer` (`gcloud alpha mldiagnostics monitored-events`) and 1-minute Cloud Monitoring multi-slice latency metrics (`kubernetes.io/contain…

Install / Use

npx skills add google/skills --skill gke-ai-troubleshooting-tpu-mxla-hang

Installs into whichever agent you are using.

About this skill
📄

SKILL.md

Installable skill definition

Quality Score

97/100

Category

Operations

Supported Platforms

Universal

Our assessment of gke-ai-troubleshooting-tpu-mxla-hang

gke-ai-troubleshooting-tpu-mxla-hang scores 97/100 on our quality scale, 37th of 765 Operations skills we index (top 5%).

Its SKILL.md is 15 KB long, well organised into 16 sections with 3 code examples: a thorough specification that gives an agent plenty to work with.

With 20,340 GitHub stars, it is one of the more widely adopted skills in the catalogue.

Substance
30/30
Structure
18/20
Description
15/15
Adoption
18/20
Freshness
15/15

Maintenance, license and trust

  • The repository was last updated 26 days ago, so gke-ai-troubleshooting-tpu-mxla-hang is actively maintained.
  • It is released under the Apache-2.0 license, a permissive license that allows use, modification and commercial use with attribution.
  • Its trust signals score 100/100, with no cautions. These come from repository metadata, not a code audit — read the skill file before letting an agent act on it.

gke-ai-troubleshooting-tpu-mxla-hang compared with similar skills

All 4 of these similar skills score higher than gke-ai-troubleshooting-tpu-mxla-hang; compare them before choosing.

SkillScoreStarsUpdatedFormat
gke-ai-troubleshooting-tpu-mxla-hang (this skill)by google9720.3k26d agoSKILL.md
algorithmic-artby anthropics100177.9k27d agoSKILL.md
pptxby anthropics100177.9k27d agoSKILL.md
designby nextlevelbuilder100137.2k5d agoSKILL.md
ui-ux-pro-maxby nextlevelbuilder100137.2k5d agoSKILL.md

Frequently asked questions

How do I install gke-ai-troubleshooting-tpu-mxla-hang?
Run npx skills add google/skills --skill gke-ai-troubleshooting-tpu-mxla-hang. The install tabs above show the steps for each supported agent.
Which AI agents does gke-ai-troubleshooting-tpu-mxla-hang work with?
It is written for Universal, as a SKILL.md file. Other agents that read the same format can often use it too.
Is gke-ai-troubleshooting-tpu-mxla-hang safe to use?
It is Apache-2.0-licensed and scores 100/100 on trust signals. Skills are instructions an agent will follow, so read the file before installing it and do not approve commands you do not understand.
Is gke-ai-troubleshooting-tpu-mxla-hang still maintained?
The repository was last updated 26 days ago, so gke-ai-troubleshooting-tpu-mxla-hang is actively maintained.

name: gke-ai-troubleshooting-tpu-mxla-hang description: >- Diagnose GKE Cloud TPU multi-slice training hangs (Megascale HANG_DETECTED logs and hang monitored events) using the ML Diagnostics Megascale XLA (MXLA) Hang Analyzer (gcloud alpha mldiagnostics monitored-events) and 1-minute Cloud Monitoring multi-slice latency metrics (kubernetes.io/container/multislice/*). Distinguishes XLA compiler/HLO launch divergence and host data-input stalls from TPU chip, SparseCore, ICI, or network fabric faults. Use when multi-slice TPU training jobs freeze without progressing steps, emit HANG_DETECTED, or stall in collective operations. Don't use for gradual step-time throughput drops without hangs (use gke-ai-troubleshooting-tpu-performance-degradation) or pod preemption/eviction restarts (use gke-ai-troubleshooting-jobset-interruption). metadata: version: "1.0.1" category: AiAndMachineLearning

Troubleshoot GKE TPU multi-slice hangs with the MXLA Hang Analyzer

Diagnose Cloud TPU multi-slice training hangs on Google Kubernetes Engine (GKE) by correlating Megascale HANG_DETECTED logs and ML Diagnostics Workload Monitoring Megascale XLA (MXLA) Hang Analyzer reports with 1-minute multi-slice latency metrics (kubernetes.io/container/multislice/*) and GKE node topology labels.


Attribution

MUST READ: Before executing any gcloud, REST API, or MCP command, you MUST read Usage Attribution. For commands executed directly in the terminal (never in generated scripts, Terraform, or user code), prefix gcloud with CLOUDSDK_METRICS_REQUEST_ATTRIBUTION="agent-skills/1.0 (skill:gke-ai-troubleshooting-tpu-mxla-hang)" and append agent-skills/1.0 (skill:gke-ai-troubleshooting-tpu-mxla-hang) to User-Agent headers.

Prerequisites

  • Tools: Install the Google Cloud SDK (gcloud with alpha component for gcloud alpha mldiagnostics) and kubectl.
  • Cloud Billing & Project Configuration: Verify an active billing account is linked (gcloud billing projects describe {project_id}), authenticate (gcloud auth login), set the target project (gcloud config set project {project_id}), and ensure container.googleapis.com, logging.googleapis.com, monitoring.googleapis.com, and hypercomputecluster.googleapis.com are enabled.
  • Supported workloads and versions: Google Cloud ML Diagnostics only supports JAX on TPUs (see ML Diagnostics platform). Workload Monitoring is enabled by default, supports the jobset and job GKE job types, and is compatible with GKE versions 1.36.0-gke.4681000 and later (Configure GKE for ML Diagnostics, which also covers the cluster setup needed for on-demand profiling in Step 4 Path B). If a workload uses another framework (such as PyTorch) or another custom resource type, gcloud alpha mldiagnostics won't list ML runs or monitored events for it. The Megascale XLA hang analyzer and Megascale XLA metrics require LibTPU 0.40.0 or later (see "Get started" in Workload monitoring with ML Diagnostics).
  • Required IAM Roles:
    • Cluster Director Editor (roles/hypercomputecluster.editor), the role listed in the "IAM permissions" section of ML Diagnostics platform, for the ML Diagnostics CLI and API calls in this skill (ML runs, monitored events, and on-demand profiler sessions)
    • Monitoring Viewer (roles/monitoring.viewer) for the PromQL queries in Step 2
    • Logs Viewer (roles/logging.viewer) for the Cloud Logging query in Step 1
    • Kubernetes Engine Viewer (roles/container.viewer) for the kubectl get nodes query in Step 3
    • For remediation ([High Risk] steps): Kubernetes Engine Cluster Admin (roles/container.clusterAdmin)
  • Reference Documentation:

Read-only rule: Run read-only diagnostic commands only. Never drain, delete, or re-create nodes, or run any other command that changes the cluster. Give the user any fix to apply themselves.

When you recommend a fix, link the doc section that describes it.


MXLA Hang Analyzer routing overview

A Megascale hang occurs when a multi-slice worker has waited on a Megascale communication operation for a set timeout period. The TPU logs then show a Megascale HANG_DETECTED message. HANG_DETECTED is a catch-all signal that the workload isn't progressing, and the cause can be in software or in hardware. When a hang occurs, ML Diagnostics runs the Megascale XLA (MXLA) Hang Analyzer, which reports the likely cause as a code. Consult the Megascale XLA (MXLA) Hang Analyzer section for the definition and recommended action of each code, and route by category:

  • Category A: compiler or HLO divergence (never cordon or replace nodes):
    • When the analyzer reports different HLO modules, inconsistent HLO compilation, or an inconsistent launch order across VMs (such as FINGERPRINT_MISMATCH), route to Path A: Compiler or HLO divergence.
  • Category B: host program queueing or data input stall (never cordon or replace nodes):
  • Category C: hardware or network faults on specific instances:
    • When the analyzer attributes the hang to a TPU chip, SparseCore, ICI, or DCN networking issue, or to an unrecoverable error on specific instances, route to Path C: Hardware or network faults.
  • Category D: hang signal or event exists, but the analyzer is NOT_DETECTED or reports UNKNOWN:
    • When HANG_DETECTED logs or a hang monitored event fired, but the analyzer report has detectionState: "NOT_DETECTED" or reports UNKNOWN ("The MXLA hang was detected but a potential cause is not determined"), route to Path D: No DETECTED analyzer or UNKNOWN cause.

Diagnostic workflow

Step 0: Collect context and set the investigation window [Low Risk]

Collect the target parameters. By default, query a 60-minute window `[T - 30m, T

  • 30m]around{issue_time}`:
  • {project_id}: Google Cloud project ID
  • {location}: Google Cloud region where the ML run and GKE cluster reside (for example, us-central1)
  • {cluster_name}: GKE cluster name
  • {namespace} / {workload_name}: Kubernetes namespace and JobSet/Pod prefix
  • {ml_run_id}: ML Diagnostics run ID
  • {issue_time}: Timestamp when the hang occurred (T, ISO-8601 UTC)
  • {start_time}: T - 30m
  • {end_time}: T + 30m

Step 1: Query HANG_DETECTED logs and hang events [Low Risk]

  1. Check GKE container logs for HANG_DETECTED (read-only Cloud Logging LQL): Query k8s_container logs over [{start_time}, {end_time}] to confirm HANG_DETECTED and identify the first stalled pods:
resource.type="k8s_container"
resource.labels.project_id="{project_id}"
resource.labels.cluster_name="{cluster_name}"
"HANG_DETECTED"
timestamp >= "{start_time}" AND timestamp <= "{end_time}"
  1. List active or recent ML runs: Follow the List machine learning runs section of the ML Diagnostics CLI reference (gcloud alpha mldiagnostics machine-learning-run list) to identify {ml_run_id}.
  2. List and describe hang monitored events: Follow the Monitored-events commands section (gcloud alpha mldiagnostics monitored-events list and gcloud alpha mldiagnostics monitored-events describe) or Access Workload Monitoring information through the API to inspect the Megascale XLA (MXLA) Hang Analyzer report (detectionState, details, and recommendedActions).
    • If HANG_DETECTED logs or a hang monitored event fired, run Step 2 to correlate with the 1-minute metrics; if no analyzer reports detectionState: "DETECTED" or the analyzer reports UNKNOWN, follow Path D: No DETECTED analyzer or UNKNOWN cause.
    • If no HANG_DETECTED log or hang monitored event exists and multi-slice latencies are normal in Step 2, rule out an MXLA hang by following Path E: Healthy telemetry.

Step 2: Correlate with 1-minute multi-slice and TPU metrics [Low Risk]

Consult the System Metrics section of the Workload Monitoring guide for the 1-minute multi-slice network (kubernetes.io/container/multislice/network/*), multi-slice accelerator (kubernetes.io/container/multislice/accelerator/*), and node duty-cycle (kubernetes.io/node/accelerator/duty_cycle) metrics, and run read-only PromQL queries over [{start_time}, {end_time}]:

# 1. P95 multi-slice collective end-to-end latency by pod
histogram_quantile(
  0.95,
  sum by (pod_name, le) (
    rate(kubernetes_io:container_multislice_network_collective_end_to_end_latencies_bucket{
      monitored_resource="k8s_container",
      project_id="{project_id}",
      cluster_name="{cluster_name}"
    }[5m])
  )
)

# 2. P95 multi-slice DCN transfer latency by pod
histogram_quantile(
  0.95,
  sum by (pod_name, le) (
    rate(kubernetes_io:container_multislice_network_dcn_transfer_latencies_bucket{
      monitored_resource="k8s_container",
      project_id="{project_id}",
      cluster_name="{cluster_name}"
    }[5m])
  )
)

# 3. P95 host-to-device transfer latency by pod
histogram_quantile(
  0.95,
  sum by (pod_nam

Truncated for display — read the full file on GitHub.

Related Skills

View on GitHub
GitHub Stars20.3k
CategoryOperations
Updated26d ago
Forks1.7k

Languages

Python

Trust signals

100/100

From repository metadata: license, adoption, age and documentation. Not a code audit — see the Safety scan above for what the skill file itself contains.

No cautions