GKE TPU 训练性能下降诊断
gke-ai-troubleshooting-tpu-performance-degradation
使用 ML Diagnostics 工作负载监控(`gcloud alpha mldiagnostics monitored-events` / `hypercomputecluster.googleapis.com/v1alpha`)和 1 分钟粒度 Cloud Monitoring 系统指标(`kubernetes.io/node/accelerator/*`),诊断 GKE Cloud TPU 训练吞吐量下降和步时间回归(TPU 占用率下降 15% 以上)。区分硬件和网络结构限流与工作负载资源瓶颈(HBM 容量、主机内存或主机 CPU 饱和)。适用于 TPU 训练吞吐量或占用率下降但 Pod 未崩溃、`PERFORMANCE_DEGRADATION` 监控事件触发,或对多切片训练步数变慢进行分类研判时。不适用于带有 `HANG_DETECTED` 日志的多切片 XLA 完全执行停顿(使用 gke-ai-troubleshooting-tpu-mxla-hang)或 Pod 驱逐/中断重启(使用 gke-ai-troubleshooting-jobset-interruption)。
- License 许可
- Apache-2.0
- 所属仓库
- google/skills
- 最近更新
- 2026-11-14
- Stars
- ★ 2.4w
- Forks
- 2.0k
01 前言 Front Matter
- name
- gke-ai-troubleshooting-tpu-performance-degradation
- metadata
- { "version": "1.0.1", "category": "AiAndMachineLearning" }
- description
- Diagnose GKE Cloud TPU training throughput drops and step-time regressions (15%+ TPU duty-cycle drop) using ML Diagnostics Workload Monitoring (`gcloud alpha mldiagnostics monitored-events` / `hypercomputecluster.googleapis.com/v1alpha`) and 1-minute Cloud Monitoring system metrics (`kubernetes.io/node/accelerator/*`). Distinguishes hardware and network fabric throttling from workload resource bottlenecks (HBM capacity, host memory, or host CPU saturation). Use when TPU training throughput or duty cycle drops without crashing pods, when `PERFORMANCE_DEGRADATION` monitored events fire, or when triaging slow multi-slice training steps. Don't use for complete multi-slice XLA execution stalls with `HANG_DETECTED` logs (use gke-ai-troubleshooting-tpu-mxla-hang) or pod eviction/interruption restarts (use gke-ai-troubleshooting-jobset-interruption).
02 资源文件 5
- 参考文档references/attribution.md1.9 KB
- 参考文档references/path-a-workload-bottlenecks.md2.3 KB
- 参考文档references/path-b-infrastructure-throttling.md2.2 KB
- 参考文档references/path-c-no-detected-analyzer.md1.5 KB
- 参考文档references/path-d-healthy-telemetry.md323 B
03 SKILL.md 正文
Troubleshoot GKE TPU performance degradation with ML Diagnostics Workload Monitoring
Diagnose and mitigate Cloud TPU training throughput drops and step-time
regressions (15%+ drop in TPU duty cycle) on Google Kubernetes Engine (GKE) by
correlating ML Diagnostics Workload Monitoring MonitoredEvent analyzer
reports with 1-minute Cloud Monitoring system metrics 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-performance-degradation)"
and append agent-skills/1.0 (skill:gke-ai-troubleshooting-tpu-performance-degradation) to User-Agent headers.
Prerequisites
- Tools: Install the
Google Cloud SDK (
gcloudwithalphacomponent forgcloud alpha mldiagnostics) andkubectl. - 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 ensurecontainer.googleapis.com,monitoring.googleapis.com, andhypercomputecluster.googleapis.comare enabled. - Supported workloads and GKE versions: Google Cloud ML Diagnostics only
supports JAX on TPUs (see
ML Diagnostics platform).
Workload Monitoring is enabled by default, supports the
jobsetandjobGKE job types, and is compatible with GKE versions1.36.0-gke.4681000and later, as stated in Configure GKE for ML Diagnostics. If a workload uses another framework (such as PyTorch) or another custom resource type,gcloud alpha mldiagnosticswon't list ML runs or monitored events for it. On-demand profiling (Step 4 Path A) additionally requires the cluster setup described in that document. - 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 - Kubernetes Engine Viewer (
roles/container.viewer) for thekubectl get nodesquery in Step 3 - For remediation (
[High Risk]steps): Kubernetes Engine Cluster Admin (roles/container.clusterAdmin)
- Cluster Director Editor (
- Reference Documentation:
- ML Diagnostics platform (Sections: "IAM permissions")
- Configure GKE for ML Diagnostics (Sections: "Set up with gcloud CLI, Google Cloud console, or Terraform", "Manual installation", "Connection-operator")
- Workload monitoring with ML Diagnostics (Sections: "Workload Monitoring and analyzers", "HBM Capacity Analyzer", "Host Memory Utilization Analyzer", "CPU Utilization Analyzer", "Access Workload Monitoring information through the API", "List all monitored events", "System Metrics")
- Get started with the ML Diagnostics CLI (Sections: "List machine learning runs", "Monitored-events commands", "List profiler targets", "Capture on-demand profiler sessions")
- Scale container resource requests and limits (Sections: "Identify workloads without resource requests or limits")
- Auto-repair nodes (Sections: "Repair criteria", "Verify node auto-repair is enabled for a Standard node pool", "Enable auto-repair for an existing Standard node pool", "Node auto repair in TPU slice nodes")
- Deploy TPU workloads in GKE Standard (Sections: "Configure auto repair for TPU slice nodes")
- Get support (Sections: "Before you contact support")
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.
Analyzer routing overview
By default, Workload Monitoring treats a 15% drop in TPU duty cycle as a
performance degradation, raises a MonitoredEvent (type: PERFORMANCE_DEGRADATION), and runs its analyzers. Consult the
Workload Monitoring and analyzers
section in the official Cloud TPU documentation for the complete analyzer
definitions, detection criteria, and subsections, and route remediation by
category:
- Category A: workload resource bottlenecks (never cordon or replace nodes):
- When the firing analyzer (
detectionState: "DETECTED") indicates a workload memory or host CPU capacity bottleneck (see the "HBM Capacity Analyzer", "Host Memory Utilization Analyzer", and "CPU Utilization Analyzer" sections of Workload monitoring with ML Diagnostics), route to Path A: Workload resource bottlenecks (workload optimization and profiling).
- When the firing analyzer (
- Category B: infrastructure and network fabric throttling (culprit nodes):
- When the firing analyzer (
detectionState: "DETECTED") indicates an interconnect, thermal/power throttling, memory bandwidth, or Top-of-Rack (ToR) network fault on specific instances (see Workload Monitoring and analyzers), route to Path B: Infrastructure or network fabric throttling (map the culprit Compute Engine instance IDs to GKE nodes, handle node repair through GKE, and escalate to Google Cloud Support).
- When the firing analyzer (
- Category C:
PERFORMANCE_DEGRADATIONevent fired, but no analyzer reportsdetectionState: "DETECTED":- When a
PERFORMANCE_DEGRADATIONevent exists (as in the sample output in List all monitored events, whereanalyzerReportsentries havedetectionState: "NOT_DETECTED"), route to Path C: Event fired with no DETECTED analyzer.
- When a
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{workload_name}/{ml_run_id}: JobSet / workload name or ML Diagnostics run ID{issue_time}: Timestamp when throughput degradation was observed (T, ISO-8601 UTC){start_time}:T - 30m{end_time}:T + 30m
Step 1: Query ML runs and monitoredEvents [Low Risk]
- List active or recent ML runs: Give the user
gcloud alpha mldiagnostics machine-learning-run listwith a link to List machine learning runs in the ML Diagnostics CLI reference, and locate{ml_run_id}matching{workload_name}. - List performance degradation events: Give the user
gcloud alpha mldiagnostics monitored-events listwith a link to Monitored-events commands, or thehypercomputecluster.googleapis.com/v1alphaAPI with a link to Access Workload Monitoring information through the API, to check forPERFORMANCE_DEGRADATIONevents during[{start_time}, {end_time}]. - Describe the
MonitoredEvent: Give the usergcloud alpha mldiagnostics monitored-events describewith a link to the same Monitored-events commands section, and inspect theanalyzerReportsarray (analyzer,detectionState,details, andrecommendedActions).- If a
PERFORMANCE_DEGRADATIONevent fired, run Step 2 to corroborate with the 1-minute system metrics; if none of itsanalyzerReportsentries hasdetectionState: "DETECTED", follow Path C: Event fired with no DETECTED analyzer. - If no
PERFORMANCE_DEGRADATIONevent exists and duty cycle is steady in Step 2, rule out TPU performance degradation by following Path D: Healthy telemetry.
- If a
Step 2: Correlate with 1-minute Cloud Monitoring system metrics [Low Risk]
Consult the
System Metrics
section in the Workload Monitoring documentation for the 1-minute Cloud
Monitoring metrics exported for TPU and host devices, and run read-only PromQL
queries over [{start_time}, {end_time}] to corroborate the analyzer report:
# 1. Node TPU duty cycle (look for the drop on the affected nodes)
kubernetes_io:node_accelerator_duty_cycle{
monitored_resource="k8s_node",
project_id="{project_id}",
cluster_name="{cluster_name}"
}
# 2. HBM utilization ratio by node (around 0.90 is approaching the limit)
sum by (node_name) (
kubernetes_io:node_accelerator_memory_used{
monitored_resource="k8s_node",
project_id="{project_id}",
cluster_name="{cluster_name}"
}
)
/
sum by (node_name) (
kubernetes_io:node_accelerator_memory_total{
monitored_resource="k8s_node",
project_id="{project_id}",
cluster_name="{cluster_name}"
}
)
# 3. Host memory and CPU allocatable utilization
kubernetes_io:node_memory_allocatable_utilization{
monitored_resource="k8s_node",
project_id="{project_id}",
cluster_name="{cluster_name}"
}
kubernetes_io:node_cpu_allocatable_utilization{
monitored_resource="k8s_node",
project_id="{project_id}",
cluster_name="{cluster_name}"
}
Step 3: Map culprit instance IDs to GKE nodes and topology [Low Risk]
When an infrastructure analyzer reports culprit numeric Compute Engine instance
IDs in details or recommendedActions, map those numeric instance IDs to GKE
Node names and physical topology blocks using this read-only kubectl query
inspecting container.googleapis.com/instance_id:
kubectl get nodes -l cloud.google.com/gke-tpu-accelerator \
-o jsonpath='{range .items[*]}{.metadata.name}{"\tinstance_id="}{.metadata.annotations.container\.googleapis\.com/instance_id}{"\tblock="}{.metadata.labels.cloud\.google\.com/gce-topology-block}{"\tsubblock="}{.metadata.labels.cloud\.google\.com/gce-topology-subblock}{"\thost="}{.metadata.labels.cloud\.google\.com/gce-topology-host}{"\n"}{end}'
Step 4: Remediation by analyzer category
Load and follow only the reference file that matches the analyzer category from Step 1:
- Path A (workload resource bottlenecks — HBM, host memory, or host CPU utilization): Read Path A: Workload resource bottlenecks.
- Path B (infrastructure, thermal, ICI, memory bandwidth, or network fabric throttling): Read Path B: Infrastructure or network fabric throttling.
- Path C (
PERFORMANCE_DEGRADATIONevent fired with all analyzersNOT_DETECTED): Read Path C: Event fired with no DETECTED analyzer. - Path D (no
PERFORMANCE_DEGRADATIONevents and steady telemetry): Read Path D: Healthy telemetry.
Guardrails
- Never change GKE-managed instance groups or VMs through Compute Engine:
Don't run
gcloud compute instance-groups managedcommands, such asdelete, on a node pool's managed instance group. Handle nodes through GKE, as described in Path B: Infrastructure or network fabric throttling. - Never cordon nodes for workload resource saturation: If only the HBM capacity, host memory, or host CPU utilization analyzers detected an issue, don't cordon or replace nodes.
04 同仓库更多 Skills
cloud-operator-share-context
Shares Google Cloud operating context the user or their team already have — environments, projects, services and regions, product preferences, best practices, architecture guidance, runbooks — found in agent instruction files, local memory, skills and workflows, and the repository's GCP docs, with the operator agent's memory after the user reviews the list. Use when the user runs this skill, accepts the cloud-operator or cloud-operator-setup skill's offer to share their existing Google Cloud context, or asks to share, import or save that context or a GCP fact for the operator agent. Don't use for ordinary GCP requests, which go to the cloud-operator skill.
cloud-operator-setup
Sets up the operator agent in a Google Cloud project via the autocloud MCP server: picks the operator project, creates or checks the user's operator agent, saves the project, and offers to share the user's existing Google Cloud operating context with the operator agent's memory. Use when the user runs this skill, asks to set up the operator or create their operator agent, or chooses setup when the cloud-operator skill asks. Don't use for ordinary GCP requests or installing gcloud.
developer-device-platform-device-run
Runs automated, non-interactive jobs on remote Android devices with Developer Device Platform (DDP) Device Run using `gcloud beta device-run sessions`: native Android executables or shell scripts (for example CLI tools, custom runners, test harnesses or benchmarks) and Android instrumentation tests, on one or many devices, then waits for completion and collects per-device outputs and logs. Use when running a binary or test suite on remote devices without an interactive connection. Don't use it for interactive device reservations, adb tunnels or screen streaming (use developer-device-platform-basics), or for local devices.
compute-vm-creation
Guides the planning, configuration, and provisioning of standalone Google Compute Engine virtual machines (VMs) and bare metal (-metal) instances using gcloud CLI commands or direct MCP tool execution. Use ONLY when the user wants to create, configure, or provision a new standalone Compute Engine VM or bare metal instance from conversational intents (hardware sizing, region selection, OS image, networking, security defaults). DO NOT read or use for Google Kubernetes Engine (GKE) Autopilot or Standard clusters, Kubernetes node pools or Pods, container orchestration, managing existing VMs, Managed Instance Groups (MIGs), or Instance Templates.
agent-platform-autorater-customization
Customizes an autorater (evaluation metric) for an AI agent so its grades match the user's own judgment, starting from the agent's real trajectories. Use when a user wants a metric tailored to their agent, wants to turn failing trajectories into rubrics, says an existing autorater grades their agent wrong, or wants an autorater to agree with human labels (autorater hillclimbing, judge calibration). Don't use for quick evals with built-in metrics or for improving the agent itself (use agent-platform-eval-flywheel).
iap-agent-platform-troubleshooting
Diagnoses Identity-Aware Proxy (IAP) denials of outbound requests from Gemini Enterprise Agent Platform agents that run on Agent Runtime and send traffic through Agent Gateway. Use when an agent request fails with "Egress request is not authorized", when Cloud Audit Logs show an IAP egressViaIAP decision with granted false, when IAP audit entries are missing while debugging agent egress, or when Access policies, IAP allow policies, policy bindings, or Agent Registry entries might block agent egress. Don't use for Gemini model IAM permission errors (such as aiplatform.endpoints.predict), Agent Platform API errors, or Agent Runtime deployment or 500 errors (use agent-platform-troubleshooting instead). Don't use for setting up, creating, or connecting an Agent Gateway, or for IAP web apps, IAP TCP forwarding, or SSH.