Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .github/actions/multi-gpu/multi_gpu_host_launcher.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
# IMAGE_TAG β€” per-commit CI image to ``docker run``
# INCLUDE_FILES β€” comma-sep test basenames (conftest include filter)
# PATHS β€” comma-sep relative test paths (seed the work queue)
# TEST_JOBS β€” test files each shard runs at once (tools/conftest.py); empty = serial
# WARP_CACHE_HOST_DIR β€” restored Warp kernel cache shared by every shard; empty = none
# plus the runner built-ins GITHUB_RUN_ID / GITHUB_RUN_ATTEMPT (container name)
# and GITHUB_ENV (exports MGPU_RUNTIME_DIR for the downstream summary step).
#
Expand Down Expand Up @@ -85,6 +87,14 @@ else
echo "::notice::discrete GPU mode β€” relying on --gpus all"
fi

# Same mount point and variable as .github/actions/run-tests/run_tests.sh, so kernels the
# single-GPU jobs compiled are reused here instead of rebuilt per shard.
warp_args=()
if [ -n "${WARP_CACHE_HOST_DIR:-}" ]; then
mkdir -p "$WARP_CACHE_HOST_DIR"
warp_args=(-v "${WARP_CACHE_HOST_DIR}:/tmp/isaaclab-warp-cache:rw" -e WARP_CACHE_PATH=/tmp/isaaclab-warp-cache)
fi

# "${cvd_args[@]}" expands to the CUDA_VISIBLE_DEVICES flag on MIG hosts, nothing otherwise.
docker run --rm --gpus all --network=host \
--entrypoint bash \
Expand All @@ -104,10 +114,12 @@ docker run --rm --gpus all --network=host \
-e PYTHONIOENCODING=utf-8 \
-e ISAACLAB_TEST_QUEUE=/mgpu \
-e TEST_INCLUDE_FILES="$INCLUDE_FILES" \
-e TEST_JOBS="${TEST_JOBS:-}" \
-e ISAACLAB_FABRIC_USE_GPU_INTEROP=0 \
-e HOME=/tmp/mgpu-base-home \
-e PYTHONUSERBASE=/tmp/mgpu-pyuserbase \
"${cvd_args[@]}" \
"${warp_args[@]}" \
-v "$PWD/.github/actions/multi-gpu/multi_gpu_shard_runner.sh:/multi_gpu_shard_runner.sh:ro" \
"$IMAGE_TAG" \
/multi_gpu_shard_runner.sh
Expand Down
58 changes: 40 additions & 18 deletions .github/actions/multi-gpu/multi_gpu_shard_runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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[*]}")"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Two GPUs share one summary

Both the original shard and 1-gpu0 select cuda:1. The queue names shards from resolve_test_sim_device(), not the name passed to launch_shard, so both GPUs put completed files under done/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.

Copy link
Copy Markdown
Collaborator Author

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) and tools/conftest.py files its queue claims under it, so the summary has one row per physical GPU.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 DEV_COUNT to 1 after the -lt 2 guard has passed. The loop then launches nothing, but this shard still runs: visible holds one entry, so swapped expands the unset visible[1] to empty and the shard starts with CUDA_VISIBLE_DEVICES=",0" while demanding cuda:1. That replaces a clear reconciler failure with a confusing crash. Guard this launch with the same DEV_COUNT >= 2 condition.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The 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
Expand Down
3 changes: 3 additions & 0 deletions .github/actions/run-tests/run_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ run_tests() {
echo "Setting CI_MARKER=$ci_marker"
fi

# Set by the multi-GPU smoke steps: fail rather than skip on a runner with too few GPUs.
[ -z "${ISAACLAB_TEST_REQUIRE_MULTI_GPU:-}" ] || docker_env_args+=(-e ISAACLAB_TEST_REQUIRE_MULTI_GPU)

if [ -n "$standalone_script_scope" ]; then
docker_env_args+=(
-e "ISAACLAB_RUN_STANDALONE_SCRIPT_TESTS=1"
Expand Down
120 changes: 76 additions & 44 deletions .github/workflows/test-multi-gpu-pytest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}
Expand All @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 security Cache action can change unseen

The new cache step uses the movable v4 tag, so upstream can change the code this self-hosted job runs without a change to this repository. Pin actions/cache/restore to a full commit SHA, as this workflow already does for actions/checkout.

How this was verified: The added step uses actions/cache/restore@v4 in a job that runs on a self-hosted multi-GPU runner.

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!

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping @v4: every actions/cache reference in the repo (build.yaml, check-links.yml, run-package-tests, ovrtx-shader-cache) uses the major tag, so this matches the existing convention.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right β€” consistency with the repository's existing actions/cache usage is the relevant standard here. Keeping @v4 is appropriate, so I'll withdraw this comment.

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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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 }}
Empty file.
Loading
Loading