Skip to content

Enable non-contiguous quantize_4bit tests for the MPS backend#1994

Merged
matthewdouglas merged 1 commit into
bitsandbytes-foundation:mainfrom
egeozkoc:feature/mps-noncontiguous-quant
Jul 9, 2026
Merged

Enable non-contiguous quantize_4bit tests for the MPS backend#1994
matthewdouglas merged 1 commit into
bitsandbytes-foundation:mainfrom
egeozkoc:feature/mps-noncontiguous-quant

Conversation

@egeozkoc

@egeozkoc egeozkoc commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

The TestNonContiguousInputs 4-bit tests (test_quantize_4bit_non_contiguous and test_quantize_4bit_roundtrip_non_contiguous) were gated to CUDA only when added in #1859, which fixed the raw-pointer bug (#1342, #1690) that affected the CUDA kernels specifically. The MPS backend already handles non-contiguous inputs correctly via its reshape/contiguous code paths, so this coverage can safely be extended to it.

This change relaxes the skip guard on those two tests to also run on mps.

Verification

Ran locally on Apple Silicon (macOS, MPS). Non-contiguous inputs produce bit-identical results to their contiguous equivalents across every parametrization — fp4/nf4, fp16/bf16/fp32, and blocksizes 64/128/256, for both quantize and the quantize→dequantize roundtrip:

36 passed  (previously 36 skipped)

Notes

  • The blockwise non-contiguous tests already run on MPS and pass; only the two 4-bit tests were CUDA-gated.
  • CPU remains skipped intentionally — its blockwise quantize/dequantize path still produces incorrect results on non-contiguous inputs (a separate issue will be filed).
  • No CI impact: CI exercises only the cpu and cuda backends, so these MPS-only tests are skipped there and run only on developer machines with MPS.

🤖 Generated with Claude Code

The TestNonContiguousInputs 4-bit tests were gated to CUDA only when
added in bitsandbytes-foundation#1859 to cover the raw-pointer bug (bitsandbytes-foundation#1342, bitsandbytes-foundation#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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XmxFGTVQTNPPhyN8wjsgJu
@matthewdouglas matthewdouglas added this to the v0.50.0 milestone Jul 9, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@matthewdouglas matthewdouglas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@matthewdouglas matthewdouglas merged commit e56da9e into bitsandbytes-foundation:main Jul 9, 2026
83 of 84 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants