Skip to content

Commit 122e503

Browse files
carmoccalexierule
authored andcommitted
Skip strategy=ddp_spawn, accelerator=cpu, python>=3.9 tests (#10550)
1 parent 5f4a5fe commit 122e503

18 files changed

+39
-27
lines changed

tests/callbacks/test_early_stopping.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -381,16 +381,16 @@ def on_train_end(self) -> None:
381381

382382
_ES_CHECK = dict(check_on_train_epoch_end=True)
383383
_ES_CHECK_P3 = dict(patience=3, check_on_train_epoch_end=True)
384-
_NO_WIN = dict(marks=RunIf(skip_windows=True))
384+
_SPAWN_MARK = dict(marks=RunIf(skip_windows=True, skip_49370=True))
385385

386386

387387
@pytest.mark.parametrize(
388388
"callbacks, expected_stop_epoch, check_on_train_epoch_end, strategy, num_processes",
389389
[
390390
([EarlyStopping("abc"), EarlyStopping("cba", patience=3)], 3, False, None, 1),
391391
([EarlyStopping("cba", patience=3), EarlyStopping("abc")], 3, False, None, 1),
392-
pytest.param([EarlyStopping("abc"), EarlyStopping("cba", patience=3)], 3, False, "ddp_spawn", 2, **_NO_WIN),
393-
pytest.param([EarlyStopping("cba", patience=3), EarlyStopping("abc")], 3, False, "ddp_spawn", 2, **_NO_WIN),
392+
pytest.param([EarlyStopping("abc"), EarlyStopping("cba", patience=3)], 3, False, "ddp_spawn", 2, **_SPAWN_MARK),
393+
pytest.param([EarlyStopping("cba", patience=3), EarlyStopping("abc")], 3, False, "ddp_spawn", 2, **_SPAWN_MARK),
394394
([EarlyStopping("abc", **_ES_CHECK), EarlyStopping("cba", **_ES_CHECK_P3)], 3, True, None, 1),
395395
([EarlyStopping("cba", **_ES_CHECK_P3), EarlyStopping("abc", **_ES_CHECK)], 3, True, None, 1),
396396
pytest.param(
@@ -399,15 +399,15 @@ def on_train_end(self) -> None:
399399
True,
400400
"ddp_spawn",
401401
2,
402-
**_NO_WIN,
402+
**_SPAWN_MARK,
403403
),
404404
pytest.param(
405405
[EarlyStopping("cba", **_ES_CHECK_P3), EarlyStopping("abc", **_ES_CHECK)],
406406
3,
407407
True,
408408
"ddp_spawn",
409409
2,
410-
**_NO_WIN,
410+
**_SPAWN_MARK,
411411
),
412412
],
413413
)

tests/callbacks/test_pruning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def test_pruning_callback_ddp_spawn(tmpdir):
187187
train_with_pruning_callback(tmpdir, use_global_unstructured=True, strategy="ddp_spawn", gpus=2)
188188

189189

190-
@RunIf(skip_windows=True)
190+
@RunIf(skip_windows=True, skip_49370=True)
191191
def test_pruning_callback_ddp_cpu(tmpdir):
192192
train_with_pruning_callback(tmpdir, parameters_to_prune=True, strategy="ddp_spawn", num_processes=2)
193193

tests/callbacks/test_stochastic_weight_avg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def test_swa_callback_ddp_spawn(tmpdir):
148148
train_with_swa(tmpdir, strategy="ddp_spawn", gpus=2)
149149

150150

151-
@RunIf(skip_windows=True)
151+
@RunIf(skip_windows=True, skip_49370=True)
152152
def test_swa_callback_ddp_cpu(tmpdir):
153153
train_with_swa(tmpdir, strategy="ddp_spawn", num_processes=2)
154154

tests/checkpointing/test_model_checkpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def on_train_end(self, trainer, pl_module):
385385
assert torch.save.call_count == 0
386386

387387

388-
@RunIf(skip_windows=True)
388+
@RunIf(skip_windows=True, skip_49370=True)
389389
def test_model_checkpoint_no_extraneous_invocations(tmpdir):
390390
"""Test to ensure that the model callback saves the checkpoints only once in distributed mode."""
391391
model = LogInTwoMethods()

tests/checkpointing/test_torch_saving.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def test_model_torch_save(tmpdir):
3434
trainer = torch.load(temp_path)
3535

3636

37-
@RunIf(skip_windows=True)
37+
@RunIf(skip_windows=True, skip_49370=True)
3838
def test_model_torch_save_ddp_cpu(tmpdir):
3939
"""Test to ensure torch save does not fail for model and trainer using cpu ddp."""
4040
model = BoringModel()

tests/deprecated_api/test_remove_1-7.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def get_from_queue(self, queue: torch.multiprocessing.SimpleQueue) -> None:
242242
return super().get_from_queue(queue)
243243

244244

245-
@RunIf(skip_windows=True)
245+
@RunIf(skip_windows=True, skip_49370=True)
246246
def test_v1_7_0_deprecate_add_get_queue(tmpdir):
247247
model = BoringCallbackDDPSpawnModel()
248248
trainer = Trainer(default_root_dir=tmpdir, fast_dev_run=True, num_processes=2, strategy="ddp_spawn")

tests/helpers/runif.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ def __new__(
7070
fairscale_fully_sharded: bool = False,
7171
deepspeed: bool = False,
7272
rich: bool = False,
73+
skip_49370: bool = False,
7374
**kwargs,
7475
):
7576
"""
@@ -91,6 +92,7 @@ def __new__(
9192
fairscale_fully_sharded: if `fairscale` fully sharded module is required to run the test
9293
deepspeed: if `deepspeed` module is required to run the test
9394
rich: if `rich` module is required to run the test
95+
skip_49370: Skip the test as it's impacted by https://github.com/pytorch/pytorch/issues/49370.
9496
kwargs: native pytest.mark.skipif keyword arguments
9597
"""
9698
conditions = []
@@ -165,6 +167,15 @@ def __new__(
165167
conditions.append(not _RICH_AVAILABLE)
166168
reasons.append("Rich")
167169

170+
if skip_49370:
171+
# strategy=ddp_spawn, accelerator=cpu, python>=3.9, torch<1.8 does not work
172+
py_version = f"{sys.version_info.major}.{sys.version_info.minor}.{sys.version_info.micro}"
173+
ge_3_9 = Version(py_version) >= Version("3.9")
174+
torch_version = get_distribution("torch").version
175+
old_torch = Version(torch_version) < Version("1.8")
176+
conditions.append(ge_3_9 and old_torch)
177+
reasons.append("Impacted by https://github.com/pytorch/pytorch/issues/49370")
178+
168179
reasons = [rs for cond, rs in zip(conditions, reasons) if cond]
169180
return pytest.mark.skipif(
170181
*args, condition=any(conditions), reason=f"Requires: [{' + '.join(reasons)}]", **kwargs

tests/loggers/test_all.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ def on_train_batch_start(self, trainer, pl_module, batch, batch_idx):
321321
assert pl_module.logger.experiment.something(foo="bar") is None
322322

323323

324+
@RunIf(skip_windows=True, skip_49370=True)
324325
@pytest.mark.parametrize("logger_class", [CometLogger, CSVLogger, MLFlowLogger, TensorBoardLogger, TestTubeLogger])
325-
@RunIf(skip_windows=True)
326326
def test_logger_created_on_rank_zero_only(tmpdir, monkeypatch, logger_class):
327327
"""Test that loggers get replaced by dummy loggers on global rank > 0."""
328328
_patch_comet_atexit(monkeypatch)

tests/models/test_cpu.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def validation_step(self, *args, **kwargs):
122122
model.unfreeze()
123123

124124

125-
@RunIf(skip_windows=True)
125+
@RunIf(skip_windows=True, skip_49370=True)
126126
def test_multi_cpu_model_ddp(tmpdir):
127127
"""Make sure DDP works."""
128128
tutils.set_random_main_port()

tests/models/test_horovod.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _run_horovod(trainer_options, on_gpu=False):
6666
assert exit_code == 0
6767

6868

69-
@RunIf(skip_windows=True, horovod=True)
69+
@RunIf(skip_windows=True, horovod=True, skip_49370=True)
7070
def test_horovod_cpu(tmpdir):
7171
"""Test Horovod running multi-process on CPU."""
7272
trainer_options = dict(
@@ -82,7 +82,7 @@ def test_horovod_cpu(tmpdir):
8282
_run_horovod(trainer_options)
8383

8484

85-
@RunIf(skip_windows=True, horovod=True)
85+
@RunIf(skip_windows=True, horovod=True, skip_49370=True)
8686
def test_horovod_cpu_clip_grad_by_value(tmpdir):
8787
"""Test Horovod running multi-process on CPU."""
8888
trainer_options = dict(
@@ -99,7 +99,7 @@ def test_horovod_cpu_clip_grad_by_value(tmpdir):
9999
_run_horovod(trainer_options)
100100

101101

102-
@RunIf(skip_windows=True, horovod=True)
102+
@RunIf(skip_windows=True, horovod=True, skip_49370=True)
103103
def test_horovod_cpu_implicit(tmpdir):
104104
"""Test Horovod without specifying a backend, inferring from env set by `horovodrun`."""
105105
trainer_options = dict(

0 commit comments

Comments
 (0)