From 0aa9049ea63adcd87375256b61340c1cdb5085c0 Mon Sep 17 00:00:00 2001 From: Aniruddha Adak Date: Fri, 9 Oct 2026 10:45:45 +0530 Subject: [PATCH 1/2] test(torch): cover low-precision outlier does not overflow in squashing scaler --- .../test_torch_squashing_scaler.py | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/test_torch_preprocessing/test_torch_squashing_scaler.py b/tests/test_torch_preprocessing/test_torch_squashing_scaler.py index e63c499b3..c290ba8f0 100644 --- a/tests/test_torch_preprocessing/test_torch_squashing_scaler.py +++ b/tests/test_torch_preprocessing/test_torch_squashing_scaler.py @@ -439,3 +439,23 @@ def test__blocked_transform_does_not_write_to_its_input( _run_with_budgets(patch, _FORCE_BLOCKED, x, 64, 3.0) _assert_bit_identical("input tensor", x, before) + + +@pytest.mark.parametrize("outlier", [1000.0, -1000.0]) +@pytest.mark.parametrize("dtype", [torch.float16, torch.bfloat16]) +def test__call__low_precision_outlier_does_not_overflow( + outlier: float, dtype: torch.dtype +) -> None: + # Both low-precision dtypes take the upcast path, so both need the cover. + scaler = TorchSquashingScaler() + x = torch.tensor( + [0, 1, 1, 1, 2, outlier], + dtype=dtype, + ).unsqueeze(-1) + + out = scaler(x, num_train_rows=5) + + assert out.dtype == dtype + assert torch.isfinite(out).all() + assert 2.5 < abs(out[-1, 0].item()) <= 3.0 + assert out[-1, 0].item() * outlier > 0 From aeaeae3e74342f887aa2c4d4a1637d310d6fd930 Mon Sep 17 00:00:00 2001 From: Aniruddha Adak Date: Mon, 19 Oct 2026 15:30:15 +0530 Subject: [PATCH 2/2] docs(changelog): add towncrier fragment for the low-precision outlier test PR --- changelog/1368.fixed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog/1368.fixed.md diff --git a/changelog/1368.fixed.md b/changelog/1368.fixed.md new file mode 100644 index 000000000..c7036cf09 --- /dev/null +++ b/changelog/1368.fixed.md @@ -0,0 +1 @@ +Added a regression test ensuring low-precision (float16) squashing does not overflow before SquashingScaler rescaling.