Skip to content
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

Updated TPU unittests to cover more TPU types / JAX versions #623

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions dags/sparsity_diffusion_devx/configs/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,17 @@ def set_up_nightly_jax() -> Tuple[str]:
),
"pip install git+https://github.com/google/jax",
)


def set_up_jax_version(version) -> Tuple[str]:
return (
(
f"pip install jax[tpu]=={version} -f "
"https://storage.googleapis.com/jax-releases/libtpu_releases.html"
),
(
f"pip install --pre jaxlib=={version} -f"
" https://storage.googleapis.com/jax-releases/jaxlib_nightly_releases.html"
),
f"pip install jax=={version}",
)
67 changes: 49 additions & 18 deletions dags/sparsity_diffusion_devx/configs/project_bite_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,21 @@ def get_bite_tpu_config(
)


def get_bite_tpu_unittests_config(
tpu_version: TpuVersion,
tpu_cores: int,
tpu_zone: str,
runtime_version: str,
time_out_in_min: int,
task_owner: str,
is_tpu_reserved: bool = False,
pinned_version: Optional[str] = None,
):
unittest_setupcmds = (
# create configuration files needed
def dockerfile_build_cmd(jax_version):
# Generate pip commands to install certain version of JAX/libTPU e.g.
# pip install --pre jaxlib==0.5.1 -f https://storage.googleapis.com/jax-releases/jaxlib_nightly_releases.html
# pip install jax[tpu]==0.5.1 -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
# pip install jax==0.5.1
if jax_version:
pip_tpu_jax_install = "\n".join(
["RUN " + x for x in common.set_up_jax_version(jax_version)]
)
else:
pip_tpu_jax_install = "\n".join(
["RUN " + x for x in common.set_up_nightly_jax()]
)

return (
"""cat > Dockerfile_CI <<EOF
FROM python:3.10-slim
WORKDIR /workspace
Expand All @@ -122,12 +125,33 @@ def get_bite_tpu_unittests_config(
RUN pip install -e '.[core,dev,gcp]'
RUN pip install grain
RUN pip install google-cloud-aiplatform
RUN pip install -U --pre libtpu-nightly -f https://storage.googleapis.com/jax-releases/libtpu_releases.html
RUN pip install --pre -U jaxlib -f https://storage.googleapis.com/jax-releases/jaxlib_nightly_releases.html
RUN pip install git+https://github.com/google/jax
"""
+ pip_tpu_jax_install
+ """
RUN pip freeze
EOF
""",
"""
)


def get_bite_tpu_unittests_config(
tpu_version: TpuVersion,
tpu_cores: int,
tpu_zone: str,
runtime_version: str,
time_out_in_min: int,
task_owner: str,
network: str = "default",
subnetwork: str = "default",
is_tpu_reserved: bool = False,
jax_version: Optional[str] = None,
test_suffix: Optional[str] = None,
project_name: Optional[Project] = Project.CLOUD_ML_AUTO_SOLUTIONS.value,
):

unittest_setupcmds = (
# create configuration files needed
dockerfile_build_cmd(jax_version),
# create script to run the tests inside of the container
# incluedes a basic sanity check python script which prints out TPU env info for reference
"""cat > run_tpu_tests.sh <<EOF
Expand All @@ -148,19 +172,26 @@ def get_bite_tpu_unittests_config(
"sudo docker run --network=host --privileged --ulimit memlock=-1:-1 ml-auto-solutions/tpu_unittests /bin/bash -c '/workspace/run_tpu_tests.sh'",
)
job_gcp_config = gcp_config.GCPConfig(
project_name=Project.CLOUD_ML_AUTO_SOLUTIONS.value,
project_name=project_name,
zone=tpu_zone,
dataset_name=metric_config.DatasetOption.XLML_DATASET,
)

if test_suffix:
test_name = f"bite_unittests_{test_suffix}"
else:
test_name = "bite_unittests"

tpu_unittests_test_config = test_config.TpuVmTest(
test_config.Tpu(
version=tpu_version,
cores=tpu_cores,
runtime_version=runtime_version,
reserved=is_tpu_reserved,
network=network,
subnetwork=subnetwork,
),
test_name="bite_unittests",
test_name=test_name,
set_up_cmds=unittest_setupcmds,
run_model_cmds=unittest_runcmds,
timeout=datetime.timedelta(minutes=time_out_in_min),
Expand Down
107 changes: 75 additions & 32 deletions dags/sparsity_diffusion_devx/project_bite_tpu_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,52 @@


# Run once a day at 6 pm UTC (11 am PST)
SCHEDULED_TIME = "0 18 * * *" if composer_env.is_prod_env() else None
SCHEDULED_TIME = '0 18 * * *' if composer_env.is_prod_env() else None

trillium_conf = {
'tpu_version': TpuVersion.TRILLIUM,
'tpu_cores': 4,
'tpu_zone': Zone.EUROPE_WEST4_A.value,
'runtime_version': RuntimeVersion.V2_ALPHA_TPUV6.value,
}

v5p_conf = {
'tpu_version': TpuVersion.V5P,
'tpu_cores': 8,
'tpu_zone': Zone.US_EAST5_A.value,
'is_tpu_reserved': True,
'runtime_version': RuntimeVersion.V2_ALPHA_TPUV5.value,
'project_name': Project.TPU_PROD_ENV_AUTOMATED.value,
'network': 'mas-test',
'subnetwork': 'mas-test',
}

v5e_conf = {
'tpu_version': TpuVersion.V5E,
'tpu_cores': 8,
'tpu_zone': Zone.US_EAST1_C.value,
'is_tpu_reserved': True,
'runtime_version': RuntimeVersion.V2_ALPHA_TPUV5_LITE.value,
'project_name': Project.TPU_PROD_ENV_AUTOMATED.value,
'network': 'mas-test',
'subnetwork': 'mas-test',
}

common = {
'time_out_in_min': 180,
'task_owner': test_owner.Andrew_S,
}


with models.DAG(
dag_id="project_bite_tpu_e2e",
dag_id='project_bite_tpu_e2e',
schedule=SCHEDULED_TIME,
tags=[
"sparsity_diffusion_devx",
"multipod_team",
"tpu",
"axlearn",
"bite",
'sparsity_diffusion_devx',
'multipod_team',
'tpu',
'axlearn',
'bite',
],
start_date=datetime.datetime(2024, 4, 4),
catchup=False,
Expand Down Expand Up @@ -82,28 +116,37 @@
task_owner=test_owner.Maggie_Z,
)

default_unittest_args = {
"retries": 0,
}

with models.DAG(
dag_id="project_bite_tpu_unittests",
schedule=SCHEDULED_TIME,
tags=[
"sparsity_diffusion_devx",
"tpu",
"axlearn",
"bite",
],
start_date=datetime.datetime(2025, 2, 24),
catchup=False,
default_args=default_unittest_args,
) as dag:
unittests = config.get_bite_tpu_unittests_config(
tpu_version=TpuVersion.TRILLIUM,
tpu_cores=4,
tpu_zone=Zone.EUROPE_WEST4_A.value,
runtime_version=RuntimeVersion.V2_ALPHA_TPUV6.value,
time_out_in_min=180,
task_owner=test_owner.Andrew_S,
)
tpu_unittests = [
# Trillium (v6e) with JAX 0.5.1
config.get_bite_tpu_unittests_config(
**trillium_conf,
test_suffix='v6e_051',
jax_version='0.5.1',
**common,
),
# Trillium (v6e) with JAX nightly
config.get_bite_tpu_unittests_config(
**trillium_conf,
test_suffix='v6e_nightly',
**common,
),
# V5P with JAX 0.5.1
config.get_bite_tpu_unittests_config(
**v5p_conf,
test_suffix='v5p_051',
jax_version='0.5.1',
**common,
),
# V5P with JAX nightly
config.get_bite_tpu_unittests_config(
**v5p_conf,
test_suffix='v5p_nightly',
**common,
),
# V5E with JAX nightly
config.get_bite_tpu_unittests_config(
**v5e_conf,
test_suffix='v5e_nightly',
**common,
),
]