Skip to content

Commit dd7b2f3

Browse files
Bordapre-commit-ci[bot]SkafteNickibhimrazydeependujha
authored
tests: fix skipif condition for deepspeed (#21195)
* tests: fix skipif condition for `deepspeed` * split test_trainer_compiled_model * test_trainer_compiled_model_deepspeed * cuda-toolkit * Apply suggestion from @bhimrazy * add huggingface_hub as a dependency --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Nicki Skafte Detlefsen <[email protected]> Co-authored-by: Bhimraj Yadav <[email protected]> Co-authored-by: Deependu <[email protected]>
1 parent 6a8d943 commit dd7b2f3

File tree

12 files changed

+82
-36
lines changed

12 files changed

+82
-36
lines changed

.azure/gpu-tests-fabric.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ jobs:
8585
displayName: "extend env. vars 4 future"
8686
8787
- bash: |
88+
set -ex
8889
echo $(DEVICES)
8990
echo $CUDA_VISIBLE_DEVICES
9091
echo $CUDA_VERSION_MM
@@ -96,6 +97,10 @@ jobs:
9697
python --version
9798
pip --version
9899
pip list
100+
# todo: rather use devel base image
101+
apt-get update -qq --fix-missing
102+
apt-get install -y cuda-toolkit
103+
nvcc --version
99104
displayName: "Image info & NVIDIA"
100105
101106
- bash: |
@@ -156,7 +161,7 @@ jobs:
156161
- bash: python -m coverage run --source ${COVERAGE_SOURCE} -m pytest tests_fabric/ -v --durations=50
157162
workingDirectory: tests/
158163
displayName: "Testing: fabric standard"
159-
timeoutInMinutes: "10"
164+
timeoutInMinutes: "15"
160165

161166
- bash: |
162167
wget https://raw.githubusercontent.com/Lightning-AI/utilities/main/scripts/run_standalone_tests.sh
@@ -165,7 +170,7 @@ jobs:
165170
env:
166171
PL_RUN_STANDALONE_TESTS: "1"
167172
displayName: "Testing: fabric standalone"
168-
timeoutInMinutes: "10"
173+
timeoutInMinutes: "15"
169174
170175
- bash: |
171176
python -m coverage report

.azure/gpu-tests-pytorch.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ jobs:
8484
displayName: "extend env. vars 4 future"
8585
8686
- bash: |
87+
set -ex
8788
echo $(DEVICES)
8889
echo $CUDA_VISIBLE_DEVICES
8990
echo $CUDA_VERSION_MM
@@ -95,6 +96,10 @@ jobs:
9596
python --version
9697
pip --version
9798
pip list
99+
# todo: rather use devel base image
100+
apt-get update -qq --fix-missing
101+
apt-get install -y cuda-toolkit
102+
nvcc --version
98103
displayName: "Image info & NVIDIA"
99104
100105
- bash: |
@@ -189,7 +194,7 @@ jobs:
189194
env:
190195
PL_USE_MOCKED_MNIST: "1"
191196
displayName: "Testing: PyTorch standalone tasks"
192-
timeoutInMinutes: "10"
197+
timeoutInMinutes: "15"
193198

194199
- bash: |
195200
python -m coverage report

.github/checkgroup.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ subprojects:
4747
- "!*.md"
4848
- "!**/*.md"
4949
checks:
50-
- "pytorch.yml / Lit Job (nvidia/cuda:12.1.1-runtime-ubuntu22.04, pytorch, 3.10)"
50+
- "pytorch.yml / Lit Job (nvidia/cuda:12.1.1-devel-ubuntu22.04, pytorch, 3.10)"
5151
- "pytorch.yml / Lit Job (lightning, 3.12)"
5252
- "pytorch.yml / Lit Job (pytorch, 3.12)"
5353

@@ -148,7 +148,7 @@ subprojects:
148148
- "!*.md"
149149
- "!**/*.md"
150150
checks:
151-
- "fabric.yml / Lit Job (nvidia/cuda:12.1.1-runtime-ubuntu22.04, fabric, 3.10)"
151+
- "fabric.yml / Lit Job (nvidia/cuda:12.1.1-devel-ubuntu22.04, fabric, 3.10)"
152152
- "fabric.yml / Lit Job (fabric, 3.12)"
153153
- "fabric.yml / Lit Job (lightning, 3.12)"
154154

.lightning/workflows/fabric.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ trigger:
66

77
timeout: "60" # minutes
88
machine: "L4_X_2"
9-
image: "nvidia/cuda:12.6.3-runtime-ubuntu22.04"
9+
image: "nvidia/cuda:12.6.3-devel-ubuntu22.04"
1010
parametrize:
1111
matrix: {}
1212
include:
1313
# note that this is setting also all oldest requirements which is linked to python == 3.10
14-
- image: "nvidia/cuda:12.1.1-runtime-ubuntu22.04"
14+
- image: "nvidia/cuda:12.1.1-devel-ubuntu22.04"
1515
PACKAGE_NAME: "fabric"
1616
python_version: "3.10"
1717
- PACKAGE_NAME: "fabric"
1818
python_version: "3.12"
19-
# - image: "nvidia/cuda:12.6-runtime-ubuntu22.04"
20-
# PACKAGE_NAME: "fabric"
19+
#- image: "nvidia/cuda:12.6-runtime-ubuntu22.04"
20+
# PACKAGE_NAME: "fabric"
2121
- PACKAGE_NAME: "lightning"
2222
python_version: "3.12"
2323
exclude: []

.lightning/workflows/pytorch.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,18 @@ trigger:
66

77
timeout: "60" # minutes
88
machine: "L4_X_2"
9-
image: "nvidia/cuda:12.6.3-runtime-ubuntu22.04"
9+
image: "nvidia/cuda:12.6.3-devel-ubuntu22.04"
1010
parametrize:
1111
matrix: {}
1212
include:
1313
# note that this also sets oldest requirements which are linked to Python == 3.10
14-
- image: "nvidia/cuda:12.1.1-runtime-ubuntu22.04"
14+
- image: "nvidia/cuda:12.1.1-devel-ubuntu22.04"
1515
PACKAGE_NAME: "pytorch"
1616
python_version: "3.10"
1717
- PACKAGE_NAME: "pytorch"
1818
python_version: "3.12"
19-
# - image: "nvidia/cuda:12.6.3-runtime-ubuntu22.04"
20-
# PACKAGE_NAME: "pytorch"
19+
#- image: "nvidia/cuda:12.6.3-devel-ubuntu22.04"
20+
# PACKAGE_NAME: "pytorch"
2121
- PACKAGE_NAME: "lightning"
2222
python_version: "3.12"
2323
exclude: []

requirements/fabric/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ pytest-random-order ==1.2.0
99
click ==8.1.8; python_version < "3.11"
1010
click ==8.3.0; python_version > "3.10"
1111
tensorboardX >=2.6, <2.7.0 # todo: relax it back to `>=2.2` after fixing tests
12+
huggingface-hub

requirements/pytorch/test.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@ uvicorn # for `ServableModuleValidator` # not setting version as re-defined in
2121
tensorboard >=2.11, <2.21.0 # for `TensorBoardLogger`
2222

2323
torch-tensorrt; platform_system == "Linux" and python_version >= "3.12"
24+
huggingface-hub

src/lightning/fabric/utilities/testing/_runif.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def _runif_reasons(
113113
reasons.append("Standalone execution")
114114
kwargs["standalone"] = True
115115

116-
if deepspeed and not (_DEEPSPEED_AVAILABLE and not _TORCH_GREATER_EQUAL_2_4):
116+
if deepspeed and not (_DEEPSPEED_AVAILABLE and _TORCH_GREATER_EQUAL_2_4):
117117
reasons.append("Deepspeed")
118118

119119
if dynamo:

tests/tests_fabric/strategies/test_deepspeed_integration.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,9 @@ def _assert_saved_model_is_equal(fabric, model, checkpoint_path):
312312
single_ckpt_path = checkpoint_path / "single_model.pt"
313313
# the tag is hardcoded in DeepSpeedStrategy
314314
convert_zero_checkpoint_to_fp32_state_dict(checkpoint_path, single_ckpt_path, tag="checkpoint")
315+
316+
is_ckpt_path_a_file = os.path.isfile(single_ckpt_path)
317+
single_ckpt_path = single_ckpt_path if is_ckpt_path_a_file else single_ckpt_path / "pytorch_model.bin"
315318
state_dict = torch.load(single_ckpt_path, weights_only=False)
316319
else:
317320
# 'checkpoint' is the tag, hardcoded in DeepSpeedStrategy

tests/tests_pytorch/strategies/test_deepspeed.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ def on_train_start(self, trainer, pl_module) -> None:
313313
trainer.fit(model)
314314
trainer.test(model)
315315
assert list(lr_monitor.lrs) == ["lr-SGD"]
316-
assert len(set(lr_monitor.lrs["lr-SGD"])) == 8
316+
assert len(lr_monitor.lrs["lr-SGD"]) == 8
317317

318318

319319
@RunIf(min_cuda_gpus=1, standalone=True, deepspeed=True)
@@ -1029,6 +1029,9 @@ def _assert_save_model_is_equal(model, tmp_path, trainer):
10291029
if trainer.is_global_zero:
10301030
single_ckpt_path = os.path.join(tmp_path, "single_model.pt")
10311031
convert_zero_checkpoint_to_fp32_state_dict(checkpoint_path, single_ckpt_path)
1032+
1033+
if not os.path.isfile(single_ckpt_path):
1034+
single_ckpt_path = os.path.join(single_ckpt_path, "pytorch_model.bin")
10321035
state_dict = torch.load(single_ckpt_path, weights_only=False)
10331036

10341037
model = model.cpu()

0 commit comments

Comments
 (0)