From e01fc4eb3ac8a1ae69ff7fb7c1cc75fbd6f33f7c Mon Sep 17 00:00:00 2001 From: phoenixdong Date: Tue, 4 Jun 2024 20:41:46 +0800 Subject: [PATCH 1/2] add test coverage report --- .coveragerc | 5 ++++ .github/workflows/test.yml | 34 +++++++++++++++++++--------- tests/scripts/unit_test_flagscale.sh | 2 +- tests/scripts/unit_test_megatron.sh | 16 ++++++------- 4 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..29de6ff8a --- /dev/null +++ b/.coveragerc @@ -0,0 +1,5 @@ +[html] +directory = coverage + +[run] +data_file = .coverage_$LOCAL_RANK diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 916795d86..c9ff429ff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ name: flagscale-test on: push: - branches: [ "main" ] + branches: [ "main" , "test_coverage"] pull_request: branches: [ "main" ] @@ -13,7 +13,7 @@ jobs: container-test-job: runs-on: self-hosted container: - image: localhost:5000/flagscale_cicd:v1.2 + image: localhost:5000/flagscale_cicd:v1.3 ports: - 80 options: --gpus all --hostname flagscale_cicd @@ -25,19 +25,31 @@ jobs: run: | cd megatron export PYTHONPATH=..:$PYTHONPATH - torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/data - torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/dist_checkpointing - torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/fusions - torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/models - torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/pipeline_parallel - torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/tensor_parallel - torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/transformer - torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/*.py + torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/data + torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/dist_checkpointing + torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/fusions + torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/models + torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/pipeline_parallel + torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/tensor_parallel + torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/transformer + torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/*.py + + - name: Archive code coverage results megatron + uses: actions/upload-artifact@v4 + with: + name: code-coverage-report-megatron + path: cov-report-megatron - name: unit_test-flagscale run: | - torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/launcher + torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:cov-report-flagscale --cov=flagscale -q -x tests/unit_tests/launcher + - name: Archive code coverage results flagscale + uses: actions/upload-artifact@v4 + with: + name: code-coverage-report-flagscale + path: cov-report-flagscale + - name: functional_test-flagscale run: | python run.py --config-path tests/functional_tests/aquila/conf --config-name config action=test diff --git a/tests/scripts/unit_test_flagscale.sh b/tests/scripts/unit_test_flagscale.sh index 5ab8280d0..46861add6 100755 --- a/tests/scripts/unit_test_flagscale.sh +++ b/tests/scripts/unit_test_flagscale.sh @@ -1 +1 @@ -torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/launcher \ No newline at end of file +torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:./cov-report-flagscale --cov=flagscale -q -x tests/unit_tests/launcher \ No newline at end of file diff --git a/tests/scripts/unit_test_megatron.sh b/tests/scripts/unit_test_megatron.sh index 5b4773db0..eef8e585a 100755 --- a/tests/scripts/unit_test_megatron.sh +++ b/tests/scripts/unit_test_megatron.sh @@ -2,11 +2,11 @@ cd megatron export PYTHONPATH=..:$PYTHONPATH -torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/data -torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/dist_checkpointing -torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/fusions -torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/models -torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/pipeline_parallel -torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/tensor_parallel -torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/transformer -torchrun --nproc_per_node=8 -m pytest --import-mode=importlib -q -x tests/unit_tests/*.py \ No newline at end of file +torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/data +torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/dist_checkpointing +torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/fusions +torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/models +torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/pipeline_parallel +torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/tensor_parallel +torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/transformer +torchrun --nproc_per_node=8 -m pytest --import-mode=importlib --cov-append --cov-report=html:../cov-report-megatron --cov=megatron/core -q -x tests/unit_tests/*.py \ No newline at end of file From 12e2a9e790ece27b7f086d108a3f948fa601a52e Mon Sep 17 00:00:00 2001 From: phoenixdong Date: Tue, 4 Jun 2024 21:05:57 +0800 Subject: [PATCH 2/2] add test coverage report --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c9ff429ff..8740bdb8e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ name: flagscale-test on: push: - branches: [ "main" , "test_coverage"] + branches: [ "main" ] pull_request: branches: [ "main" ]