Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Loading
Loading