|
| 1 | +# Copyright 2025 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +""" |
| 16 | +A DAG to run MaxText multi-tier checkpointing tests. |
| 17 | +""" |
| 18 | +import datetime |
| 19 | +from airflow import models |
| 20 | +from dags import composer_env, gcs_bucket |
| 21 | +from dags.common import test_owner |
| 22 | +from dags.common.vm_resource import TpuVersion, Zone, DockerImage, XpkClusters |
| 23 | +from dags.multipod.configs import gke_config |
| 24 | +from dags.multipod.configs.common import SetupMode # Run once a day at 10 am UTC (2 am PST) |
| 25 | + |
| 26 | +SCHEDULED_TIME = "0 10 * * *" if composer_env.is_prod_env() else None |
| 27 | + |
| 28 | +with models.DAG( |
| 29 | + dag_id="maxtext_muti_tier_p2_checkpointing", |
| 30 | + schedule=SCHEDULED_TIME, |
| 31 | + tags=[ |
| 32 | + "multipod_team", |
| 33 | + "maxtext", |
| 34 | + "multi_tier_checkpointing_p2", |
| 35 | + "nightly", |
| 36 | + ], |
| 37 | + start_date=datetime.datetime(2025, 4, 17), |
| 38 | + catchup=False, |
| 39 | + concurrency=2, |
| 40 | +) as dag: |
| 41 | + base_output_directory = ( |
| 42 | + f"{gcs_bucket.BASE_OUTPUT_DIR}/maxtext_multi_tier_p2_checkpointing" |
| 43 | + ) |
| 44 | + dataset_path = gcs_bucket.MAXTEXT_DIR |
| 45 | + docker_images = [ |
| 46 | + (SetupMode.NIGHTLY, DockerImage.MAXTEXT_TPU_JAX_NIGHTLY), |
| 47 | + ] |
| 48 | + test_configs = { |
| 49 | + # accelerator: list of slices to test |
| 50 | + "v6e-16": [3], |
| 51 | + } |
| 52 | + clusters = { |
| 53 | + # accelerator: cluster name |
| 54 | + "v6e-16": XpkClusters.TPU_V6E_16_IN_MEM_CLUSTER, |
| 55 | + } |
| 56 | + |
| 57 | + for mode, image in docker_images: |
| 58 | + for accelerator, slices in test_configs.items(): |
| 59 | + for slice_num in slices: |
| 60 | + command = ( |
| 61 | + "bash end_to_end/test_mtc_phase_2_save_path.sh" |
| 62 | + f" multi_tier_checkpointing-{slice_num}x-{accelerator}" |
| 63 | + f" {base_output_directory} {dataset_path}", |
| 64 | + ) |
| 65 | + maxtext_v6e_chkpt_save_test = gke_config.get_gke_config( |
| 66 | + num_slices=slice_num, |
| 67 | + cluster=clusters[accelerator], |
| 68 | + time_out_in_min=60, |
| 69 | + test_name="maxtext-multi-tier-checkpointing-p2-save", |
| 70 | + run_model_cmds=command, |
| 71 | + docker_image=image.value, |
| 72 | + test_owner=test_owner.ABHINAV_S, |
| 73 | + ).run(ramdisk_directory="local", mtc_enabled=True) |
| 74 | + |
| 75 | + command = "rm -rf /local/*" |
| 76 | + ramdisk_single_slice_cleanup = gke_config.get_gke_config( |
| 77 | + num_slices=1, |
| 78 | + cluster=clusters[accelerator], |
| 79 | + time_out_in_min=60, |
| 80 | + test_name="maxtext-multi-tier-checkpointing-p2-emulate-disruption", |
| 81 | + run_model_cmds=command, |
| 82 | + docker_image=image.value, |
| 83 | + test_owner=test_owner.ABHINAV_S, |
| 84 | + ).run(ramdisk_directory="local", mtc_enabled=True) |
| 85 | + command = ( |
| 86 | + "bash end_to_end/test_mtc_phase_2_save_path.sh" |
| 87 | + f" multi_tier_checkpointing-{slice_num}x-{accelerator}" |
| 88 | + f" {base_output_directory} {dataset_path}", |
| 89 | + ) |
| 90 | + |
| 91 | + maxtext_v6e_chkpt_restore_test = gke_config.get_gke_config( |
| 92 | + num_slices=slice_num, |
| 93 | + cluster=clusters[accelerator], |
| 94 | + time_out_in_min=60, |
| 95 | + test_name="maxtext-multi-tier-checkpointing-p2-restore", |
| 96 | + run_model_cmds=command, |
| 97 | + docker_image=image.value, |
| 98 | + test_owner=test_owner.ABHINAV_S, |
| 99 | + ).run(ramdisk_directory="local", mtc_enabled=True) |
| 100 | + |
| 101 | + ( |
| 102 | + maxtext_v6e_chkpt_save_test |
| 103 | + >> ramdisk_single_slice_cleanup |
| 104 | + >> maxtext_v6e_chkpt_restore_test |
| 105 | + ) |
0 commit comments