Skip to content

Commit 11bec15

Browse files
committed
Fix: Fixed Jetstream_benchmarking_servig DAG
- Point v5e tests to new reservation in CIENET-CMCS project - Point v6e tests to new reservation in tpu-prod-env-automated
1 parent d4c530a commit 11bec15

4 files changed

Lines changed: 144 additions & 84 deletions

File tree

dags/common/vm_resource.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
f"{V5_NETWORKS_PREFIX}/regions/europe-west4/subnetworks/mas-test-v2"
2828
)
2929
V6E_SUBNETWORKS = (
30-
f"{V5_NETWORKS_PREFIX}/regions/us-central2/subnetworks/mas-test"
30+
f"{V5_NETWORKS_PREFIX}/regions/southamerica-west1-a/subnetworks/mas-test"
3131
)
3232
# TODO: Figure V6E_GCE_NETWORK and V6E_GCE_SUBNETWORK
3333
V6E_GCE_NETWORK = "default"
@@ -72,6 +72,7 @@ class Project(enum.Enum):
7272
TPU_PROD_ENV_LARGE_ADHOC = "tpu-prod-env-large-adhoc"
7373
TPU_PROD_ENV_ONE_VM = "tpu-prod-env-one-vm"
7474
TPU_PROD_ENV_LARGE_CONT = "tpu-prod-env-large-cont"
75+
CIENET_CMCS = "cienet-cmcs"
7576

7677

7778
class ImageProject(enum.Enum):
@@ -124,6 +125,10 @@ class Zone(enum.Enum):
124125
US_EAST5_C = "us-east5-c"
125126
# reserved v5e in tpu-prod-env-multipod
126127
US_WEST4_B = "us-west4-b"
128+
# reserved v5e in cienet-cmcs
129+
US_WEST4_A = "us-west4-a"
130+
# reserved v6e in cienet-cmcs
131+
US_EAST4_B = "us-east4-b"
127132
# reserved v5e in cloud-tpu-inference-test
128133
US_WEST1_C = "us-west1-c"
129134
# reserved a3+ cluster in supercomputer-testing

dags/inference/configs/jetstream_benchmark_serving_gce_config.py

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
PROJECT_NAME = Project.CLOUD_ML_AUTO_SOLUTIONS.value
2626
RUNTIME_IMAGE = RuntimeVersion.TPU_UBUNTU2204_BASE.value
2727
GCS_SUBFOLDER_PREFIX = test_owner.Team.INFERENCE.value
28+
VENV_DIR = "venv-312"
2829

2930

