1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- """
16- An example DAG to extract profile metrics from pretraining mixtral-8x7b model on v6-256.
17- Profile extraction can be seamlessly integrated with maxtext_sweep_gke_config + (to_name_gen_and_quarantine_task + run).
15+ """An example DAG to extract profile metrics.
16+
17+ Pretraining mixtral-8x7b model on v6-256.
18+ Profile extraction can be seamlessly integrated with
19+ maxtext_sweep_gke_config + (to_name_gen_and_quarantine_task + run).
1820"""
1921
2022import datetime
2123from airflow import models
2224from airflow .utils .task_group import TaskGroup
2325from dags .common import test_owner
24- from dags .common .vm_resource import XpkClusters , DockerImage , Project
26+ from dags .common .vm_resource import XpkClusters , Project
2527from dags .multipod .configs import maxtext_sweep_gke_config
2628from xlml .apis import metric_config
2729
@@ -35,7 +37,10 @@ def dict_to_arg(param_dict):
3537
3638
3739docker_image = {
38- "stable" : "gcr.io/tpu-prod-env-multipod/maxtext_jax_stable_stack:2025-05-20" ,
40+ "stable" : (
41+ "gcr.io/tpu-prod-env-multipod/"
42+ "maxtext_jax_stable_stack:2025-05-20"
43+ ),
3944}
4045
4146# https://github.com/AI-Hypercomputer/maxtext/blob/main/benchmarks/maxtext_trillium_model_configs.py
@@ -45,9 +50,14 @@ def dict_to_arg(param_dict):
4550 "cluster" : XpkClusters .TPU_V6E_256_MLPERF_CLUSTER ,
4651 "train_command" : [
4752 f"export BASE_OUTPUT_PATH={ BASE_OUTPUT_PATH } && "
48- "python3 -m maxtext.trainers.pre_train.train src/maxtext/configs/base.yml base_output_directory=${BASE_OUTPUT_PATH} model_name=mixtral-8x7b "
49- # add profiler config: ensure steps > skip_first_n_steps_for_profiler + profiler_steps
50- "steps=10 profiler=xplane skip_first_n_steps_for_profiler=5 profiler_steps=3 "
53+ "python3 -m maxtext.trainers.pre_train.train "
54+ "src/maxtext/configs/base.yml "
55+ "base_output_directory=${BASE_OUTPUT_PATH} "
56+ "model_name=mixtral-8x7b "
57+ # add profiler config: ensure steps >
58+ # skip_first_n_steps_for_profiler + profiler_steps
59+ "steps=10 profiler=xplane skip_first_n_steps_for_profiler=5 "
60+ "profiler_steps=3 "
5161 + dict_to_arg ({
5262 "per_device_batch_size" : 12 ,
5363 "ici_fsdp_parallelism" : - 1 ,
@@ -81,9 +91,14 @@ def dict_to_arg(param_dict):
8191 "base_output_directory" : "gs://runner-maxtext-logs" ,
8292 "train_command" : [
8393 f"export BASE_OUTPUT_PATH={ BASE_OUTPUT_PATH } && "
84- "python3 -m maxtext.trainers.pre_train.train src/maxtext/configs/base.yml base_output_directory=${BASE_OUTPUT_PATH} model_name=mixtral-8x7b "
85- # add profiler config: ensure steps > skip_first_n_steps_for_profiler + profiler_steps
86- "steps=10 profiler=xplane skip_first_n_steps_for_profiler=5 profiler_steps=3 "
94+ "python3 -m maxtext.trainers.pre_train.train "
95+ "src/maxtext/configs/base.yml "
96+ "base_output_directory=${BASE_OUTPUT_PATH} "
97+ "model_name=mixtral-8x7b "
98+ # add profiler config: ensure steps >
99+ # skip_first_n_steps_for_profiler + profiler_steps
100+ "steps=10 profiler=xplane skip_first_n_steps_for_profiler=5 "
101+ "profiler_steps=3 "
87102 + dict_to_arg ({
88103 "per_device_batch_size" : 12 ,
89104 "ici_fsdp_parallelism" : - 1 ,
@@ -120,25 +135,27 @@ def dict_to_arg(param_dict):
120135 )
121136
122137 for run_name , test_scripts_details in test_models_tpu .items ():
123- for image in docker_image .keys ():
138+ for image , img_val in docker_image .items ():
124139 # sweep num_slices and other training params
125140 # generate run_name and tensorboard/profile location for extraction
126141 num_slices = [1 ]
127142 sweep_params = {}
128- maxtext_sweep_gke_test = maxtext_sweep_gke_config .get_maxtext_sweep_gke_config (
129- test_owner = test_owner .SHUNING_J ,
130- dataset_project = Project .CLOUD_ML_AUTO_SOLUTIONS .value ,
131- composer_project = Project .CLOUD_ML_AUTO_SOLUTIONS .value ,
132- dataset_name = metric_config .DatasetOption .XLML_DATASET ,
133- cluster = test_scripts_details ["cluster" ],
134- time_out_in_min = test_scripts_details ["time_out_in_min" ],
135- base_output_directory = BASE_OUTPUT_PATH ,
136- num_slices = num_slices ,
137- docker_image = docker_image [image ],
138- run_name_prefix = f"maxtext_{ image } _{ run_name } " ,
139- base_run_model_cmds = test_scripts_details ["train_command" ],
140- sweep_params = sweep_params ,
141- enable_profile_config = True , # add flag to enable profile extraction
143+ maxtext_sweep_gke_test = (
144+ maxtext_sweep_gke_config .get_maxtext_sweep_gke_config (
145+ test_owner = test_owner .SHUNING_J ,
146+ dataset_project = Project .CLOUD_ML_AUTO_SOLUTIONS .value ,
147+ composer_project = Project .CLOUD_ML_AUTO_SOLUTIONS .value ,
148+ dataset_name = metric_config .DatasetOption .XLML_DATASET ,
149+ cluster = test_scripts_details ["cluster" ],
150+ time_out_in_min = test_scripts_details ["time_out_in_min" ],
151+ base_output_directory = BASE_OUTPUT_PATH ,
152+ num_slices = num_slices ,
153+ docker_image = img_val ,
154+ run_name_prefix = f"maxtext_{ image } _{ run_name } " ,
155+ base_run_model_cmds = test_scripts_details ["train_command" ],
156+ sweep_params = sweep_params ,
157+ enable_profile_config = True , # add flag to enable profile extraction
158+ )
142159 )
143160
144161 for test in maxtext_sweep_gke_test :
0 commit comments