[TPU] Support single and multi-host TPUs on GKE (#7613)

This commit is contained in:
Richard Liu
2024-08-30 00:27:40 -07:00
committed by GitHub
parent dc13e99348
commit 2148441fd3
5 changed files with 74 additions and 4 deletions
+4 -1
View File
@@ -123,7 +123,10 @@ class PallasAttentionBackendImpl(AttentionImpl):
raise NotImplementedError("TPU version must be 4 or higher.")
self.megacore_mode = None
tpu_type = torch_xla.tpu.get_tpu_env()["TYPE"].lower()
tpu_env = torch_xla.tpu.get_tpu_env()
tpu_type = tpu_env.get("TYPE") or tpu_env.get("ACCELERATOR_TYPE")
tpu_type = tpu_type.lower()
if "lite" not in tpu_type:
if self.num_kv_heads % 2 == 0:
self.megacore_mode = "kv_head"