Skip to content

Commit 7f42073

Browse files
camiloCienetxibinliu
authored andcommitted
Fix: Two Dags testing mtc and emc (with replicator=true and replicator=false)
Fix: Use abhinav-mtc xpk branch instead of main branch since xpk version > 0.4.1 crash airflow pod. b/437817546 Fix: Correct name of DAG to emtc (Emergency multitier Checkpointer). Fix: Change name_id of the test to be related to Orbax. Create new tag with Orbax. Remove --restart-on-user-code-failure flag since is already outdated in both main and develop branch Fix: Backup interval to longer. Only testing local saves. GCS testing is in DAG002 mend
1 parent c87b63f commit 7f42073

8 files changed

Lines changed: 196 additions & 157 deletions

File tree

dags/common/test_owner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Team(enum.Enum):
5656
# Multi-tier Checkpointing
5757
ABHINAV_S = "ABHINAV S."
5858
XUEFENG_G = "XUEFENG G."
59-
CAMILO = "CAMILO P."
59+
CAMILO = "camiloCienet"
6060

6161
# MLCompass
6262
ORTI_B = "Orti B."

dags/common/vm_resource.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class XpkClusters:
257257
zone=Zone.EUROPE_WEST4_B.value,
258258
)
259259
TPU_V5P_128_CLUSTER_ORBAX = XpkClusterConfig(
260-
name="b428061876-jf-v5p-128-2",
260+
name="orbax-ml-auto-solutions",
261261
device_version=TpuVersion.V5P,
262262
core_count=128,
263263
project=Project.CLOUD_TPU_MULTIPOD_DEV.value,
Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
"""A DAG to run MaxText multi-tier checkpointing tests (phase2: save & validate)."""
2+
3+
import datetime
4+
5+
from airflow import models
6+
from airflow.utils.task_group import TaskGroup
7+
8+
from dags import composer_env, gcs_bucket
9+
from dags.common import test_owner
10+
from dags.common.vm_resource import DockerImage, XpkClusters
11+
from dags.multipod.configs import gke_config
12+
from dags.multipod.configs.common import SetupMode
13+
from dags.orbax.util import logging as log
14+
from dags.orbax.util import multi_tier_checkpoint_util as mtc
15+
from xlml.utils.xpk import BRANCH_ABHINAV_MTC
16+
17+
SCHEDULE = "0 10 * * *" if composer_env.is_prod_env() else None
18+
19+
with models.DAG(
20+
dag_id="maxtext_emtc_orbax_sav01_save_local",
21+
schedule_interval=SCHEDULE,
22+
tags=[
23+
"multipod_team",
24+
"maxtext",
25+
"multi_tier_p2_chkpt_save_local",
26+
"nightly",
27+
"orbax",
28+
],
29+
start_date=datetime.datetime(2025, 6, 12),
30+
catchup=False,
31+
concurrency=2,
32+
) as dag:
33+
base_output_directory = (
34+
f"{gcs_bucket.MTC_AUTOMATION_BUCKET}/maxtext_emtc_orbax_sav01_save_local"
35+
)
36+
docker_images = [(
37+
SetupMode.NIGHTLY,
38+
DockerImage.MAXTEXT_TPU_JAX_NIGHTLY,
39+
)]
40+
ram_disk = "/local"
41+
test_configs = {"v5p-128": [2]}
42+
clusters = {"v5p-128": XpkClusters.TPU_V5P_128_CLUSTER_ORBAX}
43+
step = 100
44+
local_checkpoint_period = 20
45+
replicator_backup_interval_minutes = 30
46+
name_prefix = "max-p2-sv"
47+
model_name = "llama2-7b"
48+
tests_to_run_seq = []
49+
# Define the flags for replicator usage to create two separate test cases
50+
use_replicator_flags = ["True", "False"]
51+
52+
for i, use_replicator_flag in enumerate(use_replicator_flags):
53+
with TaskGroup(
54+
group_id=f"maxtext_emtc_orbax_sav01_save_local_replicator_{use_replicator_flag.lower()}"
55+
) as task:
56+
for mode, image in docker_images:
57+
for accelerator, slices in test_configs.items():
58+
for slice_num in slices:
59+
cpc = (
60+
clusters[accelerator].project,
61+
clusters[accelerator].zone[:-2],
62+
clusters[accelerator].name,
63+
gcs_bucket.MTC_AUTOMATION_BUCKET.split("gs://")[1],
64+
"ct5p-hightpu-4t",
65+
"google.com/tpu",
66+
"800000Mi",
67+
)
68+
# This is the key change. We conditionally set the trigger_rule
69+
# on the very first task of each task group (except the first one).
70+
# Start from fresh apply cpc yaml mtc driver
71+
delete_cpc = (
72+
mtc.delete_cpc.override(trigger_rule="all_done")(*cpc)
73+
if i > 0
74+
else mtc.delete_cpc(*cpc)
75+
)
76+
apply_cpc = mtc.apply_cpc(*cpc)
77+
run_time = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")
78+
run_name = f"{name_prefix}-{slice_num}x-{accelerator}-{run_time}"
79+
workload_command = (
80+
"export TPU_PREMAPPED_BUFFER_SIZE=52428800000 && "
81+
"export TPU_PREMAPPED_BUFFER_TRANSFER_THRESHOLD_BYTES=52428800000 && "
82+
"python3 -m MaxText.train MaxText/configs/base.yml remat_policy=full "
83+
f"global_parameter_scale=1 base_output_directory={base_output_directory} "
84+
f"dataset_type=synthetic steps={step} per_device_batch_size=1 "
85+
f"max_target_length=256 model_name={model_name} per_device_batch_size=2 "
86+
"reuse_example_batch=1 enable_emergency_checkpoint=true "
87+
f"local_checkpoint_directory={ram_disk} local_checkpoint_period={local_checkpoint_period} "
88+
f"use_replicator_service={use_replicator_flag} replicator_backup_interval_minutes={replicator_backup_interval_minutes} "
89+
f"run_name={run_name}",
90+
)
91+
92+
start_time = log.generate_timestamp()
93+
94+
maxtext_phase2_chkpt_test = gke_config.get_gke_config(
95+
num_slices=slice_num,
96+
cluster=clusters[accelerator],
97+
time_out_in_min=60,
98+
test_name=f"{name_prefix}-{use_replicator_flag.lower()}",
99+
run_model_cmds=workload_command,
100+
docker_image=image.value,
101+
test_owner=test_owner.CAMILO,
102+
).run(
103+
ramdisk_directory=ram_disk,
104+
mtc_enabled=True,
105+
xpk_branch=BRANCH_ABHINAV_MTC,
106+
skip_post_process=True,
107+
)
108+
109+
cleanup_command = (f"rm -rf {ram_disk}/*",)
110+
ram_disk_cleanup = gke_config.get_gke_config(
111+
num_slices=slice_num,
112+
cluster=clusters[accelerator],
113+
time_out_in_min=60,
114+
test_name=f"{name_prefix}-cl",
115+
run_model_cmds=cleanup_command,
116+
docker_image=image.value,
117+
test_owner=test_owner.CAMILO,
118+
).run(
119+
ramdisk_directory=ram_disk,
120+
mtc_enabled=True,
121+
xpk_branch=BRANCH_ABHINAV_MTC,
122+
skip_post_process=True,
123+
)
124+
125+
end_time = log.generate_timestamp()
126+
vali_step = step - 1
127+
vali_step_list = [
128+
i for i in range(0, vali_step, local_checkpoint_period)
129+
]
130+
vali_step_list.append(vali_step)
131+
132+
# Here we are looking for the string '(blocking + background)'.
133+
# We will compare expected steps with the ones we found when query this regex. Should be the same
134+
# If for some reason the restore start from 0 this task will fail because len(valid_step_list) != len(founded_steps)
135+
validate_log = log.validate_log_with_step(
136+
project_id=clusters[accelerator].project,
137+
location=clusters[accelerator].zone[:-2],
138+
cluster_name=clusters[accelerator].name,
139+
text_filter="(blocking + background).",
140+
start_time=start_time,
141+
end_time=end_time,
142+
vali_step_list=vali_step_list,
143+
)
144+
145+
(
146+
delete_cpc
147+
>> apply_cpc
148+
>> start_time
149+
>> maxtext_phase2_chkpt_test
150+
>> ram_disk_cleanup
151+
>> end_time
152+
>> validate_log
153+
)
154+
# Add to a global list of test to be run in a sequential way
155+
tests_to_run_seq.append(task)
156+
157+
# Chain the task groups sequentially
158+
for idx_test in range(len(tests_to_run_seq) - 1):
159+
tests_to_run_seq[idx_test] >> tests_to_run_seq[idx_test + 1]

dags/orbax/maxtext_multi_tier_chechpoint_save_local.py

Lines changed: 0 additions & 136 deletions
This file was deleted.

dags/orbax/util/__init__.py

Whitespace-only changes.
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
"""Utilities to get workloads logs and some utils."""
22

3-
from airflow.decorators import task
4-
from airflow.exceptions import AirflowFailException
5-
from google.cloud import logging as log_explorer
63
from datetime import datetime, timezone, timedelta
74
from typing import Optional
85
from absl import logging
96

7+
from airflow.decorators import task
8+
from airflow.exceptions import AirflowFailException
9+
from google.cloud import logging as log_explorer
1010

1111
@task
1212
def generate_timestamp():

xlml/utils/orbax.py renamed to dags/orbax/util/multi_tier_checkpoint_util.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
1+
2+
"""Utility functions for managing Multi-tier Cluster Configuration.
3+
4+
This module provides tasks for creating, applying, and deleting
5+
Multi-tier Driver cluster Configurations for enebale Multi Tier Checkpointing.
6+
"""
17
from absl import logging
2-
from airflow.decorators import task
3-
from airflow.exceptions import AirflowFailException
4-
from kubernetes import client as k8s_client
5-
from kubernetes.client.rest import ApiException
6-
from xlml.utils import gke
78
import yaml
89
import time
910

10-
# --- Utility Functions ---
11+
from kubernetes import client as k8s_client
12+
from kubernetes.client.rest import ApiException
13+
from airflow.decorators import task
14+
from airflow.exceptions import AirflowFailException
15+
16+
from xlml.utils import gke
1117

1218

1319
def _get_custom_objects_api_client(

0 commit comments

Comments
 (0)