|
| 1 | +# Copyright 2024 Google LLC |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | + |
| 15 | +""" |
| 16 | +A DAG to run PyTorch multislice tests |
| 17 | +""" |
| 18 | +import datetime |
| 19 | +from airflow import models |
| 20 | +from dags import composer_env, test_owner |
| 21 | +from dags.vm_resource import TpuVersion, Zone, DockerImage, ClusterName |
| 22 | +from dags.multipod.configs import pytorch_config |
| 23 | +from xlml.apis import metric_config |
| 24 | + |
| 25 | +# Run once a day at 10 am UTC (3 am PST) |
| 26 | +SCHEDULED_TIME = "0 10 * * *" if composer_env.is_prod_env() else None |
| 27 | + |
| 28 | +with models.DAG( |
| 29 | + dag_id="pytorch_multislice", |
| 30 | + schedule=SCHEDULED_TIME, |
| 31 | + tags=["multipod_team", "pytorch", "nightly"], |
| 32 | + start_date=datetime.datetime(2024, 3, 1), |
| 33 | + catchup=False, |
| 34 | + concurrency=2, |
| 35 | +) as dag: |
| 36 | + v4_8 = ClusterName.V4_8_MULTISLICE_CLUSTER |
| 37 | + v4_16 = ClusterName.V4_16_MULTISLICE_CLUSTER |
| 38 | + |
| 39 | + for num_slices, cluster in [(1, v4_8), (2, v4_8), (1, v4_16)]: |
| 40 | + ici_chips = 4 if cluster == v4_8 else 8 |
| 41 | + run_cmds = ( |
| 42 | + ( |
| 43 | + "python /pytorch/xla/test/spmd/test_sharding_strategies.py " |
| 44 | + f"--ici_fsdp_parallelism {ici_chips} " |
| 45 | + f"--dcn_data_parallelism {num_slices}" |
| 46 | + ), |
| 47 | + ) |
| 48 | + pytorch_config.get_nightly_pytorch_config( |
| 49 | + test_name="shardings", |
| 50 | + test_owner=test_owner.JON_B, |
| 51 | + run_commands=run_cmds, |
| 52 | + cluster=cluster, |
| 53 | + num_slices=num_slices, |
| 54 | + ).run() |
| 55 | + |
| 56 | + pytorch_config.get_nightly_pytorch_config( |
| 57 | + test_name="checkpoint", |
| 58 | + test_owner=test_owner.JON_B, |
| 59 | + run_commands=( |
| 60 | + f"export CHKPT_PATH={metric_config.SshEnvVars.GCS_OUTPUT.value}", |
| 61 | + "pip install gcsfs", |
| 62 | + ( |
| 63 | + "python /pytorch/xla/test/spmd/test_xla_distributed_checkpoint.py " |
| 64 | + "EndToEndCheckpointTest.test_multihost_checkpoint" |
| 65 | + ), |
| 66 | + ), |
| 67 | + cluster=v4_16, |
| 68 | + num_slices=2, |
| 69 | + ).run() |
0 commit comments