|
| 1 | +# Copyright (c) Meta Platforms, Inc. and affiliates. |
| 2 | +# All rights reserved. |
| 3 | +# |
| 4 | +# This source code is licensed under the BSD-style license found in the |
| 5 | +# LICENSE file in the root directory of this source tree. |
| 6 | + |
| 7 | +import argparse |
| 8 | +import os |
| 9 | + |
| 10 | +from tests.integration_tests import OverrideDefinitions |
| 11 | +from tests.integration_tests.run_tests import run_tests |
| 12 | + |
| 13 | + |
| 14 | +def build_auto_parallel_test_list() -> list[OverrideDefinitions]: |
| 15 | + """ |
| 16 | + returns a list of OverrideDefinitions that is used to generate |
| 17 | + variations of integration tests based on the same root config file. |
| 18 | + """ |
| 19 | + integration_tests_flavors = [ |
| 20 | + # llama3 tests |
| 21 | + OverrideDefinitions( |
| 22 | + [ |
| 23 | + [ |
| 24 | + "--model.name auto_parallel.llama3", |
| 25 | + "--parallelism.data_parallel_shard_degree 2", |
| 26 | + "--parallelism.tensor_parallel_degree 2", |
| 27 | + "--job.custom_config_module=torchtitan.experiments.auto_parallel.job_config", |
| 28 | + ], |
| 29 | + ], |
| 30 | + "llama3 AutoParallel FSDP+TP", |
| 31 | + "llama3_autoparallel_fsdp_tp", |
| 32 | + ngpu=4, |
| 33 | + ), |
| 34 | + # TODO: Re-enable this once we fix the test |
| 35 | + # deepseek_v3 tests |
| 36 | + # OverrideDefinitions( |
| 37 | + # [ |
| 38 | + # [ |
| 39 | + # "--model.name auto_parallel.deepseek_v3", |
| 40 | + # "--parallelism.data_parallel_shard_degree 2", |
| 41 | + # "--parallelism.expert_parallel_degree 2", |
| 42 | + # "--job.custom_config_module=torchtitan.experiments.auto_parallel.job_config", |
| 43 | + # "--activation_checkpoint.mode none", |
| 44 | + # ], |
| 45 | + # ], |
| 46 | + # "deepseek_v3 AutoParallel FSDP+TP+EP", |
| 47 | + # "deepseekv3_autoparallel_fsdp_tp_ep", |
| 48 | + # ngpu=4, |
| 49 | + # ), |
| 50 | + ] |
| 51 | + return integration_tests_flavors |
| 52 | + |
| 53 | + |
| 54 | +_TEST_SUITES_FUNCTION = { |
| 55 | + "auto_parallel": build_auto_parallel_test_list, |
| 56 | +} |
| 57 | + |
| 58 | + |
| 59 | +def main(): |
| 60 | + parser = argparse.ArgumentParser() |
| 61 | + parser.add_argument("output_dir") |
| 62 | + parser.add_argument( |
| 63 | + "--config_path", |
| 64 | + default="./tests/integration_tests/base_config.toml", |
| 65 | + help="Base config path for integration tests. This is the config that will be used as a base for all tests.", |
| 66 | + ) |
| 67 | + parser.add_argument( |
| 68 | + "--test_name", |
| 69 | + default="all", |
| 70 | + help="test to run, acceptable values: `test_name` in `build_test_list` (default: all)", |
| 71 | + ) |
| 72 | + parser.add_argument("--ngpu", default=8, type=int) |
| 73 | + args = parser.parse_args() |
| 74 | + |
| 75 | + if not os.path.exists(args.output_dir): |
| 76 | + os.makedirs(args.output_dir) |
| 77 | + if os.listdir(args.output_dir): |
| 78 | + raise RuntimeError("Please provide an empty output directory.") |
| 79 | + |
| 80 | + test_list = _TEST_SUITES_FUNCTION["auto_parallel"]() |
| 81 | + run_tests(args, test_list) |
| 82 | + |
| 83 | + |
| 84 | +if __name__ == "__main__": |
| 85 | + main() |
0 commit comments