1313# limitations under the License.
1414
1515"""
16- A DAG to run AOT compilation and HybridSim tests for MaxText model configs on TPU v4, v5e.
16+ A DAG to run AOT compilation and HybridSim tests
17+ for MaxText model configs on TPU v4, v5e.
1718"""
1819import datetime
1920from airflow import models
2021from airflow .utils .task_group import TaskGroup
22+
23+ from xlml .utils import name_format
24+ from xlml .apis import metric_config
25+
2126from dags import composer_env
2227from dags .common .quarantined_tests import QuarantineTests
2328from dags .common import test_owner
24- from dags .common .vm_resource import TpuVersion , Zone , DockerImage , XpkClusters , Project
25- from dags .multipod .configs import gke_config
26- from xlml .utils import name_format
29+ from dags .common .vm_resource import TpuVersion , DockerImage , XpkClusters
2730from dags .multipod .configs import gke_config
28- from xlml .apis import metric_config
2931
3032
3133# Run once a day at 1 pm UTC (5 am PST / 6 am PDT)
3234SCHEDULED_TIME = "30 2 * * *" if composer_env .is_prod_env () else None
3335
3436
35- def hybridsim_compile_and_run (test_group_id ):
36- with TaskGroup (group_id = test_group_id , prefix_group_id = True ) as group :
37+ def hybridsim_compile_and_run (group_id ):
38+ with TaskGroup (group_id = group_id , prefix_group_id = True ) as _ :
3739 gcs_subfolder = f"{ test_owner .Team .MULTIPOD .value } /maxtext"
3840 shared_gcs_location = name_format .generate_gcs_folder_location .override (
39- task_id = f"{ test_group_id } _generate_gcs_folder_location"
41+ task_id = f"{ group_id } _generate_gcs_folder_location"
4042 )(
4143 f"{ gcs_subfolder } /maxtext_configs_aot_hybridsim/v{ tpu .value } " ,
42- test_group_id ,
44+ group_id ,
4345 )
4446
47+ tpu_version_str = (
48+ v5e_alt if tpu .value == TpuVersion .V5E .value else tpu .value
49+ )
4550 # Run AOT workload: generate HLO, upload to GCS
4651 aot_cmd = (
47- 'export XLA_FLAGS="--xla_dump_to=/tmp/xla_dump/ --xla_dump_large_constants"' ,
48- f"bash MaxText/configs/v{ v5e_alt if tpu .value == TpuVersion .V5E .value else tpu .value } /{ model_size } .sh EXECUTABLE=train_compile M_COMPILE_TOPOLOGY=v{ v5e_alt if tpu .value == TpuVersion .V5E .value else tpu .value } -{ num_cores } M_COMPILE_TOPOLOGY_NUM_SLICES={ n } " ,
52+ (
53+ 'export XLA_FLAGS="--xla_dump_to=/tmp/xla_dump/'
54+ ' --xla_dump_large_constants"'
55+ ),
56+ (
57+ f"bash src/MaxText/configs/v{ tpu_version_str } /{ model_size } .sh"
58+ " EXECUTABLE=train_compile"
59+ f" M_COMPILE_TOPOLOGY=v{ tpu_version_str } -{ num_cores } "
60+ f" M_COMPILE_TOPOLOGY_NUM_SLICES={ n } "
61+ f" DATASET_PATH=dummy-dataset OUTPUT_PATH=dummy-output-dir"
62+ ),
4963 "gsutil -m cp -r /tmp/xla_dump/ ${GCS_OUTPUT}" ,
5064 )
5165 maxtext_aot = gke_config .get_gke_config (
@@ -61,7 +75,11 @@ def hybridsim_compile_and_run(test_group_id):
6175 chip_config = "default" if tpu == TpuVersion .V5E else "megacore"
6276 hybridsim_cmd = (
6377 "gsutil cp gs://cloud-hybridsim-prod/run_hybridsim.sh ." ,
64- f"bash run_hybridsim.sh GCS_XLA_DUMP_PATH=${{GCS_OUTPUT}}xla_dump GCS_OUTPUT_PATH=${{GCS_OUTPUT}}estimated_cost_ns.jsonl CHIP_CONFIG={ chip_config } MODULE_NAME_PATTERN=jit_train_step*" ,
78+ (
79+ f"bash run_hybridsim.sh GCS_XLA_DUMP_PATH=${{GCS_OUTPUT}}xla_dump"
80+ f" GCS_OUTPUT_PATH=${{GCS_OUTPUT}}estimated_cost_ns.jsonl"
81+ f" CHIP_CONFIG={ chip_config } MODULE_NAME_PATTERN=jit_train_step*"
82+ ),
6583 )
6684 job_metric_config = metric_config .MetricConfig (
6785 json_lines = metric_config .JSONLinesConfig (
@@ -72,14 +90,16 @@ def hybridsim_compile_and_run(test_group_id):
7290 maxtext_hybridsim = gke_config .get_gke_config (
7391 cluster = cluster ,
7492 time_out_in_min = 240 ,
75- test_name = f"maxtext-{ model_size } -{ n } xv{ tpu .value } -{ num_cores } -hybridsim" ,
93+ test_name = (
94+ f"maxtext-{ model_size } -{ n } xv{ tpu .value } -{ num_cores } -hybridsim"
95+ ),
7696 run_model_cmds = hybridsim_cmd ,
7797 docker_image = DockerImage .CLOUD_HYBRIDSIM_NIGHTLY .value ,
7898 test_owner = test_owner .AIRFLOW ,
7999 user_specified_job_metric_config = job_metric_config ,
80100 ).run (gcs_location = shared_gcs_location )
81101
82- shared_gcs_location >> maxtext_aot >> maxtext_hybridsim
102+ _ = shared_gcs_location >> maxtext_aot >> maxtext_hybridsim
83103
84104
85105with models .DAG (
@@ -102,7 +122,12 @@ def hybridsim_compile_and_run(test_group_id):
102122 model_configs = {
103123 # accelerator: [(model_size, num_cores), ...],
104124 TpuVersion .V4 : [("22b" , 128 ), ("52b" , 384 )],
105- TpuVersion .V5E : [("16b" , 256 ), ("32b" , 256 ), ("64b" , 256 ), ("128b" , 256 )],
125+ TpuVersion .V5E : [
126+ ("16b" , 256 ),
127+ ("32b" , 256 ),
128+ ("64b" , 256 ),
129+ ("128b" , 256 ),
130+ ],
106131 }
107132 num_slices = [1 , 2 , 4 , 8 ]
108133 clusters = {
0 commit comments