Skip to content

Commit 034266d

Browse files
committed
Merge branch 'main' into jax_0.8.0_py3.12_v7x
2 parents 7b03c3f + 2fc8cb4 commit 034266d

15 files changed

Lines changed: 678 additions & 327 deletions

axlearn/cloud/gcp/pathways_utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ def get_pathways_tpu_version(gke_machine_type: str) -> str:
9595
https://github.com/google/pathways-job/blob/4417de7aa23d3c2316e400a3a327512834374475/internal/controller/pathwaysjob_controller.go#L70-L82
9696
"""
9797
pathways_tpu_devices = {
98+
# 7x
99+
"tpu7x-standard-4t": "tpu7x",
98100
# v6e
99101
"ct6e-standard-4t": "tpuv6e",
100102
# v5p

axlearn/cloud/gcp/scripts/start_vm.sh

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env bash
22
#
3-
# Copyright © 2023 Apple Inc.
3+
# Copyright © 2025 Apple Inc.
44
#
55
# Boot script for GCP VM.
66
#
@@ -28,6 +28,10 @@ trap 'echo "Bootstrap failed." >> ${SETUP_LOG_PATH}; \
2828
gcloud compute instances add-labels ${JOB_NAME} --labels=boot_status=failed --zone ${ZONE}; \
2929
exit 1' ERR
3030

31+
# Ensure gcloud is not installed via snap.
32+
# This causes a permissions issue where the snap data directory is not writeable when using gcloud.
33+
snap remove --purge google-cloud-cli || echo "Ignoring snap removal failure..."
34+
3135
# Ensure that gcloud is installed.
3236
while [[ ! -x $(which gcloud) ]]
3337
do
@@ -88,18 +92,16 @@ if [[ " ${tar_bundlers[*]} " =~ " ${BUNDLER_TYPE} " ]]; then
8892

8993
# Install + activate Python 3.10.
9094
install_py310() {
91-
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
92-
/bin/bash miniconda.sh -b -p /opt/conda
93-
source /opt/conda/etc/profile.d/conda.sh
94-
# Accept conda ToS to allow conda env creation
95-
conda tos accept
96-
conda create -y -n py310 python=3.10
97-
conda activate py310
98-
conda info --envs
99-
# update pip and pre-install needed utilities
100-
pip install -U pip swig flit uv
101-
# Add conda to .profile file, and use login shell to source.
102-
echo 'source /opt/conda/etc/profile.d/conda.sh && conda activate py310' >> ~/.profile
95+
# Install Python 3.10 with the required venv module
96+
apt-get update && \
97+
DEBIAN_FRONTEND=noninteractive apt-get install -y python3.10-venv python3.10-dev && \
98+
apt clean -y
99+
mkdir -p /opt/venv
100+
# Create a new virtual environment
101+
python3.10 -m venv /opt/venv
102+
/opt/venv/bin/python3.10 -m pip install -U pip swig flit uv
103+
echo 'source /opt/venv/bin/activate' >> ~/.profile
104+
source /opt/venv/bin/activate
103105
}
104106
install_py310 >> ${SETUP_LOG_PATH} 2>&1
105107
log "Using python3: $(which python3)"

axlearn/cloud/gcp/system_characteristics.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -416,38 +416,38 @@ class _SystemCharacteristics:
416416
"v6e-256": _SystemCharacteristics(
417417
"16x16", 64, "tpu-v6e-slice", "ct6e-standard-4t", 4, AcceleratorType["TPU"], "v6e-256"
418418
),
419-
# v7x
420-
"v7x-8": _SystemCharacteristics(
419+
# 7x
420+
"7x-8": _SystemCharacteristics(
421421
"2x2x1", 1, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-8"
422422
),
423-
"v7x-16": _SystemCharacteristics(
423+
"7x-16": _SystemCharacteristics(
424424
"2x2x2", 2, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-16"
425425
),
426-
"v7x-32": _SystemCharacteristics(
426+
"7x-32": _SystemCharacteristics(
427427
"2x2x4", 4, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-32"
428428
),
429-
"v7x-64": _SystemCharacteristics(
429+
"7x-64": _SystemCharacteristics(
430430
"2x4x4", 8, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-64"
431431
),
432-
"v7x-128": _SystemCharacteristics(
432+
"7x-128": _SystemCharacteristics(
433433
"4x4x4", 16, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-128"
434434
),
435-
"v7x-256": _SystemCharacteristics(
435+
"7x-256": _SystemCharacteristics(
436436
"4x4x8", 32, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-256"
437437
),
438-
"v7x-512": _SystemCharacteristics(
438+
"7x-512": _SystemCharacteristics(
439439
"4x8x8", 64, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-512"
440440
),
441-
"v7x-1024": _SystemCharacteristics(
441+
"7x-1024": _SystemCharacteristics(
442442
"8x8x8", 128, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-1024"
443443
),
444-
"v7x-2048": _SystemCharacteristics(
444+
"7x-2048": _SystemCharacteristics(
445445
"8x8x16", 256, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-2048"
446446
),
447-
"v7x-4096": _SystemCharacteristics(
447+
"7x-4096": _SystemCharacteristics(
448448
"8x16x16", 512, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-4096"
449449
),
450-
"v7x-8192": _SystemCharacteristics(
450+
"7x-8192": _SystemCharacteristics(
451451
"16x16x16", 1024, "tpu7x", "tpu7x-standard-4t", 4, AcceleratorType["TPU"], "v7x-8192"
452452
),
453453
# v4
@@ -530,13 +530,15 @@ class _SystemCharacteristics:
530530
"ct4p-hightpu-4t": 407,
531531
"ct5lp-hightpu-4t": 192,
532532
"ct6e-standard-4t": 720,
533+
"tpu7x-standard-4t": 960,
533534
}
534535

535536
# Reference doc https://cloud.google.com/kubernetes-engine/docs/concepts/plan-tpus
536537
GCE_MACHINE_TYPE_TO_CPU_CHARACTERISTICS = {
537538
"ct5p-hightpu-4t": 208,
538539
"ct4p-hightpu-4t": 240,
539540
"ct6e-standard-4t": 180,
541+
"tpu7x-standard-4t": 224,
540542
}
541543

542544

axlearn/cloud/gcp/tpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ def infer_tpu_workers(tpu_type: str) -> int:
6363
try:
6464
if match is not None:
6565
tpu_version, tpu_cores = match.groups()
66-
if tpu_version in {"v3", "v4", "v5p", "v7x"}:
66+
if tpu_version in {"v3", "v4", "v5p", "7x"}:
6767
return int(tpu_cores) // 8
6868
if tpu_version in {"v5litepod", "v6e"}:
6969
return int(tpu_cores) // 4

axlearn/cloud/gcp/vertexai_tensorboard.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
"""Tools to upload model summaries to VertexAI Tensorboard."""
44

5+
import hashlib
56
import multiprocessing
67
import re
78
import resource
@@ -34,10 +35,15 @@ def _vertexai_experiment_name_from_output_dir(output_dir: str) -> str:
3435
# Vertex AI Tensorboard requires experiment_name to match "[a-z0-9][a-z0-9-]+".
3536
experiment_name = match.group(1).lower().replace("/", "-").replace("_", "-").replace(".", "-")
3637
if len(experiment_name) >= _VERTEXAI_EXP_NAME_MAX_LEN: # Vertex AI length limit.
37-
raise ValueError(
38-
rf"Experiment name must be less than {_VERTEXAI_EXP_NAME_MAX_LEN} chars long."
39-
rf"{experiment_name} is {len(experiment_name)} chars."
38+
logging.warning(
39+
"Experiment name '%s' is %d chars (exceeds %d limit). Truncating to fit.",
40+
experiment_name,
41+
len(experiment_name),
42+
_VERTEXAI_EXP_NAME_MAX_LEN,
4043
)
44+
hash_suffix = hashlib.md5(experiment_name.encode()).hexdigest()[:8]
45+
max_name_len = _VERTEXAI_EXP_NAME_MAX_LEN - 1 - len(hash_suffix)
46+
experiment_name = f"{experiment_name[:max_name_len]}-{hash_suffix}"
4147
return experiment_name
4248

4349

axlearn/cloud/gcp/vertexai_tensorboard_test.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from axlearn.cloud.gcp import config as gcp_config
1313
from axlearn.cloud.gcp import test_utils
1414
from axlearn.cloud.gcp.vertexai_tensorboard import (
15+
_VERTEXAI_EXP_NAME_MAX_LEN,
1516
VertexAITensorboardUploader,
1617
_vertexai_experiment_name_from_output_dir,
1718
)
@@ -79,5 +80,10 @@ def test_uploader_calls(
7980

8081
class ExperimentNameTest(absltest.TestCase):
8182
def test_exp_name_len(self):
82-
with self.assertRaises(ValueError):
83-
_vertexai_experiment_name_from_output_dir("gs://abc/" + "a" * 128)
83+
# Test that long experiment names are properly truncated
84+
long_input = "gs://abc/" + "a" * _VERTEXAI_EXP_NAME_MAX_LEN
85+
result = _vertexai_experiment_name_from_output_dir(long_input)
86+
self.assertLessEqual(len(result), _VERTEXAI_EXP_NAME_MAX_LEN)
87+
self.assertGreater(len(result), 0)
88+
# The result should end with a hash suffix when truncated
89+
self.assertRegex(result, r"-[a-f0-9]{8}$")

axlearn/common/compiler_options.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def default_xla_options(
132132
xla_should_add_loop_invariant_op_in_chain="true",
133133
xla_tpu_use_enhanced_launch_barrier="true",
134134
)
135-
if version == "v7x":
135+
if version == "7x":
136136
options.update(
137137
# Many of the v7x flags are similar to v6e
138138
xla_tpu_scoped_vmem_limit_kib=65536,
@@ -307,7 +307,7 @@ class NotTpuError(ValueError):
307307
def infer_tpu_type(instance_type: str) -> str:
308308
"""Infers tpu type (e.g. v4-8 or v6e-8-1) from instance type
309309
(e.g. tpu-v4-8, v4-8, tpu-v6e-8-1 or v6e-8-1)."""
310-
if not (instance_type and re.fullmatch(r"(tpu-)?v.+-\d+", instance_type)):
310+
if not (instance_type and re.fullmatch(r"(tpu-)?v?.+-\d+", instance_type)):
311311
raise NotTpuError(f"Invalid TPU instance: {instance_type}")
312312
return instance_type.replace("tpu-", "")
313313

@@ -399,7 +399,7 @@ def infer_xsc_compiler_options(
399399

400400

401401
_TPU_VERSION_ALIASES = {"v5e": "v5litepod"}
402-
_TPU_VERSIONS = ("v3", "v4", "v5litepod", "v5p", "v6e", "v7x")
402+
_TPU_VERSIONS = ("v3", "v4", "v5litepod", "v5p", "v6e", "7x")
403403

404404

405405
def infer_xla_performance_flags(

0 commit comments

Comments
 (0)