2525PROJECT_NAME = Project .CLOUD_ML_AUTO_SOLUTIONS .value
2626RUNTIME_IMAGE = RuntimeVersion .TPU_UBUNTU2204_BASE .value
2727GCS_SUBFOLDER_PREFIX = test_owner .Team .INFERENCE .value
28+ VENV_DIR = "venv-312"
2829
2930
3031def get_config (
@@ -55,8 +56,10 @@ 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+ "sudo apt-get -o Dpkg::Lock::Timeout=300 -y update" ,
62+ "sudo apt-get -o Dpkg::Lock::Timeout=300 -y install jq" ,
6063 "cd JetStream && pip install -e . && cd benchmarks && pip install -r requirements.in" ,
6164 "pip install torch --index-url https://download.pytorch.org/whl/cpu" ,
6265 "cd .." ,
@@ -70,11 +73,14 @@ def get_config(
7073 # Make the PATH change permanent for subsequent sessions (optional, but good practice)
7174 "echo 'export PATH=\" $HOME/.local/bin:$PATH\" ' >> ~/.bashrc" ,
7275 "source ~/.bashrc" ,
73- "uv venv --python 3.12 venv-312 --seed" ,
74- "source venv-312 /bin/activate" ,
76+ f "uv venv --python 3.12 { VENV_DIR } --seed --clear " ,
77+ f "source { VENV_DIR } /bin/activate" ,
7578 "pip install uv" ,
7679 "uv pip install maxtext --resolution=lowest" ,
7780 "install_maxtext_github_deps" ,
81+ "uv pip install rouge-score" ,
82+ "sudo apt-get -o Dpkg::Lock::Timeout=300 install -y git-lfs" ,
83+ "git lfs install" ,
7884 )
7985
8086 set_up_cmds += setup_maxtext_cmds
@@ -113,15 +119,19 @@ def get_config(
113119
114120 # Let gcs path be directly used, else use maxtext/assets dir
115121 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' ]} "
122+ tokenizer_path = (
123+ f"src/maxtext/assets/tokenizers/{ model_configs ['tokenizer' ]} "
124+ )
125+ full_tokenizer_path = (
126+ f"maxtext/src/maxtext/assets/tokenizers/{ model_configs ['tokenizer' ]} "
127+ )
118128 else :
119129 tokenizer_path = model_configs ["tokenizer" ]
120130 full_tokenizer_path = model_configs ["tokenizer" ]
121131
122132 run_model_cmds = (
123133 # Start virtual environment
124- "source .env /bin/activate" ,
134+ f "source { VENV_DIR } /bin/activate" ,
125135 "wget https://huggingface.co/datasets/anon8231489123/ShareGPT_Vicuna_unfiltered/resolve/main/ShareGPT_V3_unfiltered_cleaned_split.json > /dev/null 2>&1" ,
126136 # Get commit hash of the maxtext and jetstream repos
127137 f"export METADATA_DICT='{ json .dumps (additional_metadata_dict )} '" ,
@@ -131,58 +141,37 @@ def get_config(
131141 'export METADATA_DICT=$(jq -c \' . + { "jetstream_commit_hash": $newVal}\' --arg newVal ${JETSTREAM_COMMIT_HASH} <<<"$METADATA_DICT")' ,
132142 ### Benchmark
133143 "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' ]} " ,
156144 # 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} &""" ,
145+ f"""python3 -m MaxText.maxengine_server \\
146+ src/maxtext/configs/inference/inference_jetstream.yml \\
147+ model_name='{ model_configs ['model_name' ]} ' \\
148+ tokenizer_path='{ tokenizer_path } ' \\
149+ weight_dtype='{ model_configs ['weight_dtype' ]} ' \\
150+ scan_layers='{ model_configs ['scan_layers' ]} ' \\
151+ max_prefill_predict_length='{ model_configs ['max_prefill_predict_length' ]} ' \\
152+ max_target_length='{ model_configs ['max_target_length' ]} ' \\
153+ attention='{ model_configs ['attention' ]} ' \\
154+ ici_fsdp_parallelism='{ model_configs ['ici_fsdp_parallelism' ]} ' \\
155+ ici_autoregressive_parallelism='{ model_configs ['ici_autoregressive_parallelism' ]} ' \\
156+ ici_tensor_parallelism='{ model_configs ['ici_tensor_parallelism' ]} ' \\
157+ load_parameters_path='{ model_configs ['checkpoint' ]} ' \\
158+ quantization='"{ model_configs .get ('quantization' ) or "" } "' \\
159+ quantize_kvcache='{ model_configs ['quantize_kvcache' ]} ' \\
160+ kv_quant_dtype='"{ model_configs .get ('kv_quant_dtype' ) or "" } "' \\
161+ per_device_batch_size='{ model_configs ['per_device_batch_size' ]} ' \\
162+ prefill_cache_axis_order='{ model_configs ['prefill_cache_axis_order' ]} ' \\
163+ ar_cache_axis_order='{ model_configs ['ar_cache_axis_order' ]} ' \\
164+ compute_axis_order='{ model_configs ['compute_axis_order' ]} ' \\
165+ reshape_q='{ model_configs ['reshape_q' ]} ' \\
166+ kv_quant_axis='"{ model_configs .get ('kv_quant_axis' ) or "" } "' &""" ,
183167 "cd .." ,
184168 # Give server time to start
185169 f"sleep { model_configs ['sleep_time' ]} " ,
170+ "cd JetStream" ,
171+ # Since we change to the Jetstream dir as root, we need to change the ownership of the dir to the user running the script
172+ "sudo chown -R $USER:$USER /home/sa_112632397993248756658/JetStream" ,
173+ "git lfs pull" ,
174+ "cd .." ,
186175 # Run benchmark, run eval, save benchmark and eval results, and save predictions to /tmp/request-outputs.json
187176 f"""python JetStream/benchmarks/benchmark_serving.py \
188177 --tokenizer { full_tokenizer_path } \
@@ -233,7 +222,6 @@ def get_config(
233222 json_lines = metric_config .JSONLinesConfig ("metric_report.jsonl" ),
234223 use_runtime_generated_gcs_folder = True ,
235224 )
236-
237225 return task .run_queued_resource_test (
238226 task_test_config = job_test_config ,
239227 task_gcp_config = job_gcp_config ,
0 commit comments