Repository navigation
[CI] Re-enable multi-GPU tests on two-GPU runners #8275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a250aaf
e61d7a5
80c1d9b
67bc9a2
af9119b
2a2d654
0c2c416
824fcdb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,43 +57,51 @@ else | |
| DEV_COUNT=$GPU_COUNT | ||
| echo "::notice::container: discrete mode, $GPU_COUNT GPUs" | ||
| fi | ||
| if [ "$DEV_COUNT" -lt 2 ]; then | ||
| echo "::error::Need at least 2 visible devices; found $DEV_COUNT" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Cross-check with torch and cap shard count to what torch can actually | ||
| # address. Guards against a CUDA_VISIBLE_DEVICES misconfig silently fanning | ||
| # out shards that crash on device access. | ||
| TORCH_COUNT=$(/isaac-sim/python.sh -c "import torch; print(torch.cuda.device_count())") | ||
| # torch lives in the image's venv, not Kit's bundled Python, so resolve it the way the shards do. | ||
| TORCH_COUNT=$(uv run --no-sync isaaclab -p -c "import torch; print(torch.cuda.device_count())" | tail -n1) | ||
| if ! [[ "$TORCH_COUNT" =~ ^[0-9]+$ ]]; then | ||
| echo "::error::Could not read torch.cuda.device_count(); got '$TORCH_COUNT'" | ||
| exit 1 | ||
| fi | ||
| echo "container: torch sees $TORCH_COUNT cuda devices (cross-check vs $DEV_COUNT)" | ||
| if [ "$TORCH_COUNT" -lt "$DEV_COUNT" ]; then | ||
| echo "::warning::torch sees fewer devices than nvidia-smi β capping shards to $TORCH_COUNT" | ||
| DEV_COUNT=$TORCH_COUNT | ||
| fi | ||
| if [ "$DEV_COUNT" -lt 2 ]; then | ||
| echo "::error::Need at least 2 visible devices; found $DEV_COUNT" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Fan out 1 pytest subshell per non-default cuda:N. Each gets its own HOME | ||
| # (per-shard isolation for .cache, .local/share, etc.) and per-shard | ||
| # ISAACLAB_TEST_DEVICES. | ||
| declare -A pids # associative array: shard index -> background PID | ||
| for ((cuda = 1; cuda < DEV_COUNT; cuda++)); do # C-style loop; start at 1 to skip cuda:0 (single-GPU CI covers it) | ||
| zeros="" | ||
| # Fan out 1 pytest subshell per shard. Each gets its own HOME (per-shard | ||
| # isolation for .cache, .local/share, etc.) and per-shard ISAACLAB_TEST_DEVICES. | ||
| # launch_shard <name> <cuda> [<CUDA_VISIBLE_DEVICES>] | ||
| declare -A pids # associative array: shard name -> background PID | ||
| launch_shard() { | ||
| local name="$1" cuda="$2" cvd="${3:-}" | ||
| local zeros="" | ||
| for ((i = 0; i <= cuda; i++)); do zeros+="0"; done # build the leading zeros of the device mask | ||
| runtime_devices="${zeros}1" # e.g. cuda:2 -> "0001": only this GPU active in the ISAACLAB_TEST_DEVICES mask | ||
| local runtime_devices="${zeros}1" # e.g. cuda:2 -> "0001": only this GPU active in the ISAACLAB_TEST_DEVICES mask | ||
|
|
||
| shard_home="/tmp/isaaclab-ci-home-${cuda}" | ||
| local shard_home="/tmp/isaaclab-ci-home-${name}" | ||
| mkdir -p "${shard_home}/.cache" "${shard_home}/.local/share" \ | ||
| "${shard_home}/.nvidia-omniverse/config" \ | ||
| "${shard_home}/.nvidia-omniverse/logs" | ||
|
|
||
| shard_log="/shard-logs/cuda-${cuda}.log" | ||
| local shard_log="/shard-logs/cuda-${name}.log" | ||
|
|
||
| # each shard runs in its own subshell, backgrounded with '&' below, so all shards run in parallel | ||
| ( | ||
| export HOME="$shard_home" | ||
| export XDG_CACHE_HOME="${HOME}/.cache" | ||
| export XDG_DATA_HOME="${HOME}/.local/share" | ||
| export ISAACLAB_TEST_DEVICES="$runtime_devices" | ||
| export ISAACLAB_TEST_QUEUE_SHARD="cuda-${name}" # done/<shard>/ in the queue, so the summary splits shards | ||
| [ -z "$cvd" ] || export CUDA_VISIBLE_DEVICES="$cvd" | ||
|
|
||
| # Full pytest output captures to $shard_log; live stdout is filtered | ||
| # down to high-signal lines (test boundaries, failures, summary stats, | ||
|
|
@@ -110,17 +118,31 @@ for ((cuda = 1; cuda < DEV_COUNT; cuda++)); do # C-style loop; start at 1 to sk | |
| | tee "$shard_log" \ | ||
| | stdbuf -oL grep -aE \ | ||
| 'π|^source/.*::.* (PASSED|FAILED|ERROR|SKIPPED|XFAIL|XPASS)|^(Total|Passing|Failing|Crashed|Startup Hang|Timeout|Total Wall Time|Total Test Time|Passing Percentage):|^~~~~|^=+ |^E +|^ +File |Traceback|^FAILED|^ERROR ' \ | ||
| | stdbuf -oL sed "s/^/[cuda:${cuda}] /" | ||
| | stdbuf -oL sed "s/^/[cuda:${name}] /" | ||
|
|
||
| exit "${PIPESTATUS[0]}" # exit with pytest's code, not tee/grep/sed's (PIPESTATUS[0] = first pipe stage) | ||
| ) & | ||
| pids[$cuda]=$! # $! = PID of the subshell just backgrounded | ||
| echo "::notice::launched shard cuda:${cuda} (pid ${pids[$cuda]}, runtime_devices=$runtime_devices)" | ||
| pids[$name]=$! # $! = PID of the subshell just backgrounded | ||
| echo "::notice::launched shard cuda:${name} (pid ${pids[$name]}, runtime_devices=$runtime_devices${cvd:+, CUDA_VISIBLE_DEVICES=$cvd})" | ||
| } | ||
|
|
||
| for ((cuda = 1; cuda < DEV_COUNT; cuda++)); do # start at 1: a shard tests a non-default device index | ||
| launch_shard "$cuda" "$cuda" | ||
| done | ||
|
|
||
| # Physical GPU 0 would idle, since single-GPU CI covers cuda:0. Swapping the first two visible | ||
| # devices makes it this shard's cuda:1, so it still tests a non-default index. | ||
| if [ -n "${CUDA_VISIBLE_DEVICES:-}" ]; then | ||
| IFS=',' read -ra visible <<< "$CUDA_VISIBLE_DEVICES" | ||
| else | ||
| mapfile -t visible < <(seq 0 $((DEV_COUNT - 1))) | ||
| fi | ||
| swapped=("${visible[1]}" "${visible[0]}" "${visible[@]:2}") | ||
| launch_shard "1-gpu0" 1 "$(IFS=,; echo "${swapped[*]}")" | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π΅ Suggestion Β· Implementation β Extra shard ignores torch device cap The torch cross-check can lower
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 127d9f44286: the two-device minimum now runs after the torch cap, so the extra shard never launches with fewer than two devices. |
||
|
|
||
| # Wait for every shard before aggregating exits β a fast failure must not | ||
| # tear down still-running siblings. | ||
| declare -A results # associative array: shard index -> exit code | ||
| declare -A results # associative array: shard name -> exit code | ||
| for cuda in "${!pids[@]}"; do # "${!pids[@]}" = the array's keys (the shard indices) | ||
| wait "${pids[$cuda]}" # block until that shard's PID exits | ||
| results[$cuda]=$? # $? = the waited shard's exit code | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,26 +108,21 @@ jobs: | |
| build: | ||
| name: Build / cache image | ||
| needs: [config, changes] | ||
| # One builder for the image both the unit shards and the Kit smoke run, so a dependency | ||
| # change builds it once instead of in both jobs racing to push the same tag. | ||
| if: needs.changes.outputs.unit == 'true' || needs.changes.outputs.smoke == 'true' | ||
| # Must run on the SAME pool as the test job. The ECR cache repo is resolved | ||
| # Must run on the SAME pool as the test jobs. The ECR cache repo is resolved | ||
| # per runner pool (single-GPU `gpu` runners -> gitci-docker-cache; multi-GPU | ||
| # runners -> multigpu-docker-cache). If this built on `[self-hosted, gpu]` | ||
| # the image would land in gitci-docker-cache, which the multi-GPU test job | ||
| # cannot see, so it would rebuild from scratch on the scarce multi-GPU | ||
| # runner. Building here populates multigpu-docker-cache so the test job's | ||
| # pull hits. | ||
| # runners -> multigpu-docker-cache), so an image built on `[self-hosted, gpu]` | ||
| # would be invisible to the multi-GPU test jobs. | ||
| runs-on: [self-hosted, linux, x64, multi-gpu] | ||
| steps: | ||
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| fetch-depth: 1 | ||
| lfs: true | ||
|
|
||
| # Pre-populates the ECR exact-commit tag from deps-cache (registry-side | ||
| # alias). Without this prior step, run-package-tests' internal | ||
| # ecr-build-push-pull hits exact-cache-miss + deps-cache-hit and leaves | ||
| # no local image, causing `docker run` to fail with `pull access | ||
| # denied`. Mirrors the build β test split in build.yaml. | ||
| # Pushes the exact-commit tag: built on a miss, aliased registry-side on a deps-cache hit. | ||
| - uses: ./.github/actions/ecr-build-push-pull | ||
| env: | ||
| NGC_API_KEY: ${{ secrets.NGC_API_KEY }} | ||
|
|
@@ -168,18 +163,13 @@ jobs: | |
| test-multi-gpu-pytest: | ||
| name: Multi-GPU unit tests | ||
| needs: [config, build, changes] | ||
| # ``always()`` is load-bearing: ``build`` is skipped when neither gate fires, and GitHub skips | ||
| # a job whose dependency skipped unless the condition carries a status function. Without it a | ||
| # gate-miss would silently skip the shards too. | ||
| if: always() && needs.build.result == 'success' | ||
| if: needs.changes.outputs.unit == 'true' | ||
| # The ``multi-gpu`` label is the multi-GPU pool. Do NOT add ``gpu`` here: | ||
| # in this fleet ``gpu`` tags single-GPU runners, so requiring it routes the | ||
| # job onto a 1-GPU box and the shard runner aborts with "Need at least 2 | ||
| # visible devices; found 1". | ||
| runs-on: [self-hosted, linux, x64, multi-gpu] | ||
| # Shards plus the full training-smoke matrix. The smoke alone is ~30 min | ||
| # (Kit boot dominates the Kit-renderer cases), so 60 no longer fits. | ||
| timeout-minutes: 120 | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
@@ -235,10 +225,8 @@ jobs: | |
|
|
||
| - name: Pull image from ECR | ||
| # Pulls the per-commit image the build job pushed. ecr-build-push-pull | ||
| # handles ECR auth via the EC2 IAM role, and on exact-cache-hit (which | ||
| # the build job's deps-cache-hit registry-tag created for this SHA) | ||
| # it pulls the image locally and tags it as ``$CI_IMAGE_TAG`` for our | ||
| # parallel ``docker run`` block below. | ||
| # handles ECR auth via the EC2 IAM role and, on the exact-tag hit, leaves | ||
| # the image locally as ``$CI_IMAGE_TAG`` for the ``docker run`` block below. | ||
| uses: ./.github/actions/ecr-build-push-pull | ||
| env: | ||
| NGC_API_KEY: ${{ secrets.NGC_API_KEY }} | ||
|
|
@@ -249,6 +237,17 @@ jobs: | |
| dockerfile-path: docker/Dockerfile.base | ||
| cache-tag: cache-base | ||
|
|
||
| - name: Resolve Warp cache key | ||
| id: warp-cache-key | ||
| uses: ./.github/actions/warp-cache-key | ||
|
|
||
| - name: Restore Warp kernel cache | ||
| uses: actions/cache/restore@v4 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new cache step uses the movable How this was verified: The added step uses Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keeping
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You're right β consistency with the repository's existing |
||
| with: | ||
| path: ${{ steps.warp-cache-key.outputs.host-dir }} | ||
| key: ${{ steps.warp-cache-key.outputs.key }} | ||
| restore-keys: ${{ steps.warp-cache-key.outputs.restore-keys }} | ||
|
|
||
| - name: Run shards in parallel on local GPUs (1-docker N-shard) | ||
| # ONE container hosts all N pytest shards as parallel subshells, each | ||
| # pinned to its own non-default cuda:N and pulling from a shared work | ||
|
|
@@ -259,43 +258,74 @@ jobs: | |
| IMAGE_TAG: ${{ env.CI_IMAGE_TAG }} | ||
| INCLUDE_FILES: ${{ steps.discover.outputs.include }} | ||
| PATHS: ${{ steps.discover.outputs.paths }} | ||
| if: needs.changes.outputs.unit == 'true' | ||
| # Files per shard at once, as the package jobs in build.yaml run them. | ||
| TEST_JOBS: "4" | ||
| WARP_CACHE_HOST_DIR: ${{ steps.warp-cache-key.outputs.host-dir }} | ||
| run: bash .github/actions/multi-gpu/multi_gpu_host_launcher.sh | ||
|
|
||
| - name: Aggregated test summary | ||
| # Per-shard + per-file pass/total/walltime, plus a combined table, also | ||
| # written to $GITHUB_STEP_SUMMARY. Runs on success or failure. | ||
| if: always() | ||
| env: | ||
| RUNTIME_DIR: ${{ env.MGPU_RUNTIME_DIR }} | ||
| run: python3 .github/actions/multi-gpu/aggregate_test_summary.py | ||
|
|
||
| test-multi-gpu-smoke-kit: | ||
| name: Multi-GPU training smoke (Kit) | ||
| needs: [config, build, changes] | ||
| # Its own job so it runs beside the shards instead of after them. | ||
| if: needs.changes.outputs.smoke == 'true' | ||
| runs-on: [self-hosted, linux, x64, multi-gpu] | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
| with: | ||
| fetch-depth: 1 | ||
| lfs: true | ||
|
|
||
| - name: Pull image from ECR | ||
| # The per-commit image the build job pushed; see the unit-test job. | ||
| uses: ./.github/actions/ecr-build-push-pull | ||
| env: | ||
| NGC_API_KEY: ${{ secrets.NGC_API_KEY }} | ||
| with: | ||
| image-tag: ${{ env.CI_IMAGE_TAG }} | ||
| isaacsim-base-image: ${{ needs.config.outputs.isaacsim_image_name }} | ||
| isaacsim-version: ${{ needs.config.outputs.isaacsim_image_tag }} | ||
| dockerfile-path: docker/Dockerfile.base | ||
| cache-tag: cache-base | ||
|
|
||
| - name: Multi-GPU training smoke (Kit renderer) | ||
| # Real multi-rank training runs, outside the sharded device-parametrized | ||
| # path above: a multi-GPU job owns several GPUs at once, so a per-device | ||
| # shard cannot express it. Unsharded, all GPUs exposed; the tests choose | ||
| # their own device order. | ||
| # path: a multi-GPU job owns several GPUs at once, so a per-device shard | ||
| # cannot express it. Unsharded, all GPUs exposed; the tests choose their | ||
| # own device order. ``-n 4`` runs four cases at once; each is small enough | ||
| # to share the GPUs, and Kit boot dominates a case. | ||
| # | ||
| # Uses the shared run-tests action rather than a bespoke ``docker run``: | ||
| # passing a file path (not ``tools``) skips the conftest sharding | ||
| # orchestrator, so this is a plain single pytest run, while still | ||
| # inheriting the standard container contract -- writable HOME, the Isaac | ||
| # Sim cache mounts, and junit results collected into ``reports/``. | ||
| # Runs on failure too, so a red shard does not hide smoke coverage. | ||
| if: always() && needs.changes.outputs.smoke == 'true' | ||
| # orchestrator, so this is a plain pytest run, while still inheriting the | ||
| # standard container contract -- writable HOME, the Isaac Sim cache mounts, | ||
| # and junit results collected into ``reports/``. | ||
| uses: ./.github/actions/run-tests | ||
| env: | ||
| # Fail rather than skip when the runner has fewer than two GPUs; the job is not a | ||
| # required check, so this turns lost coverage red without blocking a merge. | ||
| ISAACLAB_TEST_REQUIRE_MULTI_GPU: "1" | ||
| with: | ||
| test-path: source/isaaclab/test/multi_gpu/test_multi_gpu_training_smoke.py | ||
| result-file: multi-gpu-smoke-report.xml | ||
| container-name: isaac-lab-mgpu-smoke-${{ github.run_id }}-${{ github.run_attempt }} | ||
| image-tag: ${{ env.CI_IMAGE_TAG }} | ||
| pytest-options: -m "not kitless" | ||
| pytest-options: -m "not kitless" -n 4 | ||
| # Run the checkout, not the image's baked-in copy. ecr-build-push-pull serves a | ||
| # commit-tagged or deps-cache image, so on a cache hit the container carries source | ||
| # from whenever that image was built -- CI then reports a pass or fail for code this | ||
| # commit never contained. The shard launcher already bind-mounts for this reason. | ||
| # commit never contained. The shard launcher bind-mounts for the same reason. | ||
| volume-mount-source: ${{ github.workspace }} | ||
|
|
||
| - name: Aggregated test summary | ||
| # Per-shard + per-file pass/total/walltime, plus a combined table, also | ||
| # written to $GITHUB_STEP_SUMMARY. Runs on success or failure. | ||
| if: always() | ||
| env: | ||
| RUNTIME_DIR: ${{ env.MGPU_RUNTIME_DIR }} | ||
| run: python3 .github/actions/multi-gpu/aggregate_test_summary.py | ||
|
|
||
| test-multi-gpu-smoke-kitless: | ||
| name: Multi-GPU training smoke (kit-less) | ||
| needs: [config, build-kitless, changes] | ||
|
|
@@ -305,7 +335,6 @@ jobs: | |
| # scheduler serialises them onto it, which is the previous behaviour. | ||
| if: always() && needs.build-kitless.result == 'success' && needs.changes.outputs.smoke == 'true' | ||
| runs-on: [self-hosted, linux, x64, multi-gpu] | ||
| # One lane only; the 120 min ceiling on the sharded job covers shards + Kit smoke together. | ||
| timeout-minutes: 60 | ||
| steps: | ||
| - name: Checkout repository | ||
|
|
@@ -328,18 +357,21 @@ jobs: | |
| isaacsim-version: ${{ needs.config.outputs.isaacsim_image_tag }} | ||
| dockerfile-path: docker/Dockerfile.kitless | ||
| cache-tag: cache-kitless | ||
| pull-on-deps-hit: 'true' | ||
|
|
||
| - name: Multi-GPU training smoke (kitless renderer) | ||
| # Same tests as the Kit lane with the marker inverted, but run in the kit-less image, | ||
| # which already carries ``ov[all]``. Each stack runs in the image built for it, and the | ||
| # job split keeps a kitless-renderer fault from taking down the Kit-renderer coverage | ||
| # that guards renderer device selection. | ||
| uses: ./.github/actions/run-tests | ||
| env: | ||
| ISAACLAB_TEST_REQUIRE_MULTI_GPU: "1" # same as the Kit lane | ||
| with: | ||
| test-path: source/isaaclab/test/multi_gpu/test_multi_gpu_training_smoke.py | ||
| result-file: multi-gpu-smoke-kitless-report.xml | ||
| container-name: isaac-lab-mgpu-smoke-kitless-${{ github.run_id }}-${{ github.run_attempt }} | ||
| image-tag: ${{ env.CI_KITLESS_IMAGE_TAG }} | ||
| pytest-options: -m kitless | ||
| # Same reason as the Kit step above. | ||
| pytest-options: -m kitless -n 4 | ||
| # Same reason as the Kit lane. | ||
| volume-mount-source: ${{ github.workspace }} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both the original shard and
1-gpu0selectcuda:1. The queue names shards fromresolve_test_sim_device(), not the name passed tolaunch_shard, so both GPUs put completed files underdone/cuda-1. The summary combines them into one row, hiding which files ran on physical GPU 0. Pass a separate shard identifier to the queue helpers so each GPU has its own summary.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 127d9f44286: each shard exports
ISAACLAB_TEST_QUEUE_SHARD(cuda-1,cuda-1-gpu0) andtools/conftest.pyfiles its queue claims under it, so the summary has one row per physical GPU.