From a703e4f7897527c92cbbede91d153c8ed853f802 Mon Sep 17 00:00:00 2001 From: Ege Ozkoc <90700230+egeozkoc@users.noreply.github.com> Date: Sun, 5 Jul 2026 13:05:27 -0400 Subject: [PATCH] Enable non-contiguous quantize_4bit tests for MPS backend The TestNonContiguousInputs 4-bit tests were gated to CUDA only when added in #1859 to cover the raw-pointer bug (#1342, #1690) that only affected the CUDA kernels. The MPS backend handles non-contiguous inputs correctly via its reshape/contiguous code paths. Verified locally that non-contiguous inputs produce bit-identical results to their contiguous equivalents on MPS across fp4/nf4, fp16/bf16/fp32, and blocksizes 64/128/256 (quantize + roundtrip). Enable the existing regression coverage on MPS. Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01XmxFGTVQTNPPhyN8wjsgJu --- tests/test_ops.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_ops.py b/tests/test_ops.py index 69589dcc0..6f935887c 100644 --- a/tests/test_ops.py +++ b/tests/test_ops.py @@ -435,8 +435,8 @@ def test_dequantize_blockwise_non_contiguous(self, device, dtype, blocksize): @pytest.mark.parametrize("quant_type", ["fp4", "nf4"]) @pytest.mark.parametrize("blocksize", [64, 128, 256]) def test_quantize_4bit_non_contiguous(self, device, dtype, quant_type, blocksize): - if device != "cuda": - pytest.skip("Non-contiguous fix targets CUDA backend only") + if device not in ("cuda", "mps"): + pytest.skip("Non-contiguous input handling not implemented for this backend") # Reproduce issue #1342: non-contiguous tensor from slicing A_full = torch.randn(3, 4, 6, 256, dtype=dtype, device=device) @@ -458,8 +458,8 @@ def test_quantize_4bit_non_contiguous(self, device, dtype, quant_type, blocksize @pytest.mark.parametrize("blocksize", [64, 128, 256]) def test_quantize_4bit_roundtrip_non_contiguous(self, device, dtype, quant_type, blocksize): """End-to-end test: quantize non-contiguous, dequantize, compare with contiguous path.""" - if device != "cuda": - pytest.skip("Non-contiguous fix targets CUDA backend only") + if device not in ("cuda", "mps"): + pytest.skip("Non-contiguous input handling not implemented for this backend") A_full = torch.randn(3, 4, 6, 256, dtype=dtype, device=device) A_noncontig = A_full[:, ::2, :, :]