|
| 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 perf tests for MaxText model configs on V5p. |
| 17 | +""" |
| 18 | +import datetime |
| 19 | +from airflow import models |
| 20 | +from airflow.utils.task_group import TaskGroup |
| 21 | +from dags import composer_env |
| 22 | +from dags.common import test_owner |
| 23 | +from dags.common.vm_resource import Project, XpkClusters, DockerImage |
| 24 | +from dags.common.model_configs import MaxTextV5pModelConfigs |
| 25 | +from dags.multipod.configs import maxtext_sweep_gke_config |
| 26 | +from dags.multipod.configs.common import SetupMode |
| 27 | +from xlml.apis import metric_config |
| 28 | + |
| 29 | +# Run once a day at 4 am UTC (8 pm PST / 9 pm PDT) |
| 30 | +SCHEDULED_TIME = "0 4 * * *" if composer_env.is_prod_env() else None |
| 31 | +DOCKER_IMAGES = [ |
| 32 | + (SetupMode.STABLE, DockerImage.MAXTEXT_TPU_JAX_STABLE_STACK), |
| 33 | + (SetupMode.NIGHTLY, DockerImage.MAXTEXT_TPU_JAX_NIGHTLY), |
| 34 | +] |
| 35 | +QUANTIZATION_SWEEP = {"M_QUANTIZATION": ["", "int8"]} |
| 36 | +BASE_OUTPUT_DIRECTORY = "gs://runner-maxtext-logs" |
| 37 | + |
| 38 | +with models.DAG( |
| 39 | + dag_id="maxtext_v5p_configs_perf", |
| 40 | + schedule=SCHEDULED_TIME, |
| 41 | + tags=[ |
| 42 | + "multipod_team", |
| 43 | + "maxtext", |
| 44 | + "stable", |
| 45 | + "nightly", |
| 46 | + "mlscale_perfx", |
| 47 | + ], |
| 48 | + start_date=datetime.datetime(2024, 2, 19), |
| 49 | + catchup=False, |
| 50 | +) as dag: |
| 51 | + quarantine_task_group = TaskGroup( |
| 52 | + group_id="Quarantine", dag=dag, prefix_group_id=False |
| 53 | + ) |
| 54 | + for mode, image in DOCKER_IMAGES: |
| 55 | + for model in MaxTextV5pModelConfigs: |
| 56 | + base_run_model_cmds = [ |
| 57 | + "bash preflight.sh", |
| 58 | + f"python3 -m benchmarks.benchmark_runner on-device --base_output_directory={BASE_OUTPUT_DIRECTORY} --model_name={model.value} --libtpu_type=maxtext-docker --num_steps=15", |
| 59 | + ] |
| 60 | + maxtext_sweep_gke_test = ( |
| 61 | + maxtext_sweep_gke_config.get_maxtext_sweep_gke_config( |
| 62 | + test_owner=test_owner.RISHABH_B, |
| 63 | + dataset_project=Project.CLOUD_ML_AUTO_SOLUTIONS.value, |
| 64 | + composer_project=Project.CLOUD_ML_AUTO_SOLUTIONS.value, |
| 65 | + dataset_name=metric_config.DatasetOption.XLML_DATASET, |
| 66 | + cluster=XpkClusters.TPU_V5P_128_CLUSTER, |
| 67 | + time_out_in_min=360, |
| 68 | + base_output_directory=BASE_OUTPUT_DIRECTORY, |
| 69 | + num_slices=[1, 2], |
| 70 | + docker_image=image.value, |
| 71 | + run_name_prefix=f"maxtext-{model.name.lower()}-{mode.value}", |
| 72 | + base_run_model_cmds=base_run_model_cmds, |
| 73 | + sweep_params=QUANTIZATION_SWEEP, |
| 74 | + ) |
| 75 | + ) |
| 76 | + |
| 77 | + chain_num = 4 |
| 78 | + prev = maxtext_sweep_gke_test[0].run_with_name_gen_and_quarantine( |
| 79 | + quarantine_task_group |
| 80 | + ) |
| 81 | + for i in range(1, len(maxtext_sweep_gke_test)): |
| 82 | + curr = maxtext_sweep_gke_test[i].run_with_name_gen_and_quarantine( |
| 83 | + quarantine_task_group |
| 84 | + ) |
| 85 | + if i % chain_num != 0: |
| 86 | + prev >> curr |
| 87 | + prev = curr |
0 commit comments