Skip to content

Commit 051497b

Browse files
committed
Remove obsolete cross-device checkpoint test
The test verified the EXDEV/PermissionError workaround in _atomic_save that handled fsspec's cross-device staging. Since #21744 stages local checkpoints next to the destination, that code path is unreachable for local files — the test's mocks (os.rename, os.chmod) never fire on the new code path, leaving the test inert.
1 parent 80f8bd6 commit 051497b

1 file changed

Lines changed: 0 additions & 29 deletions

File tree

tests/tests_pytorch/trainer/connectors/test_checkpoint_connector.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
import errno
15-
import operator
1614
import os
17-
import re
1815
from unittest import mock
1916
from unittest.mock import ANY, Mock
2017

2118
import pytest
2219
import torch
23-
from lightning_utilities.core.imports import compare_version
2420

2521
from lightning.pytorch import Trainer
2622
from lightning.pytorch.callbacks import Callback, ModelCheckpoint
@@ -109,31 +105,6 @@ def test_hpc_max_ckpt_version(tmp_path):
109105
)
110106

111107

112-
def test_local_cross_device_checkpoint(tmpdir):
113-
"""Test that the _CheckpointConnector can write local cross-device files or raises an error if fsspec<2025.5.0."""
114-
model = BoringModel()
115-
# hardcoding dir since `tmp_path` can be windows path
116-
trainer = Trainer(
117-
default_root_dir="memory://test_ckpt_for_fsspec", limit_train_batches=1, limit_val_batches=1, max_epochs=1
118-
)
119-
trainer.fit(model)
120-
# Simulate the behavior of fsspec when writing to a local file system but other device.
121-
with (
122-
mock.patch("os.rename", side_effect=OSError(errno.EXDEV, "Invalid cross-device link")),
123-
mock.patch("os.chmod", side_effect=PermissionError("Operation not permitted")),
124-
):
125-
if compare_version("fsspec", operator.lt, "2025.5.0"):
126-
with pytest.raises(
127-
RuntimeError,
128-
match=re.escape(
129-
'Upgrade fsspec to enable cross-device local checkpoints: pip install "fsspec[http]>=2025.5.0"'
130-
),
131-
):
132-
trainer.save_checkpoint(tmpdir + "/test_ckpt_for_fsspec/hpc_ckpt.ckpt")
133-
else:
134-
trainer.save_checkpoint(tmpdir + "/test_ckpt_for_fsspec/hpc_ckpt.ckpt")
135-
136-
137108
def test_ckpt_for_fsspec():
138109
"""Test that the _CheckpointConnector is able to write to fsspec file systems."""
139110
model = BoringModel()

0 commit comments

Comments
 (0)