-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy patha3ultra_mixtral_8_7b_nemo.py
181 lines (163 loc) · 6.25 KB
/
a3ultra_mixtral_8_7b_nemo.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# Copyright 2024 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 Aotc reproducibility benchmarks."""
import datetime
import sys
import os
import tempfile
from airflow import models
from airflow.decorators import task
from airflow.hooks.subprocess import SubprocessHook
from dags import composer_env
from dags.map_reproducibility.utils.common_utils import get_nemo_metrics_cmds
from dags.map_reproducibility.utils.common_utils import configure_project_and_cluster
from dags.map_reproducibility.utils.common_utils import install_helm_cmds
from dags.map_reproducibility.utils.common_utils import namespace_cmds
from dags.map_reproducibility.utils.common_utils import wait_for_jobs_cmds
from dags.map_reproducibility.utils.common_utils import copy_bucket_cmds
from dags.map_reproducibility.utils.common_utils import cleanup_cmds
from dags.map_reproducibility.utils.common_utils import git_cookie_authdaemon
from dags.map_reproducibility.utils.common_utils import clone_recipes_gob
from dags.map_reproducibility.utils.common_utils import helm_apply_cmds
from dags.map_reproducibility.utils.common_utils import get_nemo_metrics
from dags.map_reproducibility.utils.common_utils import get_bq_writer_repo
from dags.map_reproducibility.utils.benchmarkdb_utils import write_run
from dags.map_reproducibility.utils.common_utils import extract_run_details
from dags.map_reproducibility.utils.common_utils import extract_gpus
from dags.map_reproducibility.utils.common_utils import get_accelerator_type
from dags.map_reproducibility.utils.common_utils import get_pre_workload_cmds
from dags.map_reproducibility.utils.common_utils import get_gpu_recipe_cmd
from dags.map_reproducibility.utils.common_utils import get_bq_writer_path
from dags.map_reproducibility.utils.common_utils import get_recipe_repo_path
# Run once a day at 2 pm UTC (6 am PST)
SCHEDULED_TIME = "0 14 * * *" if composer_env.is_prod_env() else None
MODEL_ID = "mixtral-8x7b"
METRICS_MODEL_ID = "mixtral-7b"
PRECISION = "bf16"
HYPERCOMPUTER = "a3ultra"
FRAMEWORK = "nemo"
VALUE_YAML_PATH = (
f"training/{HYPERCOMPUTER}/{MODEL_ID}/nemo-pretraining-gke/values.yaml"
)
CLUSTER = "gke-a3u-map-01-31"
CLUSTER_REGION = "europe-west1"
SOFTWARE_ID = "pytorch_nemo"
IMAGE_VERSION = "nemo_workload:24.07"
DOCKER_IMAGE = f"us-central1-docker.pkg.dev/supercomputer-testing/gunjanjalori/{FRAMEWORK}_test/{IMAGE_VERSION}"
@task
def run_aotc_workload():
with tempfile.TemporaryDirectory() as tmpdir:
hook = SubprocessHook()
result = hook.run_command(
[
"bash",
"-c",
";".join(
git_cookie_authdaemon()
+ clone_recipes_gob()
+ get_bq_writer_repo()
),
],
cwd=tmpdir,
)
recipe_repo_root = get_recipe_repo_path(tmpdir)
bq_writer_repo_root = get_bq_writer_path(tmpdir)
num_gpus = extract_gpus(recipe_repo_root, VALUE_YAML_PATH)
num_gpus_temp = 256
config_yaml_path = f"src/frameworks/{HYPERCOMPUTER}/nemo-configs/{MODEL_ID}-{num_gpus_temp}gpus-a3u-{PRECISION}.yaml"
full_config_yaml_path = os.path.join(recipe_repo_root, config_yaml_path)
(
global_batch_size,
optimizer,
precision,
seq_length,
max_steps,
) = extract_run_details(recipe_repo_root, config_yaml_path)
accelerator_type = get_accelerator_type(HYPERCOMPUTER)
print(
f"batch size: {global_batch_size}, num gpus: {num_gpus}, precision: {precision}, seq length: {seq_length}, max steps: {max_steps}"
)
result = hook.run_command(
[
"bash",
"-c",
";".join(
configure_project_and_cluster(CLUSTER, CLUSTER_REGION)
+ get_gpu_recipe_cmd(
HYPERCOMPUTER, MODEL_ID, FRAMEWORK, recipe_repo_root
)
+ install_helm_cmds()
+ namespace_cmds()
+ get_pre_workload_cmds(MODEL_ID, FRAMEWORK)
+ helm_apply_cmds(
FRAMEWORK,
HYPERCOMPUTER,
full_config_yaml_path,
recipe_repo_root,
DOCKER_IMAGE,
)
+ wait_for_jobs_cmds()
+ copy_bucket_cmds(recipe_repo_root)
+ get_nemo_metrics_cmds(
global_batch_size,
num_gpus,
PRECISION,
METRICS_MODEL_ID,
accelerator_type,
tmpdir,
)
# DEBUG: to clean-up, get manifest by doing: helm list | grep regression | awk '{print $1}'
# + cleanup_cmds()
),
],
cwd=tmpdir,
)
assert result.exit_code == 0, f"Command failed with code {result.exit_code}"
average_step_time, mfu = get_nemo_metrics(tmpdir)
write_run(
model_id=MODEL_ID,
hardware_id=HYPERCOMPUTER,
software_id=SOFTWARE_ID,
number_of_nodes=num_gpus / 8,
number_of_chips=num_gpus,
container_image_name=IMAGE_VERSION,
global_batch_size=global_batch_size,
precision=precision,
optimizer=optimizer,
seq_length=seq_length,
median_step_time=average_step_time,
e2e_time=0,
number_of_steps=max_steps,
mfu=mfu,
tokens_per_second=1,
writer_path=bq_writer_repo_root,
topology="2X2",
comment="Regression tests",
is_test=False,
)
with models.DAG(
dag_id=f"{HYPERCOMPUTER}_recipes_{MODEL_ID}_{FRAMEWORK}",
schedule=SCHEDULED_TIME,
tags=[
"simple",
"aotc",
"nightly",
"reproducibility",
"experimental",
"xlml",
],
start_date=datetime.datetime(2024, 11, 15),
catchup=False,
) as dag:
run_aotc_workload()