排解 Pathways on Cloud 問題

事前準備

本文說明如何排解 Pathways 工作負載問題。

查看記錄

在 Cloud Logging 記錄檔探索工具中,使用下列查詢並調整專案、區域、叢集和工作負載。

resource.type="k8s_container"
resource.labels.project_id="PROJECT"
resource.labels.location="LOCATION"
resource.labels.cluster_name="CLUSTER"
resource.labels.namespace_name="default"
resource.labels.pod_name:"WORKLOAD_NAME"

更改下列內容:

  • PROJECT:您的 Google Cloud 專案 ID
  • LOCATION:您建立 GKE 叢集的區域或可用區
  • CLUSTER:GKE 叢集名稱
  • WORKLOAD_NAME:使用 XPK 時的工作負載名稱,或使用 kubectl 時的 JobSet 名稱

這項查詢會比對多個 Pathways Kubernetes 容器,名稱類似 pathways-rmpathways-proxypathways-worker。您可以新增容器名稱的篩選器 (例如 resource.labels.container_name:"<container_name>"),縮小範圍找出造成問題的容器。

監控

健康狀態監控功能

您可以查看容器記錄中的項目,監控各種 Pathways 元件的健康狀態,例如:

寫入下列記錄時,pathways-proxy 即可處理新的連線要求:

kubectl logs ${HEAD_POD_NAME} --container pathways-proxy
...
I1101 04:51:41.967764       1 proxy_server.cc:125] IFRT proxy server started with status OK

寫入下列記錄時,pathways-rm 即可處理新的連線要求:

kubectl logs $HEAD_POD_NAME --container pathways-rm
...
I1101 04:50:41.967764       1 server_lib.cc:1473] Pathways Server serving on [::]:29001

如要確認向 Pathways Resource Manager 註冊的所有 TPU 是否都已準備就緒,請在 pathways-rm 容器記錄中尋找 ***<num slices>/<num slices> Pathways Slices Now Ready ***

kubectl logs $HEAD_POD_NAME --container pathways-rm
...
I1101 04:52:41.967764       1 multi_job_allocator.cc:1063] *** 2/2 Pathways Slices Now Ready ***

只要 Proxy 伺服器已就緒,即使並非所有切片都已就緒,Pathways 用戶端仍可連線至 IFRT Proxy 伺服器。您的工作會使用虛擬切片,直到切片準備就緒為止。如果 TPU 無法使用,虛擬切片可讓程式碼繼續執行。

寫入下列記錄時,pathways-worker 即可處理新的連線要求:

kubectl logs $WORKER_POD_NAME --container pathways-worker
...
I1101 04:50:41.967764       1 server_lib.cc:1473] Pathways Server serving on [::]:29001

指標收集

路徑可將低層級的系統指標寫入 Cloud Monitoring,以利偵錯。 這些指標包括:

  • DCN 傳輸延遲
  • 集體延遲時間
  • 主機到裝置的傳輸延遲
  • 裝置到主機的轉移延遲

您可以在執行 GKE 叢集的 {gcp_name} 專案的 Cloud Monitoring 資訊主頁上找到指標。

如要在 Metrics Explorer 中監控這些指標,請按照下列步驟操作:

  1. 前往 Metrics Explorer
  2. 使用「選取指標」欄位,依指標名稱篩選
  3. 選取「新增篩選器」,然後依 pod_name 篩選,即可依工作負載名稱和時間範圍篩選
  4. 根據指標和監控的工作負載,選擇適當的匯總類型

DCN 傳輸延遲

這是 Megascale XLA (MXLA) 指標,用於測量多切片流量的網路傳輸延遲累積分佈。當系統發出透過 DCN 傳輸資料的要求,並收到資料傳輸完成的確認訊息時,就會開始計算延遲時間。如要監控這項指標,請依 dcn_transfer_latencies 指標名稱篩選。

集合延遲時間

這是 MXLA 指標,用於測量多切片流量的端對端集體延遲累積分配情形。延遲時間的計算起點為發出集合要求,終點為收到資料傳輸完成的確認訊息。如要監控這項指標,請依 collective_e2e_latency 指標名稱篩選。

主機到裝置的傳輸延遲

這是 MXLA 指標,用於測量多重切片流量的主機到裝置傳輸延遲累積分配情形。當系統發出透過 DCN 傳輸資料的要求,並收到資料傳輸完成的確認訊息時,就會開始計算延遲時間。如要監控這項指標,請依 host_to_device_transfer_latencies 指標名稱篩選。

裝置到主機的轉移延遲

這是 MXLA 指標,用於測量多切片流量的裝置到主機轉移延遲時間累積分布。當系統發出透過 DCN 傳輸資料的要求時,就會開始測量延遲時間,並在收到資料傳輸完成的確認訊息時結束測量。如要監控這項指標,請依 device_to_host_transfer_latencies 指標名稱篩選。

常見錯誤的除錯方式

無法對加速器設定警告進行雜湊處理

