]> khamidou — GitHub mirrors - safetensors.git/commitdiff
Adding a failing test on the device cast. (#623)
authorNicolas Patry <patry.nicolas@protonmail.com>
Mon, 16 Jun 2025 13:37:54 +0000 (13:37 +0000)
committerGitHub <noreply@github.com>
Mon, 16 Jun 2025 13:37:54 +0000 (15:37 +0200)
.pre-commit-config.yaml
bindings/python/tests/test_pt_comparison.py

index 1a28594bf50122930ff80429a2661f0924223348..70e9ba35ca1c0507d484ab4cdd65f72a58aa7c69 100644 (file)
@@ -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"]
index a87f50aa04841a870ba146b5975b0ffa16f995e7..441fb3519ea36581ee263c87011f1468ed115688 100644 (file)
@@ -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