Skip to content

Commit 8db7c97

Browse files
committed
add the minimal test
1 parent 3b5c003 commit 8db7c97

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

tests/tests_pytorch/trainer/connectors/test_accelerator_connector.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,11 @@ class AcceleratorSubclass(CPUAccelerator):
582582
Trainer(accelerator=AcceleratorSubclass(), strategy=FSDPStrategySubclass())
583583

584584

585+
@RunIf(min_cuda_gpus=1)
586+
def test_check_fsdp_strategy_and_fallback_with_cudaaccelerator():
587+
Trainer(strategy="fsdp", accelerator=CUDAAccelerator(), devices=1, fast_dev_run=True)
588+
589+
585590
@mock.patch.dict(os.environ, {}, clear=True)
586591
def test_unsupported_tpu_choice(xla_available, tpu_available):
587592
# if user didn't set strategy, _Connector will choose the SingleDeviceXLAStrategy or XLAStrategy
@@ -1080,20 +1085,3 @@ def test_precision_selection_model_parallel(precision, raises, mps_count_0):
10801085
with error_context:
10811086
_AcceleratorConnector(precision=precision, strategy=ModelParallelStrategy())
10821087

1083-
1084-
@RunIf(min_cuda_gpus=1)
1085-
def test_fsdp_with_cudaaccelerator_instance(tmp_path):
1086-
# Minimal test to ensure FSDP works with CUDAAccelerator instance
1087-
from lightning.pytorch.demos.boring_classes import BoringModel
1088-
1089-
model = BoringModel()
1090-
trainer = Trainer(
1091-
default_root_dir=tmp_path,
1092-
max_epochs=1,
1093-
strategy="fsdp",
1094-
accelerator=CUDAAccelerator(),
1095-
devices=1,
1096-
fast_dev_run=True,
1097-
)
1098-
# Should not raise ValueError
1099-
trainer.fit(model)

0 commit comments

Comments
 (0)