Skip to content

Commit 1e7b72a

Browse files
committed
Fix format/linting errors and set the quarantine_task_group arg default to None
1 parent ff5e160 commit 1e7b72a

6 files changed

Lines changed: 55 additions & 26 deletions

dags/examples/maxtext_aqtp_version_sweep_gke_example_dag.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import datetime
2222
from airflow import models
2323
from dags.common import test_owner
24-
from dags.common.vm_resource import TpuVersion, Zone, Project, XpkClusters, DockerImage
24+
from dags.common.vm_resource import XpkClusters, DockerImage
2525
from dags.multipod.configs import maxtext_sweep_gke_config
2626

2727
# Set concurrency to number of workers otherwise tasks may time out
@@ -54,7 +54,11 @@
5454
for model_size in models:
5555
run_cmds = [
5656
"pip show aqtp",
57-
f"bash src/maxtext/configs/tpu/{tpu}/{model_size}.sh EXECUTABLE=train.py OUTPUT_PATH={base_output_directory} PLATFORM=gke",
57+
(
58+
f"bash src/maxtext/configs/tpu/{tpu}/{model_size}.sh "
59+
f"EXECUTABLE=train.py OUTPUT_PATH={base_output_directory} "
60+
"PLATFORM=gke"
61+
),
5862
]
5963

6064
tests.extend(

dags/examples/maxtext_profile_namegen_example_dag.py

Lines changed: 36 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,66 +12,82 @@
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 1xv4-128.
15+
"""An example DAG to extract profile metrics.
16+
17+
Pretraining mixtral-8x7b model on 1xv4-128.
1718
Profile extraction can be easily integrated with gke_config + (to_name_gen_and_quarantine_task + run).
1819
"""
1920

2021
import datetime
2122
from airflow import models
2223
from dags.common import test_owner
23-
from dags.common.vm_resource import XpkClusters, DockerImage
24+
from dags.common.vm_resource import XpkClusters
2425
from dags.multipod.configs import gke_config
2526
from xlml.apis import metric_config
2627

2728
SCHEDULED_TIME = None
2829
BASE_OUTPUT_PATH = "gs://runner-maxtext-logs"
2930

3031
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+
),
3235
}
3336

3437
base_command = (
3538
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"
3748
)
3849

3950
test_models_tpu = {
4051
# 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
4254
"mixtral-8x7b_pretraining-megablox_config-true_upload-one": {
4355
"cluster": XpkClusters.TPU_V4_128_CLUSTER,
4456
"time_out_in_min": 60,
4557
"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",
4860
],
4961
},
5062
# 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
5265
"mixtral-8x7b_pretraining-megablox_config-true_upload-all": {
5366
"cluster": XpkClusters.TPU_V4_128_CLUSTER,
5467
"time_out_in_min": 60,
5568
"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",
5872
],
5973
},
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
6176
"testing_config-true_upload-none": {
6277
"cluster": XpkClusters.TPU_V4_128_CLUSTER,
6378
"time_out_in_min": 60,
6479
"train_command": [
6580
base_command + " steps=10",
6681
],
6782
},
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
6985
"testing_config-false_upload-one": {
7086
"cluster": XpkClusters.TPU_V4_128_CLUSTER,
7187
"time_out_in_min": 60,
7288
"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",
7591
],
7692
"not_add_profile_config": True,
7793
},
@@ -87,7 +103,7 @@
87103
concurrency=2,
88104
) as dag:
89105
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():
91107
# file_location: pass in base_output_directory, will be altered in
92108
# XpkNameGenAndQuarantineTask.run_with_run_name_generation
93109
job_metric_config = metric_config.MetricConfig()
@@ -112,10 +128,12 @@
112128
time_out_in_min=test_scripts_details["time_out_in_min"],
113129
test_name=f"maxtext_{image}_{run_name}",
114130
run_model_cmds=test_scripts_details["train_command"],
115-
docker_image=docker_image[image],
131+
docker_image=img_val,
116132
test_owner=test_owner.SHUNING_J,
117133
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
119137
)
120138
.to_name_gen_and_quarantine_task(run_name_env="RUN_NAME")
121139
.run()

dags/examples/maxtext_profile_sweep_example_dag.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from airflow.utils.task_group import TaskGroup
2525
from dags.common import test_owner
2626
from dags.common.vm_resource import XpkClusters, Project
27-
from dags.multipod.configs import maxtext_sweep_gke_config
27+
from dags.multipod.configs import maxtext_sweep_gke_config as sweep_config
2828
from xlml.apis import metric_config
2929

3030
SCHEDULED_TIME = None
@@ -139,7 +139,7 @@ def dict_to_arg(param_dict):
139139
# generate run_name and tensorboard/profile location for extraction
140140
num_slices = [1]
141141
sweep_params = {}
142-
maxtext_sweep_gke_test = maxtext_sweep_gke_config.get_maxtext_sweep_gke_config(
142+
maxtext_sweep_gke_test = sweep_config.get_maxtext_sweep_gke_config(
143143
test_owner=test_owner.SHUNING_J,
144144
dataset_project=Project.CLOUD_ML_AUTO_SOLUTIONS.value,
145145
composer_project=Project.CLOUD_ML_AUTO_SOLUTIONS.value,

dags/examples/maxtext_sweep_gke_example_dag.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import datetime
2222
from airflow import models
2323
from dags.common import test_owner
24-
from dags.common.vm_resource import TpuVersion, Zone, Project, XpkClusters, DockerImage
24+
from dags.common.vm_resource import XpkClusters, DockerImage
2525
from dags.multipod.configs import maxtext_sweep_gke_config
2626

2727
# Set concurrency to number of workers otherwise tasks may time out
@@ -37,7 +37,13 @@
3737
# MaxText set up and run commands
3838
base_output_directory = "gs://maxtext-experiments-multipod"
3939
base_run_model_cmds = [
40-
f"python3 -m maxtext.trainers.pre_train.train src/maxtext/configs/base.yml base_output_directory={base_output_directory} dataset_path=gs://max-datasets-rogue enable_checkpointing=false global_parameter_scale=16 steps=10",
40+
(
41+
"python3 -m maxtext.trainers.pre_train.train "
42+
"src/maxtext/configs/base.yml "
43+
f"base_output_directory={base_output_directory} "
44+
"dataset_path=gs://max-datasets-rogue enable_checkpointing=false "
45+
"global_parameter_scale=16 steps=10"
46+
),
4147
]
4248

4349
# Get list of MaxText GKE XPK jobs

dags/multipod/maxtext_convergence.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484

8585
sequential_tests = []
8686
for test_name, run_command in convergence_tests.items():
87-
# The grain dataset takes longer to run, so we give it a longer timeout. The other tests are expected to complete within 5 hours.
87+
# The grain dataset takes longer to run, so we give it a longer timeout.
88+
# The other tests are expected to complete within 5 hours.
8889
timeout_in_min = 360 if test_name == "maxtext-convergence-grain" else 300
8990

9091
test_task = (

xlml/apis/task.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ def to_node_interruption_task(
388388

389389
def to_name_gen_and_quarantine_task(
390390
self,
391-
quarantine_task_group,
391+
quarantine_task_group: Any = None,
392392
run_name_env: str = "M_RUN_NAME",
393393
nested_run_name_in_tb_file_location: bool = True,
394394
) -> "XpkNameGenAndQuarantineTask":

0 commit comments

Comments
 (0)