diff --git a/backends/cadence/aot/tests/test_replace_ops_passes.py b/backends/cadence/aot/tests/test_replace_ops_passes.py index 95d470644a0..cecf49c58ce 100644 --- a/backends/cadence/aot/tests/test_replace_ops_passes.py +++ b/backends/cadence/aot/tests/test_replace_ops_passes.py @@ -1242,9 +1242,17 @@ def test_replace_conv1d_with_linear(self) -> None: self.assertTrue(result.modified) graph_after_passes = result.graph_module - # Validate numerical accuracy + # Conv and linear compute the same dot product but accumulate fp32 + # terms in different order, so non-associativity of floating-point + # addition produces diffs up to ~1.2e-05. Use rtol=2e-05. inputs = [x, weights, bias] - validate(gm_before, graph_after_passes, inputs, "ReplaceTrivialConvWithLinear") + validate( + gm_before, + graph_after_passes, + inputs, + "ReplaceTrivialConvWithLinear", + rtol=2e-5, + ) # Assert that conv1d is trivially converted to linear self.assertEqual( @@ -1278,9 +1286,17 @@ def test_replace_conv2d_with_linear(self) -> None: self.assertTrue(result.modified) graph_after_passes = result.graph_module - # Validate numerical accuracy + # Conv and linear compute the same dot product but accumulate fp32 + # terms in different order, so non-associativity of floating-point + # addition produces diffs up to ~1.2e-05. Use rtol=2e-05. inputs = [x, weights, bias] - validate(gm_before, graph_after_passes, inputs, "ReplaceTrivialConvWithLinear") + validate( + gm_before, + graph_after_passes, + inputs, + "ReplaceTrivialConvWithLinear", + rtol=2e-5, + ) # Assert that conv2d is trivially converted to linear self.assertEqual(