Skip to content

Commit d0fefd6

Browse files
committed
Fix: Change name of DAG to be mtc and emc. mainly because both of these test are being tested.
Fix: Fix some try and catch exceptions that seems to be unnecessary. Fix: Refactor whole Cpc delete task into two task initiate_cpc and wait_to_delete. wait_to_delete task is a sensor task that will check every 10 s if the delition already happened. Fix: Two Dags testing mtc and emc (with replicator=true and replicator=false) Fix: Change loggin.py library to logging_mtc.py names conflict. 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 adc12a7 commit d0fefd6

11 files changed

Lines changed: 455 additions & 381 deletions

dags/common/test_owner.py

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

6060
# MLCompass
6161
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,

dags/gcs_bucket.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@
2626

2727
# Multi-tier checkpointing need special permission for GCS Bucket
2828
# For further question reach out to Multi-tier Checkpointing Owners.
29-
MTC_BUCKET = "gs://mtc-bucket-us-east5/output"
3029
MTC_AUTOMATION_BUCKET = "gs://mtc-automation-bucket"

dags/multipod/maxtext_multi_tier_p2_checkpointing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
concurrency=2,
4040
) as dag:
4141
base_output_directory = (
42-
f"{gcs_bucket.MTC_BUCKET}/maxtext_multi_tier_p2_checkpointing"
42+
f"{gcs_bucket.MTC_AUTOMATION_BUCKET}/maxtext_multi_tier_p2_checkpointing"
4343
)
4444
dataset_path = gcs_bucket.MAXTEXT_DIR
4545
docker_images = [
Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
"""
2+
A DAG to run MaxText multi-tier and emergency checkpointing tests.
3+
4+
This DAG performs a series of tests to save and validate checkpoints
5+
for the MaxText model. It runs tests in two modes: one with the replicator
6+
service enabled (Multi-tier Checkpointing) and one without
7+
(Emergency Checkpointing). The tests are executed on a TPU multi-pod cluster.
8+
9+
Variables:
10+
SCHEDULE (str): The cron schedule.
11+
DAG_TEST_NAME (str): Unique DAG name.
12+
BASE_OUTPUT_DIRECTORY (str): GCS path for saved checkpoints.
13+
DOCKER_IMAGES (list): Tuples of setup mode and Docker image.
14+
RAM_DISK (str): Local directory mounted on each machine.
15+
TEST_CONFIGS (dict): Accelerator type and slice count.
16+
CLUSTERS (dict): Maps accelerator to TPU cluster configs.
17+
STEP (int): Total training steps.
18+
LOCAL_CHECKPOINT_PERIOD (int): Frequency (in steps) for local checkpoints.
19+
REPLICATOR_BACKUP_INTERVAL_MINUTES (int): Interval (in minutes) for replicator.
20+
NAME_PREFIX (str): Prefix for test run names.
21+
MODEL_NAME (str): Name of the model under test.
22+
"""
23+
24+
import datetime
25+
from dataclasses import asdict
26+
27+
from airflow import models
28+
from airflow.utils.task_group import TaskGroup
29+
30+
from dags import composer_env, gcs_bucket
31+
from dags.common import test_owner
32+
from dags.common.vm_resource import DockerImage, XpkClusters
33+
from dags.multipod.configs import gke_config
34+
from dags.multipod.configs.common import SetupMode
35+
from dags.orbax.util import logging_mtc as log
36+
from dags.orbax.util import multi_tier_checkpoint_util as mtc
37+
from xlml.utils.xpk import BRANCH_ABHINAV_MTC
38+
from absl import logging
39+
40+
SCHEDULE = "0 10 * * *" if composer_env.is_prod_env() else None
41+
DAG_TEST_NAME = "maxtext_emc_and_mtc_orbax_save_local"
42+
BASE_OUTPUT_DIRECTORY = (
43+
f"{gcs_bucket.MTC_AUTOMATION_BUCKET}/"
44+
)
45+
DOCKER_IMAGES = [(
46+
SetupMode.NIGHTLY,
47+
DockerImage.MAXTEXT_TPU_JAX_NIGHTLY,
48+
)]
49+
RAM_DISK = "/local"
50+
TEST_CONFIGS = {"v5p-128": [2]}
51+
CLUSTERS = {"v5p-128": XpkClusters.TPU_V5P_128_CLUSTER_ORBAX}
52+
STEP = 100
53+
LOCAL_CHECKPOINT_PERIOD = 20
54+
REPLICATOR_BACKUP_INTERVAL_MINUTES = 30
55+
NAME_PREFIX = "max-sv"
56+
MODEL_NAME = "llama2-7b"
57+
58+
with models.DAG(
59+
dag_id=DAG_TEST_NAME,
60+
schedule_interval=SCHEDULE,
61+
tags=[
62+
"multipod_team",
63+
"maxtext",
64+
"emergency_checkpoint_manager",
65+
"multitier_checkpointing",
66+
"nightly",
67+
"orbax",
68+
],
69+
start_date=datetime.datetime(2025, 6, 12),
70+
catchup=False,
71+
concurrency=2,
72+
) as dag:
73+
tests_to_run_seq = []
74+
for use_replicator_flag in [True, False]:
75+
76+
# These are the two test cases we are testing
77+
# use_replicator = True --> Multi-tier Checkpointing
78+
# use_replicator = False --> Emergency Checkpointing
79+
prefix_replicator = "mtc" if use_replicator_flag else "emc"
80+
folder = f"maxtext_{prefix_replicator}_orbax_save_local"
81+
BASE_OUTPUT_DIRECTORY = f"{gcs_bucket.MTC_AUTOMATION_BUCKET}/{folder}"
82+
with TaskGroup(
83+
group_id=f"maxtext_{prefix_replicator}_orbax_save_local"
84+
) as task:
85+
for mode, image in DOCKER_IMAGES:
86+
for accelerator, slices in TEST_CONFIGS.items():
87+
for slice_num in slices:
88+
89+
# Multi-tier Checkpointing Configuration
90+
# TODO(Camilo): Make this configurable based on the accelerator type.
91+
# Currently, it is hardcoded for v5p.
92+
cpc_conf = (
93+
CLUSTERS[accelerator].project,
94+
CLUSTERS[accelerator].zone[:-2],
95+
CLUSTERS[accelerator].name,
96+
gcs_bucket.MTC_AUTOMATION_BUCKET.split("gs://")[1],
97+
"ct5p-hightpu-4t",
98+
"google.com/tpu",
99+
"800000Mi",
100+
)
101+
102+
# We conditionally set the trigger_rule on the first task.
103+
# If first task group failed the next one can execute.
104+
init_delete_cpc = mtc.initiate_cpc_deletion(*cpc_conf)
105+
wait_delete_cpc = mtc.wait_for_cpc_deletion.override(trigger_rule="all_done")(*cpc_conf)
106+
apply_cpc = mtc.apply_cpc(*cpc_conf)
107+
run_time = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")
108+
run_name = f"{NAME_PREFIX}-{prefix_replicator}-{slice_num}x-{accelerator}-{run_time}"
109+
workload_command = (
110+
"export TPU_PREMAPPED_BUFFER_SIZE=52428800000 && "
111+
"export TPU_PREMAPPED_BUFFER_TRANSFER_THRESHOLD_BYTES=52428800000 && "
112+
"python3 -m MaxText.train MaxText/configs/base.yml remat_policy=full "
113+
f"global_parameter_scale=1 base_output_directory={BASE_OUTPUT_DIRECTORY} "
114+
f"dataset_type=synthetic steps={STEP} per_device_batch_size=1 "
115+
f"max_target_length=256 model_name={MODEL_NAME} per_device_batch_size=2 "
116+
"reuse_example_batch=1 enable_emergency_checkpoint=true "
117+
f"local_checkpoint_directory={RAM_DISK} local_checkpoint_period={LOCAL_CHECKPOINT_PERIOD} "
118+
f"use_replicator_service={use_replicator_flag} replicator_backup_interval_minutes={REPLICATOR_BACKUP_INTERVAL_MINUTES} "
119+
f"run_name={run_name}",
120+
)
121+
122+
start_time = log.generate_timestamp()
123+
124+
maxtext_chkpt_run_test = gke_config.get_gke_config(
125+
num_slices=slice_num,
126+
cluster=CLUSTERS[accelerator],
127+
time_out_in_min=60,
128+
test_name=f"{NAME_PREFIX}-{prefix_replicator}",
129+
run_model_cmds=workload_command,
130+
docker_image=image.value,
131+
test_owner=test_owner.CAMILO,
132+
).run(
133+
ramdisk_directory=RAM_DISK,
134+
mtc_enabled=True,
135+
xpk_branch=BRANCH_ABHINAV_MTC,
136+
skip_post_process=True,
137+
)
138+
139+
cleanup_command = (f"rm -rf {RAM_DISK}/*",)
140+
ram_disk_cleanup = gke_config.get_gke_config(
141+
num_slices=slice_num,
142+
cluster=CLUSTERS[accelerator],
143+
time_out_in_min=60,
144+
test_name=f"{NAME_PREFIX}-cl",
145+
run_model_cmds=cleanup_command,
146+
docker_image=image.value,
147+
test_owner=test_owner.CAMILO,
148+
).run(
149+
ramdisk_directory=RAM_DISK,
150+
mtc_enabled=True,
151+
xpk_branch=BRANCH_ABHINAV_MTC,
152+
skip_post_process=True,
153+
)
154+
155+
end_time = log.generate_timestamp()
156+
vali_step = STEP- 1
157+
vali_step_list = [
158+
i for i in range(0, vali_step, LOCAL_CHECKPOINT_PERIOD)
159+
]
160+
vali_step_list.append(vali_step)
161+
162+
# Here we are looking for the string '(blocking + background)'.
163+
# We will compare expected steps with the ones we found when query this regex. Should be the same
164+
# If for some reason the restore start from 0 this task will fail because len(valid_step_list) != len(founded_steps)
165+
validate_log = log.validate_log_with_step(
166+
project_id=CLUSTERS[accelerator].project,
167+
location=CLUSTERS[accelerator].zone[:-2],
168+
cluster_name=CLUSTERS[accelerator].name,
169+
text_filter="(blocking + background).",
170+
start_time=start_time,
171+
end_time=end_time,
172+
vali_step_list=vali_step_list,
173+
)
174+
175+
(
176+
init_delete_cpc
177+
>> wait_delete_cpc
178+
>> apply_cpc
179+
>> start_time
180+
>> maxtext_chkpt_run_test
181+
>> ram_disk_cleanup
182+
>> end_time
183+
>> validate_log
184+
)
185+
# Add to a global list of test to be run in a sequential way
186+
tests_to_run_seq.append(task)
187+
188+
# Chain the task groups sequentially
189+
for idx_test in range(len(tests_to_run_seq) - 1):
190+
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: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
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
10+
1011

1112
@task
1213
def generate_timestamp():

0 commit comments

Comments
 (0)