Skip to content

Commit b740a99

Browse files
eqypytorchmergebot
authored andcommitted
[cuDNN][TF32] Threshold adjustments for TF32 on >=sm80 (pytorch#78437)
CC @ptrblck @mcarilli Change to transformer multilayer test can potentially be swapped in favor of an rtol change? (see also: pytorch#75612). Pull Request resolved: pytorch#78437 Approved by: https://github.com/ngimel
1 parent 416f581 commit b740a99

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

test/test_nn.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14070,7 +14070,10 @@ def _test(t, weight, mode):
1407014070
if mode == 'same':
1407114071
actual = actual[:5, :5, :10]
1407214072

14073-
self.assertEqual(actual, expected, rtol=2e-5, atol=5e-6)
14073+
if tf32_is_not_fp32() and (dtype == torch.float or dtype == torch.complex64):
14074+
self.assertEqual(actual, expected, atol=0.05, rtol=0.05)
14075+
else:
14076+
self.assertEqual(actual, expected, rtol=2e-5, atol=5e-6)
1407414077

1407514078
# Global dtype for this test suite is torch.double
1407614079
# This leads to change in type-promotion
@@ -19505,7 +19508,10 @@ def test_cudnn_convolution_relu(self, device, dtype):
1950519508
w = w.to(memory_format=memory_format)
1950619509
cudnn_out = torch.cudnn_convolution_relu(inp, w, None, (1, 1), (0, 0), (1, 1), 1)
1950719510
self.assertTrue(cudnn_out.is_contiguous(memory_format=memory_format))
19508-
self.assertEqual(conv2d_out.relu(), cudnn_out)
19511+
if tf32_is_not_fp32() and dtype == torch.float:
19512+
self.assertEqual(conv2d_out.relu(), cudnn_out, atol=2e-4, rtol=0.006)
19513+
else:
19514+
self.assertEqual(conv2d_out.relu(), cudnn_out)
1950919515

1951019516
@onlyCUDA
1951119517
@skipCUDAIfRocm
@@ -19533,7 +19539,10 @@ def test_cudnn_convolution_add_relu(self, device, dtype):
1953319539
cudnn_out = torch.cudnn_convolution_add_relu(inp, w, z, alpha, None, (1, 1), (0, 0), (1, 1), 1)
1953419540

1953519541
self.assertTrue(cudnn_out.is_contiguous(memory_format=memory_format))
19536-
self.assertEqual(F.relu(conv2d_out + alpha * z), cudnn_out)
19542+
if tf32_is_not_fp32() and dtype == torch.float:
19543+
self.assertEqual(F.relu(conv2d_out + alpha * z), cudnn_out, atol=3e-4, rtol=0.006)
19544+
else:
19545+
self.assertEqual(F.relu(conv2d_out + alpha * z), cudnn_out)
1953719546

1953819547
@onlyCUDA
1953919548
@skipCUDAIfRocm

torch/testing/_internal/common_nn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4243,7 +4243,7 @@ def unsqueeze_inp(inp):
42434243
check_gradgrad=False,
42444244
desc='multilayer_coder',
42454245
with_tf32=True,
4246-
tf32_precision=0.01,
4246+
tf32_precision=0.02,
42474247
),
42484248
dict(
42494249
module_name='Linear',

0 commit comments

Comments
 (0)