From 918def412a8f70fdef5d6e667b8240d7423ef858 Mon Sep 17 00:00:00 2001 From: Matthew Douglas <38992547+matthewdouglas@users.noreply.github.com> Date: Mon, 8 Sep 2025 14:14:44 -0400 Subject: [PATCH] Adjust 4bit test tolerance on CPU for larger blocksizes --- tests/test_functional.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/test_functional.py b/tests/test_functional.py index fc37cb4c3..34d3e8412 100644 --- a/tests/test_functional.py +++ b/tests/test_functional.py @@ -1169,8 +1169,12 @@ def test_4bit_quant(self, device, dtype, quant_type, blocksize): 4096: 0.262457, } - assert err < error_dict[quant_type]["err"][blocksize] + 1e-3 - assert relerr < error_dict[quant_type]["rel_err"][blocksize] + 1e-3 + # Allow higher tolerance for fp32 on CPU with larger block sizes + reltol = 2.8e-3 if dtype == torch.float32 and blocksize >= 128 and device == "cpu" else 1e-3 + errtol = 1.2e-3 if dtype == torch.float32 and blocksize >= 1024 and device == "cpu" else 1e-3 + + assert err < error_dict[quant_type]["err"][blocksize] + errtol + assert relerr < error_dict[quant_type]["rel_err"][blocksize] + reltol @pytest.mark.parametrize("device", get_available_devices()) @pytest.mark.parametrize("quant_type", ["fp4", "nf4"])