Skip to content

Commit 7499a82

Browse files
ci: shard core unit tests
Signed-off-by: svcnemo-autobot <svcnemo-autobot@nvidia.com>
1 parent b6bf292 commit 7499a82

5 files changed

Lines changed: 37 additions & 1 deletion

File tree

‎.github/actions/test-template/action.yml‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,14 @@ inputs:
5959
runner:
6060
description: "Runner to use for test"
6161
required: true
62+
shard-id:
63+
description: "Zero-based pytest shard index"
64+
required: false
65+
default: ""
66+
num-shards:
67+
description: "Total number of pytest shards"
68+
required: false
69+
default: ""
6270

6371
runs:
6472
using: "composite"
@@ -135,6 +143,8 @@ runs:
135143
--env NEMO_HOME=/home/TestData/nemo_home \
136144
--env RUN_ID=${{ github.run_id }} \
137145
--env UV_NO_SYNC=1 \
146+
--env SHARD_ID=${{ inputs.shard-id }} \
147+
--env NUM_SHARDS=${{ inputs.num-shards }} \
138148
--workdir /opt/Megatron-Bridge \
139149
$VOLUME_ARGS \
140150
${{ inputs.container-image }} \

‎.github/workflows/cicd-main.yml‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,10 @@ jobs:
567567
--skip-file /opt/import-check/import_check_skip.txt
568568
569569
cicd-unit-tests-core:
570+
strategy:
571+
fail-fast: false
572+
matrix:
573+
shard-id: [0, 1, 2]
570574
if: |
571575
(
572576
success()
@@ -579,7 +583,7 @@ jobs:
579583
&& (github.event.inputs.test_suite == '' || github.event.inputs.test_suite == 'all' || github.event.inputs.test_suite == 'unit-only' || contains('L0 L1 L2', github.event.inputs.test_suite))
580584
needs: [pre-flight, configure, cicd-container-build]
581585
runs-on: ${{ needs.pre-flight.outputs.runner_prefix }}
582-
name: Launch_Unit_Tests_Core
586+
name: Launch_Unit_Tests_Core_${{ matrix.shard-id }}
583587
env:
584588
TRANSFORMERS_OFFLINE: "1"
585589
HF_HUB_OFFLINE: "1"
@@ -603,6 +607,8 @@ jobs:
603607
script: Launch_Unit_Tests_Core
604608
timeout: 18
605609
is_unit_test: "true"
610+
shard-id: ${{ matrix.shard-id }}
611+
num-shards: 3
606612
github-token: ${{ steps.app-token.outputs.token }}
607613
container-image: ${{ needs.pre-flight.outputs.registry }}/megatron-bridge:${{ needs.configure.outputs.merge_sha }}
608614
test-data-path: ${{ needs.pre-flight.outputs.test_data_path }}

‎pyproject.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ test = [
201201
"pytest-timeout>=2.4.0",
202202
"pytest-mock>=3.14.0",
203203
"pytest-runner>=6.0.1",
204+
"pytest-shard>=0.1.2",
204205
"pygithub",
205206
"click",
206207
]

‎tests/unit_tests/Launch_Unit_Tests_Core.sh‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ set -xeuo pipefail # Exit immediately if a command exits with a non-zero status
1717

1818
REPO_ROOT=$(cd "$(dirname "$0")/../.." && pwd)
1919

20+
: "${SHARD_ID:?SHARD_ID must be set}"
21+
: "${NUM_SHARDS:?NUM_SHARDS must be set}"
22+
2023
echo "=================================================="
2124
echo "🧪 UNIT TESTS (core)"
2225
echo "=================================================="
@@ -31,6 +34,8 @@ CUDA_VISIBLE_DEVICES="0,1" uv run coverage run -a --data-file="${REPO_ROOT}/.cov
3134
-o log_cli=true \
3235
-o log_cli_level=INFO \
3336
--disable-warnings \
37+
--shard-id="${SHARD_ID}" \
38+
--num-shards="${NUM_SHARDS}" \
3439
-vs tests/unit_tests \
3540
--ignore=tests/unit_tests/diffusion \
3641
-m "not pleasefixme"

‎uv.lock‎

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)