Skip to content

Commit e58ac18

Browse files
committed
update reproduce script to skip repeated env setup
Signed-off-by: Zhang <jianmusings@gmail.com>
1 parent f69c1f1 commit e58ac18

1 file changed

Lines changed: 39 additions & 17 deletions

File tree

scripts/setup_pr7916.sh

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
#
1414
# Usage (from repo root):
1515
# ./scripts/setup_pr7916.sh
16+
# ./scripts/setup_pr7916.sh --skip-install # reuse .venvs/pr7916, no pip/venv setup
17+
# PR7916_SKIP_INSTALL=1 ./scripts/setup_pr7916.sh
1618
#
1719
# Activate later:
1820
# source .venvs/pr7916/bin/activate
@@ -24,30 +26,50 @@ cd "$ROOT"
2426
VENV_DIR="${PR7916_VENV_DIR:-$ROOT/.venvs/pr7916}"
2527
MAIN_REF="${PR7916_MAIN_REF:-master}"
2628

27-
echo "==> Using venv: $VENV_DIR (only this path is removed if it already exists)"
28-
rm -rf "$VENV_DIR"
29-
mkdir -p "$(dirname "$VENV_DIR")"
30-
python3 -m venv "$VENV_DIR"
31-
# shellcheck source=/dev/null
32-
. "$VENV_DIR/bin/activate"
29+
SKIP_INSTALL=0
30+
case "${PR7916_SKIP_INSTALL:-}" in
31+
1|true|yes|on) SKIP_INSTALL=1 ;;
32+
esac
33+
if [[ "${1:-}" == "--skip-install" ]]; then
34+
SKIP_INSTALL=1
35+
shift
36+
fi
3337

34-
python -c 'import sys; assert sys.version_info[:2] == (3, 11), "Use Python 3.11 to match the bug report"' || {
35-
echo "Warning: expected Python 3.11; found $(python -V)" >&2
36-
}
38+
if [[ "$SKIP_INSTALL" -eq 1 ]]; then
39+
echo "==> Skipping venv recreate and pip installs (reuse $VENV_DIR)"
40+
if [[ ! -f "$VENV_DIR/bin/activate" ]]; then
41+
echo "error: venv not found at $VENV_DIR — run once without --skip-install first." >&2
42+
exit 1
43+
fi
44+
# shellcheck source=/dev/null
45+
. "$VENV_DIR/bin/activate"
46+
python -c "import torch, deepspeed; print('torch', torch.__version__, 'cuda', torch.version.cuda); print('deepspeed', deepspeed.__file__); print('deepspeed version', deepspeed.__version__)"
47+
else
48+
echo "==> Using venv: $VENV_DIR (only this path is removed if it already exists)"
49+
rm -rf "$VENV_DIR"
50+
mkdir -p "$(dirname "$VENV_DIR")"
51+
python3 -m venv "$VENV_DIR"
52+
# shellcheck source=/dev/null
53+
. "$VENV_DIR/bin/activate"
3754

38-
pip install -U pip setuptools wheel
55+
python -c 'import sys; assert sys.version_info[:2] == (3, 11), "Use Python 3.11 to match the bug report"' || {
56+
echo "Warning: expected Python 3.11; found $(python -V)" >&2
57+
}
3958

40-
# PyTorch 2.8.0 + CUDA 12.8 (matches common functorch / ZeRO-3 bug reports)
41-
pip install "torch==2.8.0" --index-url https://download.pytorch.org/whl/cu128
59+
pip install -U pip setuptools wheel
4260

43-
pip install -r requirements/requirements.txt
61+
# PyTorch 2.8.0 + CUDA 12.8 (matches common functorch / ZeRO-3 bug reports)
62+
pip install "torch==2.8.0" --index-url https://download.pytorch.org/whl/cu128
4463

45-
# Latest DeepSpeed = this git checkout (editable)
46-
pip install -e .
64+
pip install -r requirements/requirements.txt
4765

48-
pip install pytest
66+
# Latest DeepSpeed = this git checkout (editable)
67+
pip install -e .
4968

50-
python -c "import torch, deepspeed; print('torch', torch.__version__, 'cuda', torch.version.cuda); print('deepspeed', deepspeed.__file__); print('deepspeed version', deepspeed.__version__)"
69+
pip install pytest
70+
71+
python -c "import torch, deepspeed; print('torch', torch.__version__, 'cuda', torch.version.cuda); print('deepspeed', deepspeed.__file__); print('deepspeed version', deepspeed.__version__)"
72+
fi
5173

5274
REPRO_SRC="$ROOT/scripts/repro_pr7916.py"
5375
if [[ ! -f "$REPRO_SRC" ]]; then

0 commit comments

Comments
 (0)