3031
def get_config(
@@ -55,8 +56,20 @@ def get_config(
5556
# Download jetstream and maxtext
5657
f"if [ ! -d maxtext ]; then git clone {maxtext_branch} https://github.com/google/maxtext.git; fi",
5758
f"if [ ! -d JetStream ]; then git clone {jetstream_branch} https://github.com/google/JetStream.git; fi",
58-
"sudo apt-get -y update",
59-
"sudo apt-get -y install jq",
59+
"sudo systemctl stop unattended-upgrades",
60+
"sudo systemctl disable unattended-upgrades",
61+
# 2. Aggressively kill any lingering apt, dpkg, or unattended-upgrades processes
62+
"sudo pkill -9 unattended-upgr || true",
63+
"sudo pkill -9 apt || true",
64+
"sudo pkill -9 dpkg || true",
65+
# 3. Remove any remaining lock files
66+
"sudo rm -f /var/lib/apt/lists/lock",
67+
"sudo rm -f /var/cache/apt/archives/lock",
68+
"sudo rm -f /var/lib/dpkg/lock*",
69+
# 4. Repair any interrupted package configurations
70+
"sudo dpkg --configure -a",
71+
"sudo apt-get -o Dpkg::Lock::Timeout=300 -y update",
72+
"sudo apt-get -o Dpkg::Lock::Timeout=300 -y install jq",
6073
"cd JetStream && pip install -e . && cd benchmarks && pip install -r requirements.in",
6174
"pip install torch --index-url https://download.pytorch.org/whl/cpu",
6275
"cd ..",
@@ -70,11 +83,14 @@ def get_config(
7083
# Make the PATH change permanent for subsequent sessions (optional, but good practice)
7184
"echo 'export PATH=\"$HOME/.local/bin:$PATH\"' >> ~/.bashrc",
7285
"source ~/.bashrc",
73-
"uv venv --python 3.12 venv-312 --seed",
74-
"source venv-312/bin/activate",
86+
f"uv venv --python 3.12 {VENV_DIR} --seed --clear",
87+
f"source {VENV_DIR}/bin/activate",
7588
"pip install uv",
7689
"uv pip install maxtext --resolution=lowest",
7790
"install_maxtext_github_deps",
91+
"uv pip install rouge-score",
92+
"sudo apt-get -o Dpkg::Lock::Timeout=300 install -y git-lfs",
93+
"git lfs install",
7894
)
7995

8096
set_up_cmds += setup_maxtext_cmds
@@ -113,15 +129,19 @@ def get_config(
113129

114130
# Let gcs path be directly used, else use maxtext/assets dir
115131
if not model_configs["tokenizer"].startswith("gs://"):
116-
tokenizer_path = f"assets/{model_configs['tokenizer']}"
117-
full_tokenizer_path = f"maxtext/assets/{model_configs['tokenizer']}"
132+
tokenizer_path = (
133+
f"src/maxtext/assets/tokenizers/{model_configs['tokenizer']}"
134+
)
135+
full_tokenizer_path = (
136+
f"maxtext/src/maxtext/assets/tokenizers/{model_configs['tokenizer']}"
137+
)
118138
else:
119139
tokenizer_path = model_configs["tokenizer"]
120140
full_tokenizer_path = model_configs["tokenizer"]
121141

122142
run_model_cmds = (
123143
# Start virtual environment
124-
"source .env/bin/activate",
144+
f"source {VENV_DIR}/bin/activate",
125145
"wget https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json > /dev/null 2>&1",
126146
# Get commit hash of the maxtext and jetstream repos
127147
f"export METADATA_DICT='{json.dumps(additional_metadata_dict)}'",
@@ -131,58 +151,37 @@ def get_config(
131151
'export METADATA_DICT=$(jq -c \'. + { "jetstream_commit_hash": $newVal}\' --arg newVal ${JETSTREAM_COMMIT_HASH} <<<"$METADATA_DICT")',
132152
### Benchmark
133153
"cd maxtext",
134-
# Configure flags
135-
f"export MODEL_NAME={model_configs['model_name']}",
136-
f"export TOKENIZER_PATH={tokenizer_path}",
137-
f"export WEIGHT_DTYPE={model_configs['weight_dtype']}",
138-
f"export SCAN_LAYERS={model_configs['scan_layers']}",
139-
f"export MAX_PREFILL_PREDICT_LENGTH={model_configs['max_prefill_predict_length']}",
140-
f"export MAX_TARGET_LENGTH={model_configs['max_target_length']}",
141-
f"export ATTENTION={model_configs['attention']}",
142-
f"export ICI_FSDP_PARALLELISM={model_configs['ici_fsdp_parallelism']}",
143-
f"export ICI_AUTOREGRESSIVE_PARALLELISM={model_configs['ici_autoregressive_parallelism']}",
144-
f"export ICI_TENSOR_PARALLELISM={model_configs['ici_tensor_parallelism']}",
145-
f"export UNSCANNED_CKPT_PATH={model_configs['checkpoint']}",
146-
"export LOAD_PARAMETERS_PATH=${UNSCANNED_CKPT_PATH}",
147-
f"export QUANTIZATION={model_configs['quantization']}",
148-
f"export QUANTIZE_KVCACHE={model_configs['quantize_kvcache']}",
149-
f"export KV_QUANT_DTYPE={model_configs['kv_quant_dtype']}",
150-
f"export PER_DEVICE_BATCH_SIZE={model_configs['per_device_batch_size']}",
151-
f"export PREFILL_CACHE_AXIS_ORDER={model_configs['prefill_cache_axis_order']}",
152-
f"export AR_CACHE_AXIS_ORDER={model_configs['ar_cache_axis_order']}",
153-
f"export COMPUTE_AXIS_ORDER={model_configs['compute_axis_order']}",
154-
f"export RESHAPE_Q={model_configs['reshape_q']}",
155-
f"export KV_QUANT_AXIS={model_configs['kv_quant_axis']}",
156154
# Start JetStream MaxText server in the background
157-
"""python3 -m MaxText.maxengine_server \
158-
src/maxtext/configs/inference/inference_jetstream.yml \
159-
model_name=${MODEL_NAME} \
160-
tokenizer_path=${TOKENIZER_PATH} \
161-
weight_dtype=${WEIGHT_DTYPE} \
162-
scan_layers=${SCAN_LAYERS} \
163-
max_prefill_predict_length=${MAX_PREFILL_PREDICT_LENGTH} \
164-
max_target_length=${MAX_TARGET_LENGTH} \
165-
attention=${ATTENTION} \
166-
ici_fsdp_parallelism=${ICI_FSDP_PARALLELISM} \
167-
ici_autoregressive_parallelism=${ICI_AUTOREGRESSIVE_PARALLELISM} \
168-
ici_tensor_parallelism=${ICI_TENSOR_PARALLELISM} \
169-
load_parameters_path=${LOAD_PARAMETERS_PATH} \
170-
quantization=${QUANTIZATION} \
171-
quantize_kvcache=${QUANTIZE_KVCACHE} \\"""
172-
+ (
173-
"""kv_quant_dtype=${KV_QUANT_DTYPE} \\"""
174-
if model_configs["kv_quant_dtype"]
175-
else ""
176-
)
177-
+ """per_device_batch_size=${PER_DEVICE_BATCH_SIZE} \
178-
prefill_cache_axis_order=${PREFILL_CACHE_AXIS_ORDER} \
179-
ar_cache_axis_order=${AR_CACHE_AXIS_ORDER} \
180-
compute_axis_order=${COMPUTE_AXIS_ORDER} \
181-
reshape_q=${RESHAPE_Q} \
182-
kv_quant_axis=${KV_QUANT_AXIS} &""",
155+
f"""python3 -m MaxText.maxengine_server \\
156+
src/maxtext/configs/inference/inference_jetstream.yml \\
157+
model_name='{model_configs['model_name']}' \\
158+
tokenizer_path='{tokenizer_path}' \\
159+
weight_dtype='{model_configs['weight_dtype']}' \\
160+
scan_layers='{model_configs['scan_layers']}' \\
161+
max_prefill_predict_length='{model_configs['max_prefill_predict_length']}' \\
162+
max_target_length='{model_configs['max_target_length']}' \\
163+
attention='{model_configs['attention']}' \\
164+
ici_fsdp_parallelism='{model_configs['ici_fsdp_parallelism']}' \\
165+
ici_autoregressive_parallelism='{model_configs['ici_autoregressive_parallelism']}' \\
166+
ici_tensor_parallelism='{model_configs['ici_tensor_parallelism']}' \\
167+
load_parameters_path='{model_configs['checkpoint']}' \\
168+
quantization='"{model_configs.get('quantization') or ""}"' \\
169+
quantize_kvcache='{model_configs['quantize_kvcache']}' \\
170+
kv_quant_dtype='"{model_configs.get('kv_quant_dtype') or ""}"' \\
171+
per_device_batch_size='{model_configs['per_device_batch_size']}' \\
172+
prefill_cache_axis_order='{model_configs['prefill_cache_axis_order']}' \\
173+
ar_cache_axis_order='{model_configs['ar_cache_axis_order']}' \\
174+
compute_axis_order='{model_configs['compute_axis_order']}' \\
175+
reshape_q='{model_configs['reshape_q']}' \\
176+
kv_quant_axis='"{model_configs.get('kv_quant_axis') or ""}"' &""",
183177
"cd ..",
184178
# Give server time to start
185179
f"sleep {model_configs['sleep_time']}",
180+
"cd JetStream",
181+
# Since we change to the Jetstream dir as root, we need to change the ownership of the dir to the user running the script
182+
"sudo chown -R $USER:$USER /home/sa_112632397993248756658/JetStream",
183+
"git lfs pull",
184+
"cd ..",
186185
# Run benchmark, run eval, save benchmark and eval results, and save predictions to /tmp/request-outputs.json
187186
f"""python JetStream/benchmarks/benchmark_serving.py \
188187
--tokenizer {full_tokenizer_path} \
@@ -233,7 +232,6 @@ def get_config(
233232
json_lines=metric_config.JSONLinesConfig("metric_report.jsonl"),
234233
use_runtime_generated_gcs_folder=True,
235234
)
236-
237235
return task.run_queued_resource_test(
238236
task_test_config=job_test_config,
239237
task_gcp_config=job_gcp_config,

dags/inference/maxtext_inference.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from airflow import models
2020
from dags import composer_env
2121
from dags.common.vm_resource import TpuVersion
22-
from dags.inference.maxtext_model_config_generator import generate_model_configs
22+
from dags.inference.maxtext_model_config_generator import generate_model_configs, TpuConfig
2323

2424
USER_PREFIX = ""
2525

@@ -117,7 +117,10 @@
117117
"jetstream_branch": jetstream_branch,
118118
"sleep_time": 360,
119119
"time_out_in_min": 120,
120-
"tpu_version_cores": [(TpuVersion.V5E, 8), (TpuVersion.TRILLIUM, 8)],
120+
"tpu_version_cores": [
121+
(TpuConfig.temp_V5E, 8),
122+
(TpuConfig.temp_TRILLIUM, 8),
123+
],
121124
"model_name": LLAMA2_7B,
122125
"tokenizer": "tokenizer.llama2",
123126
"weight_dtype": "bfloat16",
@@ -155,7 +158,10 @@
155158
"jetstream_branch": jetstream_branch,
156159
"sleep_time": 360,
157160
"time_out_in_min": 120,
158-
"tpu_version_cores": [(TpuVersion.V5E, 8), (TpuVersion.TRILLIUM, 8)],
161+
"tpu_version_cores": [
162+
(TpuConfig.temp_V5E, 8),
163+
(TpuConfig.temp_TRILLIUM, 8),
164+
],
159165
"model_name": LLAMA2_13B,
160166
"tokenizer": "tokenizer.llama2",
161167
"weight_dtype": "bfloat16",
@@ -193,7 +199,10 @@
193199
"jetstream_branch": jetstream_branch,
194200
"sleep_time": 360,
195201
"time_out_in_min": 240,
196-
"tpu_version_cores": [(TpuVersion.V5P, 8), (TpuVersion.TRILLIUM, 8)],
202+
"tpu_version_cores": [
203+
(TpuConfig.V5P, 8),
204+
(TpuConfig.temp_TRILLIUM, 8),
205+
],
197206
"model_name": LLAMA2_70B,
198207
"tokenizer": "tokenizer.llama2",
199208
"weight_dtype": "bfloat16",
@@ -230,7 +239,10 @@
230239
"jetstream_branch": jetstream_branch,
231240
"sleep_time": 360,
232241
"time_out_in_min": 120,
233-
"tpu_version_cores": [(TpuVersion.V5E, 8), (TpuVersion.TRILLIUM, 8)],
242+
"tpu_version_cores": [
243+
(TpuConfig.temp_V5E, 8),
244+
(TpuConfig.temp_TRILLIUM, 8),
245+
],
234246
"model_name": GEMMA_7B,
235247
"tokenizer": "tokenizer.gemma",
236248
"weight_dtype": "bfloat16",
@@ -269,7 +281,10 @@
269281
"jetstream_branch": jetstream_branch,
270282
"sleep_time": 240,
271283
"time_out_in_min": 240,
272-
"tpu_version_cores": [(TpuVersion.V5P, 8), (TpuVersion.TRILLIUM, 8)],
284+
"tpu_version_cores": [
285+
(TpuConfig.V5P, 8),
286+
(TpuConfig.temp_TRILLIUM, 8),
287+
],
273288
"model_name": MIXTRAL_8_7B,
274289
"tokenizer": "gs://maxtext-external/mixtral-8x7B-v0.1-Instruct/tokenizer.mistral",
275290
"weight_dtype": "bfloat16",
@@ -576,7 +591,6 @@
576591
},
577592
}
578593
)
579-
580594
# run_configs = [
581595
# f"{LLAMA2_7B}-{BASE_MODE}-{W_BF16_KV_BF16}",
582596
# f"{LLAMA2_7B}-{BASE_MODE}-{W_INT8_KV_INT8}",

dags/inference/maxtext_model_config_generator.py

Lines changed: 63 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,60 @@
1414

1515
"""A helper to generate maxtext model configs."""
1616

17+
from dataclasses import dataclass
18+
from enum import Enum
1719
from dags.common.vm_resource import TpuVersion, Zone, Project, V5_NETWORKS, V5E_SUBNETWORKS, V5P_SUBNETWORKS, RuntimeVersion, V6E_GCE_NETWORK, V6E_GCE_SUBNETWORK
1820
from dags.inference.configs import jetstream_benchmark_serving_gce_config
1921
from dags.multipod.configs.common import SetupMode
2022

2123

24+
@dataclass
25+
class TpuResource:
26+
runtime_version: str
27+
project_name: str
28+
zone: str
29+
network: str
30+
subnetwork: str
31+
32+
33+
class TpuConfig(Enum):
34+
V5E = TpuResource(
35+
runtime_version=RuntimeVersion.V2_ALPHA_TPUV5_LITE.value,
36+
project_name=Project.TPU_PROD_ENV_AUTOMATED.value,
37+
zone=Zone.US_EAST1_C.value,
38+
network=V5_NETWORKS,
39+
subnetwork=V5E_SUBNETWORKS,
40+
)
41+
V5P = TpuResource(
42+
runtime_version=RuntimeVersion.V2_ALPHA_TPUV5.value,
43+
project_name=Project.TPU_PROD_ENV_AUTOMATED.value,
44+
zone=Zone.US_EAST5_A.value,
45+
network=V5_NETWORKS,
46+
subnetwork=V5P_SUBNETWORKS,
47+
)
48+
TRILLIUM = TpuResource(
49+
runtime_version=RuntimeVersion.V2_ALPHA_TPUV6.value,
50+
project_name=Project.TPU_PROD_ENV_AUTOMATED.value,
51+
zone=Zone.US_EAST5_A.value,
52+
network=V6E_GCE_NETWORK,
53+
subnetwork=V6E_GCE_SUBNETWORK,
54+
)
55+
temp_V5E = TpuResource(
56+
runtime_version=RuntimeVersion.V2_ALPHA_TPUV5_LITE.value,
57+
project_name="cienet-cmcs",
58+
zone=Zone.US_WEST4_A.value,
59+
network="projects/cienet-cmcs/global/networks/mas-test",
60+
subnetwork="projects/cienet-cmcs/regions/us-west4/subnetworks/mas-test",
61+
)
62+
temp_TRILLIUM = TpuResource(
63+
runtime_version=RuntimeVersion.V2_ALPHA_TPUV6.value,
64+
project_name=Project.TPU_PROD_ENV_AUTOMATED.value,
65+
zone=Zone.SOUTHAMERICA_WEST1_A.value,
66+
network=V5_NETWORKS,
67+
subnetwork="projects/tpu-prod-env-automated/regions/southamerica-west1-a/subnetworks/mas-test",
68+
)
69+
70+
2271
def generate_model_configs(
2372
test_name_prefix,
2473
model_config_name,
@@ -99,28 +148,22 @@ def generate_model_configs(
99148

100149
test_name = f"{test_name_prefix}-{test_run_tag}"
101150

102-
if tpu_version == TpuVersion.V5E:
103-
# v5e benchmarks
104-
project_name = Project.TPU_PROD_ENV_AUTOMATED.value
105-
zone = Zone.US_EAST1_C.value
106-
network = V5_NETWORKS
107-
subnetwork = V5E_SUBNETWORKS
108-
runtime_version = RuntimeVersion.V2_ALPHA_TPUV5_LITE.value
109-
elif tpu_version == TpuVersion.V5P:
110-
zone = Zone.US_EAST5_A.value
111-
runtime_version = RuntimeVersion.V2_ALPHA_TPUV5.value
112-
project_name = Project.TPU_PROD_ENV_AUTOMATED.value
113-
network = V5_NETWORKS
114-
subnetwork = V5P_SUBNETWORKS
115-
elif tpu_version == TpuVersion.TRILLIUM:
116-
zone = Zone.US_EAST5_A.value
117-
runtime_version = RuntimeVersion.V2_ALPHA_TPUV6.value
118-
project_name = Project.TPU_PROD_ENV_AUTOMATED.value
119-
network = V6E_GCE_NETWORK
120-
subnetwork = V6E_GCE_SUBNETWORK
151+
# Handle both TpuConfig and TpuVersion for backwards compatibility
152+
if isinstance(tpu_version, TpuConfig):
153+
config = tpu_version.value
154+
tpu_version_enum = TpuVersion[tpu_version.name.replace("temp_", "")]
155+
else:
156+
config = TpuConfig[tpu_version.name].value
157+
tpu_version_enum = tpu_version
158+
159+
runtime_version = config.runtime_version
160+
project_name = config.project_name
161+
zone = config.zone
162+
network = config.network
163+
subnetwork = config.subnetwork
121164
jetstream_benchmark_serving = (
122165
jetstream_benchmark_serving_gce_config.get_config(
123-
tpu_version=tpu_version,
166+
tpu_version=tpu_version_enum,
124167
tpu_cores=tpu_cores,
125168
tpu_zone=zone,
126169
time_out_in_min=sweep_model_configs["time_out_in_min"],

0 commit comments

Comments
 (0)