]> khamidou — GitHub mirrors - safetensors.git/commitdiff
Revert "Improving the bf16 tests for PT+TF. (#505)" (#506)
authorNicolas Patry <patry.nicolas@protonmail.com>
Fri, 26 Jul 2024 10:04:48 +0000 (12:04 +0200)
committerGitHub <noreply@github.com>
Fri, 26 Jul 2024 10:04:48 +0000 (12:04 +0200)
This reverts commit 3bfe61321b1f6ad870685f92a600f87c10593ff2.

bindings/python/tests/test_pt_comparison.py
bindings/python/tests/test_tf_comparison.py

index eb1aa65a7ff48baeabe5eb606aa74f6619d01ce2..0f3821b8bf0bb7bdf1a682fe4c2099fcd3b55a53 100644 (file)
@@ -52,9 +52,9 @@ class TorchTestCase(unittest.TestCase):
 
     def test_odd_dtype(self):
         data = {
-            "test": torch.randn((2, 2), dtype=torch.bfloat16),
-            "test2": torch.randn((2, 2), dtype=torch.float16),
-            "test3": torch.randn((2, 2), dtype=torch.bool),
+            "test": torch.zeros((2, 2), dtype=torch.bfloat16),
+            "test2": torch.zeros((2, 2), dtype=torch.float16),
+            "test3": torch.zeros((2, 2), dtype=torch.bool),
         }
         local = "./tests/data/out_safe_pt_mmap_small.safetensors"
 
index 2c50bb76be593b604f1a6ea00ba3646723976aeb..ac41e6f616d2743dada375297d0423bf4f5cfd1c 100644 (file)
@@ -64,7 +64,7 @@ class SafeTestCase(unittest.TestCase):
 
     def test_bfloat16(self):
         data = {
-            "test": tf.randn((1024, 1024), dtype=tf.bfloat16),
+            "test": tf.zeros((1024, 1024), dtype=tf.bfloat16),
         }
         save_file(data, self.sf_filename)
         weights = {}
@@ -76,11 +76,6 @@ class SafeTestCase(unittest.TestCase):
             tv = data[k]
             self.assertTrue(tf.experimental.numpy.allclose(v, tv))
 
-        weights = load_file(self.sf_filename)
-        for k, v in weights.items():
-            tv = data[k]
-            self.assertTrue(tf.experimental.numpy.allclose(v, tv))
-
     def test_deserialization_safe_open(self):
         weights = {}
         with safe_open(self.sf_filename, framework="tf") as f: