Skip to content

Commit 9bf007d

Browse files
dierksenclaude
andauthored
Add/update multi node/multi GPU test scripts (#2410)
<!-- .github/pull_request_template.md --> ## 📌 Description - Renames the unit testing script to more accurately reflect current usage - adds multi-node and multi-GPU testing scripts - refactors common code for those 3 scripts into a separate file ## 🔍 Related Issues <!-- Link any related issues here --> ## 🚀 Pull Request Checklist Thank you for contributing to FlashInfer! Before we review your pull request, please make sure the following items are complete. ### ✅ Pre-commit Checks - [x] I have installed `pre-commit` by running `pip install pre-commit` (or used your preferred method). - [x] I have installed the hooks with `pre-commit install`. - [x] I have run the hooks manually with `pre-commit run --all-files` and fixed any reported issues. > If you are unsure about how to set up `pre-commit`, see [the pre-commit documentation](https://pre-commit.com/). ## 🧪 Tests - [ ] Tests have been added or updated as needed. - [ ] All tests are passing (`unittest`, etc.). ## Reviewer Notes <!-- Optional: anything you'd like reviewers to focus on, concerns, etc. --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Chores** * Centralized and consolidated test orchestration and utilities for consistent unit, multi‑GPU, and multi‑node test runs. * Improved environment handling, install/verify flows, and deterministic test sampling across runners. * **New Features** * Added dry‑run mode, clearer test‑mode banners, and detailed execution and dry‑run summaries for easier test planning and reporting. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 567ded1 commit 9bf007d

5 files changed

Lines changed: 629 additions & 432 deletions

scripts/task_run_unit_tests.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
# Get the directory where this script is located
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
# Source test environment setup (handles package overrides like TVM-FFI)
8+
source "${SCRIPT_DIR}/setup_test_env.sh"
9+
10+
# Source common test functions
11+
# shellcheck disable=SC1091 # File exists, checked separately
12+
source "${SCRIPT_DIR}/test_utils.sh"
13+
14+
# Find and filter test files based on pytest.ini exclusions
15+
find_test_files() {
16+
echo "Reading pytest.ini for excluded directories..."
17+
EXCLUDED_DIRS=""
18+
if [ -f "./pytest.ini" ]; then
19+
# Extract norecursedirs from pytest.ini and convert to array
20+
NORECURSEDIRS=$(grep "^norecursedirs" ./pytest.ini | sed 's/norecursedirs\s*=\s*//' | sed 's/#.*//')
21+
if [ -n "$NORECURSEDIRS" ]; then
22+
EXCLUDED_DIRS=$(echo "$NORECURSEDIRS" | tr ',' ' ' | tr -s ' ')
23+
echo "⚠️ WARNING: Excluding directories from pytest.ini: $EXCLUDED_DIRS"
24+
echo ""
25+
fi
26+
fi
27+
28+
echo "Finding all test_*.py files in tests/ directory..."
29+
30+
# Find all test_*.py files
31+
ALL_TEST_FILES=$(find tests/ -name "test_*.py" -type f | sort)
32+
33+
# Filter out excluded files based on directory exclusions
34+
TEST_FILES=""
35+
for test_file in $ALL_TEST_FILES; do
36+
exclude_file=false
37+
test_dir=$(dirname "$test_file")
38+
39+
for excluded_dir in $EXCLUDED_DIRS; do
40+
excluded_dir=$(echo "$excluded_dir" | xargs) # trim whitespace
41+
if [ -n "$excluded_dir" ]; then
42+
# Check if this file's directory should be excluded
43+
if [[ "$test_dir" == *"/$excluded_dir" ]] || [[ "$test_dir" == "tests/$excluded_dir" ]] || [[ "$test_dir" == *"/$excluded_dir/"* ]]; then
44+
exclude_file=true
45+
break
46+
fi
47+
fi
48+
done
49+
50+
if [ "$exclude_file" = false ]; then
51+
TEST_FILES="$TEST_FILES $test_file"
52+
fi
53+
done
54+
55+
# Clean up whitespace
56+
TEST_FILES=$(echo "$TEST_FILES" | xargs)
57+
58+
if [ -z "$TEST_FILES" ]; then
59+
echo "No test files found in tests/ directory (after exclusions)"
60+
exit 1
61+
fi
62+
63+
echo "Found test files:"
64+
for test_file in $TEST_FILES; do
65+
echo " $test_file"
66+
done
67+
echo ""
68+
}
69+
70+
# Main execution
71+
main() {
72+
# Parse command line arguments
73+
parse_args "$@"
74+
75+
# Print test mode banner
76+
print_test_mode_banner
77+
78+
# Install and verify (includes precompiled kernels)
79+
install_and_verify
80+
81+
# Find test files (unique to unit tests - auto-discovery)
82+
find_test_files
83+
84+
# Execute tests or dry run
85+
if [ "$DRY_RUN" == "true" ]; then
86+
execute_dry_run "$TEST_FILES"
87+
else
88+
execute_tests "$TEST_FILES"
89+
fi
90+
91+
exit "$EXIT_CODE"
92+
}
93+
94+
main "$@"

0 commit comments

Comments
 (0)