-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Do Not Merge] Simple Maxdiffusion SDXL inference integration #299
base: master
Are you sure you want to change the base?
Changes from 3 commits
49a82cf
b51c624
07f36af
707ef89
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -14,6 +14,7 @@ | |||||||
|
||||||||
"""Utilities to construct configs for maxdiffusion inference DAG.""" | ||||||||
|
||||||||
import datetime | ||||||||
import json | ||||||||
from typing import Dict | ||||||||
from xlml.apis import gcp_config, metric_config, task, test_config | ||||||||
|
@@ -26,6 +27,14 @@ | |||||||
GCS_SUBFOLDER_PREFIX = test_owner.Team.INFERENCE.value | ||||||||
|
||||||||
|
||||||||
def _modify_save_metrics(metrics_file, model_configs): | ||||||||
metrics = json.loads(metrics_file) | ||||||||
for k, v in model_configs: | ||||||||
metrics["dimensions"][k] = str(v) | ||||||||
with open(metrics_file, "w") as f: | ||||||||
f.write(json.dumps(metrics)) | ||||||||
|
||||||||
|
||||||||
def get_maxdiffusion_inference_nightly_config( | ||||||||
tpu_version: TpuVersion, | ||||||||
tpu_cores: int, | ||||||||
|
@@ -47,10 +56,13 @@ def get_maxdiffusion_inference_nightly_config( | |||||||
dataset_name=metric_config.DatasetOption.BENCHMARK_DATASET, | ||||||||
) | ||||||||
|
||||||||
per_device_bat_size = model_configs["per_device_batch_size"] | ||||||||
attention = model_configs["attention"] | ||||||||
model_name = model_configs["model_name"] | ||||||||
set_up_cmds = ( | ||||||||
"pip install --upgrade pip", | ||||||||
# Download maxdiffusion | ||||||||
"git clone -b inference_utils https://github.com/google/maxdiffusion.git", | ||||||||
"git clone https://github.com/google/maxdiffusion.git" | ||||||||
# Create a python virtual environment | ||||||||
"sudo apt-get -y update", | ||||||||
"sudo apt-get -y install python3.10-venv", | ||||||||
|
@@ -60,25 +72,49 @@ def get_maxdiffusion_inference_nightly_config( | |||||||
"cd maxdiffusion", | ||||||||
"pip3 install jax[tpu] -f https://storage.googleapis.com/jax-releases/libtpu_releases.html", | ||||||||
"pip3 install -r requirements.txt", | ||||||||
"pip3 install ." | ||||||||
"pip3 install .", | ||||||||
# dependency for controlnet | ||||||||
"apt-get install ffmpeg libsm6 libxext6 -y" "cd ..", | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
) | ||||||||
|
||||||||
additional_metadata_dict = { | ||||||||
"per_device_batch_size": f"{model_configs['per_device_batch_size']}", | ||||||||
} | ||||||||
|
||||||||
run_model_cmds = ( | ||||||||
# Start virtual environment | ||||||||
"source .env/bin/activate", | ||||||||
### Benchmark | ||||||||
"cd maxdiffusion", | ||||||||
# Configure flags | ||||||||
""" python -m src.maxdiffusion.generate_sdxl src/maxdiffusion/configs/base_xl.yml run_name="my_run" """, | ||||||||
# Give server time to start | ||||||||
f"sleep {model_configs['sleep_time']}", | ||||||||
f"gsutil cp metrics.json {metric_config.SshEnvVars.GCS_OUTPUT.value}", | ||||||||
) | ||||||||
if model_name == "SDXL-Base-1.0": | ||||||||
run_model_cmds = ( | ||||||||
# Start virtual environment | ||||||||
"source .env/bin/activate", | ||||||||
### Benchmark | ||||||||
"cd maxdiffusion", | ||||||||
# Configure flags | ||||||||
"cd .." | ||||||||
f""" python -m src.maxdiffusion.generate_sdxl src/maxdiffusion/configs/base_xl.yml run_name="my_run" per_device_batch_size={per_device_bat_size} attention="{attention}" """, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: rename "my_run" to something more specific to "sdxl". Here, and below. |
||||||||
"cd ..", | ||||||||
f"gsutil cp metrics.json {metric_config.SshEnvVars.GCS_OUTPUT.value}", | ||||||||
) | ||||||||
if model_name == "SDXL-Lightning": | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Suggestion: change to |
||||||||
run_model_cmds = ( | ||||||||
# Start virtual environment | ||||||||
"source .env/bin/activate", | ||||||||
### Benchmark | ||||||||
"cd maxdiffusion", | ||||||||
# Configure flags | ||||||||
"cd .." | ||||||||
f""" python -m src.maxdiffusion.generate_sdxl src/maxdiffusion/configs/base_xl.yml run_name="my_run" lightning_repo="ByteDance/SDXL-Lightning" lightning_ckpt="sdxl_lightning_4step_unet.safetensors" per_device_batch_size={per_device_bat_size} attention="{attention}" """, | ||||||||
"cd ..", | ||||||||
f"gsutil cp metrics.json {metric_config.SshEnvVars.GCS_OUTPUT.value}", | ||||||||
) | ||||||||
if model_name == "SDXL-ControlNet": | ||||||||
run_model_cmds = ( | ||||||||
# Start virtual environment | ||||||||
"source .env/bin/activate", | ||||||||
### Benchmark | ||||||||
"cd maxdiffusion", | ||||||||
# Configure flags | ||||||||
"cd .." | ||||||||
f""" python src/maxdiffusion/controlnet/generate_controlnet_sdxl_replicated.py per_device_batch_size={per_device_bat_size} attention="{attention}" """, | ||||||||
"cd ..", | ||||||||
f"gsutil cp metrics.json {metric_config.SshEnvVars.GCS_OUTPUT.value}", | ||||||||
) | ||||||||
|
||||||||
_modify_save_metrics("metrics.json", model_configs) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if We can either have bash commands to do something like |
||||||||
job_test_config = test_config.TpuVmTest( | ||||||||
test_config.Tpu( | ||||||||
version=tpu_version, | ||||||||
|
@@ -91,7 +127,7 @@ def get_maxdiffusion_inference_nightly_config( | |||||||
test_name=test_name, | ||||||||
set_up_cmds=set_up_cmds, | ||||||||
run_model_cmds=run_model_cmds, | ||||||||
time_out_in_min=time_out_in_min, | ||||||||
timeout=datetime.timedelta(minutes=time_out_in_min), | ||||||||
task_owner=test_owner.VIJAYA_S, | ||||||||
num_slices=num_slices, | ||||||||
gcs_subfolder=f"{GCS_SUBFOLDER_PREFIX}/maxdiffusion", | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You didn't make these changes right? Can we rebase master please? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.