下列訊息僅為警告,不會影響 JAX 程式碼的效能。

INFO:jax._src.cache_key:get (_hash_accelerator_config): unable to hash accelerator config, falling back to hashing devices + platform: UNIMPLEMENTED: GetTopologyForDevices is not supported for the IFRT proxy client. (type <class 'jaxlib.xla_extension.XlaRuntimeError'>)

資源的「logging.logEntries.create」權限遭拒

如果看到下列錯誤,請確認 Vertex AI Workbench 使用的 Compute Engine 服務帳戶有權將記錄項目寫入 Google Cloud logging 系統。

INFO:absl:Created 'ArrayHandler' with primary_host=0, replica-id=0
WARNING:absl:pathwaysutils: Detected Pathways-on-Cloud backend. Applying changes.
Failed to submit 1 logs.
Traceback (most recent call last):
  File "/opt/conda/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 65, in error_remapped_callable
    return callable_(**args, **kwargs)
  File "/opt/conda/lib/python3.10/site-packages/grpc/_channel.py", line 1181, in __call__
    return _end_unary_response_blocking(state, call, False, None)
  File "/opt/conda/lib/python3.10/site-packages/google/api_core/grpc_helpers.py", line 1006, in _end_unary_response_blocking
    raise _InactiveRpcError(state) # pytype: disable-not-instantiable
grpc._channel._InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
  status = StatusCode.PERMISSION_DENIED
  details = "Permission 'logging.logEntries.create' denied on resource (or it may not exist)."
  debug_error_string = "UNKNOWN:Error received from peer ipv4:216.239.34.174:443 {created_time:"2024-10-03T20:30:44.820425276+00.00", grpc_status:7, grpc_message:"Permission \'logging.logEntries.create\' denied on resource (or it may not exist)."}"
>

如要修正這個問題,請將「記錄檔寫入者」角色新增至 Compute Engine 服務帳戶。

無法連線至 IFRT Proxy 伺服器

如果看到這則錯誤訊息,表示 IFRT Proxy 用戶端無法連線至 IFRT Proxy 伺服器。

  • 確認虛擬私有雲網路設定正確無誤
  • 確認防火牆已設為允許連線
  • 確認 Pathways 叢集已佈建
  • 檢查啟動錯誤訊息

當第一個將 IFRT 指令傳送至 Pathways 叢集的 JAX 指令嘗試執行時,系統會停止回應約一分鐘,然後顯示類似下列內容的 RuntimeError

RuntimeError: Unable to initialize backend 'proxy': UNAVAILABLE: Unable to establish connection to ifrt_proxy server, please check provided address example-workload-proxy-0-0.example-workload.default.svc.example-cluster-domain.:38676'; detailed error: DNS resolution failed (set JAX_PLATFORMS='' to automatically choose an available backend)

已連線至 Pathways 叢集

Pathways 叢集一次只能與一個用戶端維持工作階段。如果兩個不同的筆記本嘗試連線至同一個 Pathways 叢集,其中一個可以連線,另一個則會顯示下列錯誤。

INFO:absl:Created ArrayHandler with primary_host=0, replica_id=0
WARNING:absl:pathwaysutils: Detected Pathways-on-Cloud backend. Applying changes.
E0927 21:19:52.919607   37624 rpc_helper.cc:56] Connection to IFRT proxy server was terminated: CANCELLED: Cancelled
E0927 21:20:03.467547   37719 rpc_helper.cc:56] Connection to IFRT proxy server was terminated: CANCELLED: Cancelled
E0927 21:20:14.011645   37807 rpc_helper.cc:56] Connection to IFRT proxy server was terminated: CANCELLED: Cancelled
E0927 21:20:24.557955   37924 rpc_helper.cc:56] Connection to IFRT proxy server was terminated: CANCELLED: Cancelled
---------------------------------------------------------------------------
XlaRuntimeError                           Traceback (most recent call last)
File /opt/conda/lib/python3.10/site-packages/jax/_src/xla_bridge.py:887, in backends()
    885   continue
--> 887 backend = _init_backend(platform)
    888 _backends[platform] = backend

File /opt/conda/lib/python3.10/site-packages/jax/_src/xla_bridge.py:973, in _init_backend(platform)
    972 logger.debug("Initializing backend '%s'", platform)
--> 973 backend = registration.factory()
    974 # TODO: consider raising more descriptive errors directly from backend
    975 # factories instead of returning None.

File /opt/conda/lib/python3.10/site-packages/pathwaysutils/proxy_backend.py:24, in register_backend_factory.<locals>.<lambda>()
     21 def register_backend_factory():
     22   xla_bridge.register_backend_factory(
     23       "proxy",
---> 24       lambda: ifrt_proxy.get_client(
     25           jax.config.read("jax_backend_target"),
     26           ifrt_proxy.ClientConnectionOptions(),
     27       ),
     28       priority=-1,
     29   )

