From: Nicolas Patry Date: Mon, 16 Jun 2025 13:37:54 +0000 (+0000) Subject: Adding a failing test on the device cast. (#623) X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=f79f19d13277ec2f53fe107ee335f6492400b0cf;p=safetensors.git Adding a failing test on the device cast. (#623) --- diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1a28594..70e9ba3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -39,7 +39,7 @@ repos: args: ["--line-length", "119", "--target-version", "py35"] types: ["python"] - repo: https://github.com/pycqa/flake8 - rev: 3.8.3 + rev: 7.2.0 hooks: - id: flake8 args: ["--config", "bindings/python/setup.cfg"] diff --git a/bindings/python/tests/test_pt_comparison.py b/bindings/python/tests/test_pt_comparison.py index a87f50a..441fb35 100644 --- a/bindings/python/tests/test_pt_comparison.py +++ b/bindings/python/tests/test_pt_comparison.py @@ -303,6 +303,11 @@ class LoadTestCase(unittest.TestCase): self.assertEqual(weights["test"].device, torch.device("cpu")) torch.set_default_device(torch.device("cpu")) + torch.set_default_device(torch.device(0)) + weights = load_file(self.sf_filename) + self.assertEqual(weights["test"].device, torch.device("cpu")) + torch.set_default_device(torch.device("cpu")) + @unittest.skipIf(not torch.cuda.is_available(), "Cuda is not available") def test_deserialization_safe_gpu(self): # First time to hit disk