-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathrun_mantaray_jobs.py
133 lines (122 loc) · 4.53 KB
/
run_mantaray_jobs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""DAGs to run Mantaray benchmarks."""
import datetime
# import _datetime
from airflow import models
from xlml.utils import mantaray
import yaml
from dags import composer_env
import re
from airflow.decorators import task
from xlml.utils import xpk
from dags.common import test_owner
# Skip running this script in unit test because gcs loading will fail.
if composer_env.is_prod_env() or composer_env.is_dev_env():
# Download xlml_jobs.yaml from the borgcron GCS bucket, which
# is pulled nightly from google3.
xlml_jobs_yaml = mantaray.load_file_from_gcs(
f"{mantaray.MANTARAY_G3_GS_BUCKET}/xlml_jobs/xlml_jobs.yaml"
)
xlml_jobs = yaml.safe_load(xlml_jobs_yaml)
# Create a DAG for PyTorch/XLA tests
pattern = r"^(ptxla|pytorchxla).*"
workload_file_name_list = []
for job in xlml_jobs:
if re.match(pattern, job["task_name"]):
workload_file_name_list.append(job["file_name"])
@task.python(multiple_outputs=True)
def hello_world_vllm(params: dict = None):
dag.log.info(params)
print("Hello world vLLM!")
# merge all PyTorch/XLA tests ino one Dag
with models.DAG(
dag_id="pytorch_xla_model_regression_test_on_trillium",
schedule="0 0 * * *", # everyday at midnight # job["schedule"],
tags=["mantaray", "pytorchxla", "xlml"],
start_date=datetime.datetime(2024, 4, 22),
catchup=False,
) as dag:
for workload_file_name in workload_file_name_list:
run_workload = mantaray.run_workload.override(
task_id=workload_file_name.split(".")[0]
)(
workload_file_name=workload_file_name,
)
run_workload
# hello_world_vllm
workload_id="nightly-vllm-"+datetime.datetime.now().strftime("%Y%m%d%H%M%S%f")
cluster_name="b397493880-repo3"
cluster_project="cloud-tpu-multipod-dev"
zone="europe-west4-b"
region="europe-west4"
workload_provision_timeout = datetime.timedelta(seconds=30).total_seconds()
workload_run_timeout = datetime.timedelta(minutes=3).total_seconds()
hello_world_vllm_xpk = xpk.run_workload.override(owner=test_owner.MANFEI_B)(
task_id="run_workload_vllm_xpk",
cluster_project=cluster_project,
zone=zone,
cluster_name=cluster_name, # "b397493880-manfei3",
benchmark_id="xlml.vllm.llama3-8b.1slice.v5p_128_xpk",
workload_id=workload_id,
gcs_path=f"gs://vllmnightlyxpk/vllmnightlyxpk/workload_id",
docker_image="gcr.io/cloud-tpu-v2-images/vllm-tpu-nightly:latest",
accelerator_type="v5p-128",
run_cmds=f"export HF_TOKEN=xxxxx && \
export VLLM_SOURCE_CODE_LOC=./ && \
vllm serve meta-llama/Meta-Llama-3.1-8B --swap-space 16 --disable-log-requests --tensor_parallel_size=8 --max-model-len=2048 --num-scheduler-steps=4 & sleep 600 \
",
num_slices=1,
use_vertex_tensorboard=False,
use_pathways=False,
)
wait_for_workload_start = xpk.wait_for_workload_start.override(
timeout=workload_provision_timeout
)(
workload_id=workload_id,
project_id=cluster_project,
region=region,
cluster_name=cluster_name,
)
wait_for_workload_completion = xpk.wait_for_workload_completion.override(
timeout=workload_run_timeout
)(
workload_id=workload_id,
project_id=cluster_project,
region=region,
cluster_name=cluster_name,
)
(
hello_world_vllm_xpk
>> wait_for_workload_start
>> wait_for_workload_completion
)
# Create a DAG for each job from maxtext
for job in xlml_jobs:
if not re.match(pattern, job["task_name"]):
with models.DAG(
dag_id=job["task_name"],
schedule=job["schedule"],
tags=["mantaray"],
start_date=datetime.datetime(2024, 4, 22),
catchup=False,
) as dag:
run_workload = mantaray.run_workload(
workload_file_name=job["file_name"],
)
run_workload
else:
print(
"Skipping creating Mantaray DAGs since not running in Prod or Dev composer environment."
)