This directory contains tests for the torchtitan project, including unit tests and integration tests.
unit_tests/: Contains unit tests for individual componentsintegration_tests/: Contains integration tests that test multiple components togetherbase_config.toml: Base configuration file for integration testsfeatures.py: Tests for torchtitan features and composabilityft.py: Fault-tolerance integration testsh100.py: Tests cases for H100 GPUsmodels.py: Tests for specific model architectures and configurations
assets/: Contains test assets and fixtures used by the teststokenizer/: Tokenizer configuration and vocabulary files for testingcustom_schedule.csv: Custom PP schedule for testing
Ensure you have all development dependencies installed:
pip install -r requirements-dev.txt
pip install -r requirements.txtTo run the integration tests:
python -m tests.integration_tests.run_tests <output_dir> [--config_path CONFIG_PATH] [--test_suite TEST_SUITE] [--test_name TEST_NAME] [--ngpu NGPU]Arguments:
output_dir: (Required) Directory where test outputs will be stored--test_suite: (Optional) Specific test suite to run by name (default: "features")--config_path: (Optional) Path to the base config file (default: "./tests/integration_tests/base_config.toml")--test_name: (Optional) Specific test to run by name (default: "all")--ngpu: (Optional) Number of GPUs to use for testing (default: 8)
Examples:
# Run all model integration tests with 8 GPUs
python -m tests.integration_tests.run_tests test_output
# Run only core functionality tests for features
python -m tests.integration_tests.run_tests test_output --test_suite features
# Run a specific test with 2 GPUs
python -m tests.integration_tests.run_tests test_output --test_suite features --test_name gradient_accumulation --ngpu 2
To run only the unit tests:
pytest -s tests/unit_tests/To run a specific test file:
pytest -s tests/unit_tests/test_job_config.pyTo run a specific test function:
pytest -s tests/unit_tests/test_job_config.py::TestJobConfig::test_command_line_args