|
12 | 12 | # See the License for the specific language governing permissions and |
13 | 13 | # limitations under the License. |
14 | 14 |
|
15 | | -""" |
16 | | -An example DAG to extract profile metrics from pretraining mixtral-8x7b model on 1xv4-128. |
| 15 | +"""An example DAG to extract profile metrics. |
| 16 | +
|
| 17 | +Pretraining mixtral-8x7b model on 1xv4-128. |
17 | 18 | Profile extraction can be easily integrated with gke_config + (to_name_gen_and_quarantine_task + run). |
18 | 19 | """ |
19 | 20 |
|
20 | 21 | import datetime |
21 | 22 | from airflow import models |
22 | 23 | from dags.common import test_owner |
23 | | -from dags.common.vm_resource import XpkClusters, DockerImage |
| 24 | +from dags.common.vm_resource import XpkClusters |
24 | 25 | from dags.multipod.configs import gke_config |
25 | 26 | from xlml.apis import metric_config |
26 | 27 |
|
27 | 28 | SCHEDULED_TIME = None |
28 | 29 | BASE_OUTPUT_PATH = "gs://runner-maxtext-logs" |
29 | 30 |
|
30 | 31 | docker_image = { |
31 | | - "stable": "gcr.io/tpu-prod-env-multipod/maxtext_jax_stable_stack:2025-05-20", |
| 32 | + "stable": ( |
| 33 | + "gcr.io/tpu-prod-env-multipod/" "maxtext_jax_stable_stack:2025-05-20" |
| 34 | + ), |
32 | 35 | } |
33 | 36 |
|
34 | 37 | base_command = ( |
35 | 38 | f"export BASE_OUTPUT_PATH={BASE_OUTPUT_PATH} && " |
36 | | - + "python3 -m maxtext.trainers.pre_train.train src/maxtext/configs/base.yml base_output_directory=gs://runner-maxtext-logs run_name=${RUN_NAME} model_name=mixtral-8x7b tokenizer_path=assets/tokenizer.mistral-v1 dataset_path=gs://maxtext-dataset per_device_batch_size=4 enable_checkpointing=false ici_fsdp_parallelism=-1 max_target_length=1024 async_checkpointing=false attention=flash dtype=bfloat16 weight_dtype=bfloat16" |
| 39 | + "python3 -m maxtext.trainers.pre_train.train " |
| 40 | + "src/maxtext/configs/base.yml " |
| 41 | + "base_output_directory=gs://runner-maxtext-logs " |
| 42 | + "run_name=${RUN_NAME} model_name=mixtral-8x7b " |
| 43 | + "tokenizer_path=assets/tokenizer.mistral-v1 " |
| 44 | + "dataset_path=gs://maxtext-dataset per_device_batch_size=4 " |
| 45 | + "enable_checkpointing=false ici_fsdp_parallelism=-1 " |
| 46 | + "max_target_length=1024 async_checkpointing=false " |
| 47 | + "attention=flash dtype=bfloat16 weight_dtype=bfloat16" |
37 | 48 | ) |
38 | 49 |
|
39 | 50 | test_models_tpu = { |
40 | 51 | # use: upload single profile from the first host, extract profile |
41 | | - # add profiler config: ensure steps > skip_first_n_steps_for_profiler + profiler_steps |
| 52 | + # add profiler config: ensure steps > |
| 53 | + # skip_first_n_steps_for_profiler + profiler_steps |
42 | 54 | "mixtral-8x7b_pretraining-megablox_config-true_upload-one": { |
43 | 55 | "cluster": XpkClusters.TPU_V4_128_CLUSTER, |
44 | 56 | "time_out_in_min": 60, |
45 | 57 | "train_command": [ |
46 | | - base_command |
47 | | - + " steps=10 profiler=xplane skip_first_n_steps_for_profiler=5 profiler_steps=3", |
| 58 | + base_command + " steps=10 profiler=xplane " |
| 59 | + "skip_first_n_steps_for_profiler=5 profiler_steps=3", |
48 | 60 | ], |
49 | 61 | }, |
50 | 62 | # use: upload profiles from all hosts, extract one of the profiles |
51 | | - # add profiler config: ensure steps > skip_first_n_steps_for_profiler + profiler_steps |
| 63 | + # add profiler config: ensure steps > |
| 64 | + # skip_first_n_steps_for_profiler + profiler_steps |
52 | 65 | "mixtral-8x7b_pretraining-megablox_config-true_upload-all": { |
53 | 66 | "cluster": XpkClusters.TPU_V4_128_CLUSTER, |
54 | 67 | "time_out_in_min": 60, |
55 | 68 | "train_command": [ |
56 | | - base_command |
57 | | - + " steps=10 profiler=xplane skip_first_n_steps_for_profiler=5 profiler_steps=3 upload_all_profiler_results=True", |
| 69 | + base_command + " steps=10 profiler=xplane " |
| 70 | + "skip_first_n_steps_for_profiler=5 profiler_steps=3 " |
| 71 | + "upload_all_profiler_results=True", |
58 | 72 | ], |
59 | 73 | }, |
60 | | - # testing: handle edge case, attempt to extract, find no match, proceed to post_process without error |
| 74 | + # testing: handle edge case, attempt to extract, find no match, |
| 75 | + # proceed to post_process without error |
61 | 76 | "testing_config-true_upload-none": { |
62 | 77 | "cluster": XpkClusters.TPU_V4_128_CLUSTER, |
63 | 78 | "time_out_in_min": 60, |
64 | 79 | "train_command": [ |
65 | 80 | base_command + " steps=10", |
66 | 81 | ], |
67 | 82 | }, |
68 | | - # testing: not generate profile location, not extract profile in post_process |
| 83 | + # testing: not generate profile location, not extract profile in |
| 84 | + # post_process |
69 | 85 | "testing_config-false_upload-one": { |
70 | 86 | "cluster": XpkClusters.TPU_V4_128_CLUSTER, |
71 | 87 | "time_out_in_min": 60, |
72 | 88 | "train_command": [ |
73 | | - base_command |
74 | | - + " steps=10 profiler=xplane skip_first_n_steps_for_profiler=5 profiler_steps=3", |
| 89 | + base_command + " steps=10 profiler=xplane " |
| 90 | + "skip_first_n_steps_for_profiler=5 profiler_steps=3", |
75 | 91 | ], |
76 | 92 | "not_add_profile_config": True, |
77 | 93 | }, |
|
87 | 103 | concurrency=2, |
88 | 104 | ) as dag: |
89 | 105 | for run_name, test_scripts_details in test_models_tpu.items(): |
90 | | - for image in docker_image.keys(): |
| 106 | + for image, img_val in docker_image.items(): |
91 | 107 | # file_location: pass in base_output_directory, will be altered in |
92 | 108 | # XpkNameGenAndQuarantineTask.run_with_run_name_generation |
93 | 109 | job_metric_config = metric_config.MetricConfig() |
|
112 | 128 | time_out_in_min=test_scripts_details["time_out_in_min"], |
113 | 129 | test_name=f"maxtext_{image}_{run_name}", |
114 | 130 | run_model_cmds=test_scripts_details["train_command"], |
115 | | - docker_image=docker_image[image], |
| 131 | + docker_image=img_val, |
116 | 132 | test_owner=test_owner.SHUNING_J, |
117 | 133 | cluster=test_scripts_details["cluster"], |
118 | | - user_specified_job_metric_config=job_metric_config, # customize config |
| 134 | + user_specified_job_metric_config=( |
| 135 | + job_metric_config |
| 136 | + ), # customize config |
119 | 137 | ) |
120 | 138 | .to_name_gen_and_quarantine_task(run_name_env="RUN_NAME") |
121 | 139 | .run() |
|
0 commit comments