Skip to content

Commit 1a3bfe0

Browse files
authored
fix: Simplify pw_mcjax_benchmark_recipe (GoogleCloudPlatform#1258)
This change simplifies the `pw_mcjax_benchmark_recipe` DAG by removing the unused BigQuery integration and replacing the customized `wait_workload_complete` with the existing library.
1 parent ffc2f25 commit 1a3bfe0

3 files changed

Lines changed: 4 additions & 102 deletions

File tree

dags/maxtext_pathways/configs/parameters.py

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@
7676
title="Core Count",
7777
description='Device core count for the cluster. ex: v6e-"64"',
7878
),
79-
"benchmark_steps": Param(
80-
20,
81-
type="integer",
82-
title="Benchmark Steps",
83-
description="Number of benchmark steps.",
84-
),
8579
"num_slices_list": Param(
8680
1,
8781
type="integer",
@@ -152,34 +146,4 @@
152146
title="Max Restarts",
153147
description="Max restarts for the workload",
154148
),
155-
"bq_enable": Param(
156-
False,
157-
type="boolean",
158-
title="BigQuery Enable",
159-
description="Enable BigQuery to store metrics data",
160-
),
161-
"bq_db_project": Param(
162-
"cloud-tpu-multipod-dev",
163-
type="string",
164-
title="BigQuery Database Project",
165-
description="The Project of BigQuery Database",
166-
),
167-
"bq_db_dataset": Param(
168-
# TODO(b/451750407): Replace this temporary image with a formal one.
169-
"chzheng_test_100steps",
170-
type="string",
171-
title="BigQuery Database Dataset",
172-
description="The Dataset of BigQuery Database",
173-
),
174-
"override_timeout_in_min": Param(
175-
None,
176-
type=["null", "integer"],
177-
title="Override Timeout In Minutes",
178-
description=(
179-
"Timeout in minutes for the workload task. Adjust it when you "
180-
"meet (airflow.exceptions.AirflowException: Timed out after ...) "
181-
"issue. The default value `None` means automatic calculation "
182-
"of timeout."
183-
),
184-
),
185149
}

dags/maxtext_pathways/configs/recipe_config.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def run_command(self) -> str:
4141
"cluster_name",
4242
"project",
4343
"zone",
44-
"benchmark_steps",
4544
"num_slices_list",
4645
"server_image",
4746
"proxy_image",
@@ -50,9 +49,6 @@ def run_command(self) -> str:
5049
"selected_model_names",
5150
"priority",
5251
"max_restarts",
53-
"bq_enable",
54-
"bq_db_project",
55-
"bq_db_dataset",
5652
"workload_id",
5753
"device_type",
5854
]

dags/maxtext_pathways/pw_mcjax_dags.py

Lines changed: 4 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -162,60 +162,6 @@ def clean_up_pod(
162162
), f"kubectl clean-up failed with code {result.exit_code}"
163163

164164

165-
@task
166-
def wait_workload_complete(
167-
workload_id: str,
168-
project_id: str,
169-
region: str,
170-
cluster_name: str,
171-
benchmark_steps: int,
172-
override_timeout_in_min: int = 10,
173-
poke_interval_in_second: int = 60,
174-
) -> bool:
175-
"""
176-
Checks for the completion of an workload by repeatedly executing its core logic.
177-
The core logic uses workload logs to report the detailed status of successful or failed completion.
178-
"""
179-
# Extract and reuse the logic in the` xpk` module to wait for a workload to be completed.
180-
impl = getattr(
181-
xpk.wait_for_workload_completion, "python_callable", None
182-
) or getattr(xpk.wait_for_workload_completion, "__wrapped__", None)
183-
184-
if impl is None:
185-
raise AirflowException(
186-
f"Cannot extract core callable from {xpk.wait_for_workload_completion}."
187-
"It might not be a valid task/sensor or is wrapped too deeply."
188-
)
189-
190-
# Dynamically sets the Airflow task timeout based on a custom flag or calculates it using a benchmark step count.
191-
if override_timeout_in_min:
192-
timeout_in_min = override_timeout_in_min
193-
else:
194-
max_step_min = 5 # Average time required for each step in lama3-1-405b.
195-
timeout_in_min = benchmark_steps * max_step_min
196-
197-
timeout_in_sec = timeout_in_min * 60
198-
199-
logging.info(
200-
f"The timeout for this task is {timeout_in_min} minutes ({timeout_in_sec} seconds).\n"
201-
f"Check if completed every {poke_interval_in_second} seconds."
202-
)
203-
204-
deadline = datetime.datetime.now() + datetime.timedelta(
205-
seconds=timeout_in_sec
206-
)
207-
while datetime.datetime.now() < deadline:
208-
# Call the core function to check if the workload is complete.
209-
if impl(workload_id, project_id, region, cluster_name):
210-
return True
211-
212-
time.sleep(poke_interval_in_second)
213-
214-
raise AirflowException(
215-
f"Timed out after {timeout_in_min}min({timeout_in_sec}s). Please adjust `Override Timeout In Minutes` in UI input."
216-
)
217-
218-
219165
RECIPE_INSTANCE = recipe_cfg.Recipe.PW_MCJAX_BENCHMARK_RECIPE
220166
RECIPE_NAME = RECIPE_INSTANCE.value.lower()
221167

@@ -247,7 +193,6 @@ def wait_workload_complete(
247193
248194
### Prerequisites
249195
- This test requires an existing cluster.
250-
- This test requires that a dataset with the same name as the UI parameter "[BigQuery Database Dataset]".
251196
- If you're using a service account to pull an image from a different project, you need to grant the service account the `Artifact Registry Reader` role in that project.
252197
253198
### Procedures
@@ -276,16 +221,13 @@ def wait_workload_complete(
276221
image_full_url=dag_params["runner"],
277222
)
278223

279-
check_recipe_log = wait_workload_complete.override(
280-
task_id="check_recipe_log",
224+
wait_for_workload_complete = xpk.wait_for_workload_completion.override(
225+
task_id="wait_for_workload_complete",
281226
)(
282227
workload_id=derived_params["workload_id"],
283228
project_id=dag_params["project"],
284229
region=derived_params["region"],
285230
cluster_name=dag_params["cluster_name"],
286-
benchmark_steps=dag_params["benchmark_steps"],
287-
override_timeout_in_min=dag_params["override_timeout_in_min"],
288-
poke_interval_in_second=30,
289231
)
290232

291233
clean_up_recipe = xpk.clean_up_workload.override(
@@ -302,7 +244,7 @@ def wait_workload_complete(
302244
>> derived_params
303245
>> commands
304246
>> start_recipe
305-
>> check_recipe_log
247+
>> wait_for_workload_complete
306248
>> clean_up_recipe
307249
)
308-
start_recipe >> check_recipe_log
250+
start_recipe >> wait_for_workload_complete

0 commit comments

Comments
 (0)