Skip to content

Commit 9445632

Browse files
freebleecopybara-github
authored andcommitted
Loosen test tolerances due to BF16 GPU being enabled
PiperOrigin-RevId: 491946888
1 parent 14b035d commit 9445632

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

lingvo/core/layers_test.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,10 +2576,14 @@ def testFCLayerFProp(self):
25762576
@parameterized.named_parameters(
25772577
('F32FPropF32Input', tf.float32, tf.float32, 0.668211),
25782578
('F32FPropBF16Input', tf.float32, tf.bfloat16, 0.669565),
2579-
('BF16FPropF32Input', tf.bfloat16, tf.float32, 0.667969),
2580-
('BF16FPropBF16Input', tf.bfloat16, tf.bfloat16, 0.667969),
2579+
('BF16FPropF32Input', tf.bfloat16, tf.float32, 0.667969, 1e-2),
2580+
('BF16FPropBF16Input', tf.bfloat16, tf.bfloat16, 0.667969, 1e-2),
25812581
)
2582-
def testFCLayerDtypes(self, fprop_dtype, input_dtype, expected_sum=0.):
2582+
def testFCLayerDtypes(self,
2583+
fprop_dtype,
2584+
input_dtype,
2585+
expected_sum=0.,
2586+
tol=1e-6):
25832587
with self.session(use_gpu=True):
25842588
tf.random.set_seed(398847392)
25852589
np.random.seed(12345)
@@ -2597,7 +2601,11 @@ def testFCLayerDtypes(self, fprop_dtype, input_dtype, expected_sum=0.):
25972601

25982602
output = proj_layer.FPropDefaultTheta(inputs)
25992603
self.evaluate(tf.global_variables_initializer())
2600-
self.assertAllClose(expected_sum, self.evaluate(tf.reduce_sum(output)))
2604+
self.assertAllClose(
2605+
expected_sum,
2606+
self.evaluate(tf.reduce_sum(output)),
2607+
atol=tol,
2608+
rtol=tol)
26012609

26022610
def testFCLayerBackProp(self):
26032611
with self.session(use_gpu=True) as sess:

0 commit comments

Comments
 (0)