XlaRuntimeError: UNAVAILABLE: Unable to establish connection to ifrt_proxy server, please check provided address example-workload-proxy-0-0.example-workload.default.svc.example-cluster-domain.:38676'; detailed error: Connection to IFRT proxy server was terminated: CANCELLED: Cancelled

During handling of the above exception, another exception occurred:

RuntimeError                              Traceback (most recent call last)
Cell In[2], line 4
      1 import pathwaysutils
      3 import jax
----> 4 print(jax.devices())

File /opt/conda/lib/python3.10/site-packages/jax/_src/xla_bridge.py:1085, in devices(backend)
   1060 def devices(
   1061     backend: str | xla_client.Client | None = None
   1062 ) -> list[xla_client.Device]:
   1063   """Returns a list of all devices for a given backend.
   1064
   1065   .. currentmodule:: jaxlib.xla_extension
   (...)
   1083     List of Device subclasses.
   1084   """
-> 1085   return get_backend(backend).devices()

File /opt/conda/lib/python3.10/site-packages/jax/_src/xla_bridge.py:1019, in get_backend(platform)
   1015 @lru_cache(maxsize=None)  # don't use util.memoize because there is no X64 dependence.
   1016 def get_backend(
   1017     platform: None | str | xla_client.Client = None
   1018 ) -> xla_client.Client:
-> 1019   return _get_backend_uncached(platform)

File /opt/conda/lib/python3.10/site-packages/jax/_src/xla_bridge.py:998, in _get_backend_uncached(platform)
    994   return platform
    996 platform = (platform or _XLA_BACKEND.value or _PLATFORM_NAME.value or None)
--> 998 bs = backends()
    999 if platform is not None:
   1000   platform = canonicalize_platform(platform)

File /opt/conda/lib/python3.10/site-packages/jax/_src/xla_bridge.py:903, in backends()
    901       else:
    902         err_msg += " (you may need to uninstall the failing plugin package, or set JAX_PLATFORMS=cpu to skip this backend.)"
--> 903       raise RuntimeError(err_msg)
    905 assert _default_backend is not None
    906 if not config.jax_platforms.value:

RuntimeError: Unable to initialize backend 'proxy': UNAVAILABLE: Unable to establish connection to ifrt_proxy server, please check provided address 'example-workload-proxy-0-0.example-workload.default.svc.example-cluster-domain.:38676'; detailed error: Connection to IFRT proxy server was terminated: CANCELLED: Cancelled (set JAX_PLATFORMS='' to automatically choose an available backend)

原始用戶端中斷連線後,第二個用戶端就能連線。 如果連線意外中斷,您可能需要重新啟動 Pathways 叢集,才能讓其他用戶端連線。

LocalProxy.init() got an unexpected keyword argument 'unbound_message'

匯入 pathwaysutils 後,如果看到這項錯誤,請檢查環境中是否安裝了舊版 Flask 或 Werkzeug:

 pip3 list --outdated (replacing pip with pip3 as needed)

如果列出 Flask 或 Werkzeug,請考慮升級這些項目,但請注意,這麼做可能會導致專案中的其他套件或依附元件無法運作:

 pip install flask Werkzeug --upgrade ()

Proxy 伺服器發生內部錯誤

"Internal error from proxy server during Array::IsDeleted(): UNAVAILABLE:Connection to IFRT proxy server was terminated: FAILED_PRECONDITION:
GrpcClientSession: writes no longer allowed."

這個錯誤表示 IFRT Proxy 伺服器已與用戶端中斷連線。重新啟動用戶端即可修正這個問題。如果是筆記本,您可以重新啟動筆記本核心,然後重新執行筆記本。

SIGTERMS 和 HBM OOM

如果與 RESOURCE_EXHAUSTED 錯誤相關的記錄中出現 SIGTERM,可能表示 HBM 記憶體不足。在這種情況下,您可以減少 JAX 程式碼中使用的 HBM 記憶體量。

INVALID_ARGUMENT

"INVALID_ARGUMENT : Permanent error, with a last message of Lifecycle
matches_prefix cannot specify more than 50 prefixes per config.; Error while
initializing persistent cache storage Cloud Storage"

如果傳遞至 --pathways_gcs_location 標記的 Cloud Storage 值區已達生命週期政策上限,就會發生這個錯誤。如果發生這種情況,請清除不再使用的 Cloud Storage 生命週期政策。

永久性錯誤

Permanent error, with a last message of The specified bucket does not exist.; Error while initializing persistent cache storage gcs

當您為路徑容器提供無效的 Cloud Storage 位置時,Resource Manager 或 Pathways 工作人員會列印這項錯誤。

來自精靈的錯誤回應

Error response from daemon: dockerfile parse error line 16: Unknown flag: exclude

這是因為 Docker 版本過舊,請升級 Docker 版本。

IFRT Proxy 用戶端和伺服器無法達成共識

IFRT Proxy client and server failed to agree on the protocol version; supported versions: client = [1, 1], server = [3, 14]

這表示系統使用的是舊版 MaxText,請務必重建最新版 MaxText 映像檔。

後續步驟