From 94d765dd1181b6e8184aafde475ea49488e97a09 Mon Sep 17 00:00:00 2001 From: Alexander <208520214+AlexanderSoftCode@users.noreply.github.com> Date: Fri, 30 Oct 2026 00:41:59 -0500 Subject: [PATCH] test(conv): silence the expected fp16 overflow in the cast kernel test test_matches_clip_and_astype scales its inputs by 3e4 so some exceed fp16's 65504; the backward cast leaves inputs unclipped, so they must overflow to inf like forward's astype. The NumPy reference cast hit that overflow on the host and printed "RuntimeWarning: overflow encountered in cast" on every GPU run. The reference cast now runs under np.errstate(over="ignore"), scoped to that one line so the clipped dvalues path still warns if it ever overflows. A new assert checks the inputs really exceed the fp16 range, as the existing one does for dvalues, so the overflow half of the test can't silently become an in-range check. --- tests/ops/test_conv_cast_kernel.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ops/test_conv_cast_kernel.py b/tests/ops/test_conv_cast_kernel.py index 3448ce2..dd9ff22 100644 --- a/tests/ops/test_conv_cast_kernel.py +++ b/tests/ops/test_conv_cast_kernel.py @@ -51,8 +51,12 @@ def test_matches_clip_and_astype(self): self.assertEqual(dv16.shape, dvalues.shape) self.assertEqual(in16.shape, inputs.shape) self.assertTrue((np.abs(dvalues) > 65504).any(), "test data must exercise the clip") + self.assertTrue((np.abs(inputs) > 65504).any(), "test data must exercise the overflow") np.testing.assert_array_equal(dv16, np.clip(dvalues, -65504, 65504).astype(np.float16)) - np.testing.assert_array_equal(in16, inputs.astype(np.float16)) + # The overflow to inf is the behavior under test, so NumPy's warning is expected. + with np.errstate(over="ignore"): + expected_in16 = inputs.astype(np.float16) + np.testing.assert_array_equal(in16, expected_in16) base_case.register_test_suites(globals(), template_cls=TestConvBackwardCastKernel)