Skip to content

Commit d7f6251

Browse files
Pathways-on-Cloud Teamcopybara-github
authored andcommitted
Expand TPU type validation to include multihost, v5e and v5p
The validator now accepts tpuv5e, tpuv5p, and tpuv6e instances. The check for a maximum number of chips per slice has been removed. PiperOrigin-RevId: 842417060
1 parent f416009 commit d7f6251

File tree

1 file changed

+6
-18
lines changed

1 file changed

+6
-18
lines changed

pathwaysutils/experimental/shared_pathways_service/validators.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -39,24 +39,19 @@ def validate_pathways_service(pathways_service: str) -> None:
3939

4040

4141
def _validate_tpu_supported(tpu_instance_with_topology: str) -> None:
42-
"""Checks if the given instance represents a valid single-host TPU.
42+
"""Checks if the given instance represents a valid TPU type.
4343
4444
Args:
4545
tpu_instance_with_topology: The TPU instance string, e.g., "tpuv6e:4x8".
4646
47-
Raises ValueError if the instance is not a valid TPU host.
47+
Raises ValueError if the instance is not a valid TPU type.
4848
"""
49-
# Mapping from Cloud TPU type prefix to max chips per host.
50-
single_host_max_chips = {
51-
"tpuv6e": 8, # Cloud TPU v6e (2x4)
52-
}
53-
54-
# Regex to extract topology
49+
# Regex to extract TPU type and topology.
5550
# Examples:
56-
# ct5lp-hightpu-4t:4x8 -> ct5lp, 4x8
57-
# ct5p:2x2x1 -> ct5p, 2x2x1
51+
# tpuv6e:2x4 -> type='tpuv6e', topology='2x4'
52+
# tpuv5p:2x2x1 -> type='tpuv5p', topology='2x2x1'
5853
match = re.match(
59-
r"^(?P<type>tpuv6e):(?P<topology>\d+(?:x\d+)*)$",
54+
r"^(?P<type>tpuv(?:5e|5p|6e)):(?P<topology>\d+(?:x\d+)*)$",
6055
tpu_instance_with_topology,
6156
)
6257

@@ -85,13 +80,6 @@ def _validate_tpu_supported(tpu_instance_with_topology: str) -> None:
8580
f" '{tpu_instance_with_topology}'."
8681
) from exc
8782

88-
if num_chips > single_host_max_chips[tpu_base_type]:
89-
raise ValueError(
90-
f"Topology '{tpu_instance_with_topology}' exceeds"
91-
f" {single_host_max_chips[tpu_base_type]}, the maximum supported"
92-
f" chips for {tpu_base_type}."
93-
)
94-
9583
return
9684

9785
raise ValueError(

0 commit comments

Comments
 (0)