Repository navigation
Conversation
Contributor
Author
|
@matthewdouglas, could you approve the pending workflows and review this when you have a chance? Local MPS and CPU validation passes on Torch 2.12.1 and 2.15.0, including checks that required-Hub mode rejects fallback-only runs. Details are in the PR description. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The direct
dequantize_4bitoperator test checks shape/device and runs opcheck,but can pass when the MPS Hub kernel returns zeros. It can also pass entirely
through the fallback, so a successful MPS run does not establish Hub coverage.
Add an independent CPU reference that unpacks high/low nibbles, indexes the
public FP4/NF4 codebook, applies block scales in FP32, and casts to the requested
dtype. The existing operator matrix now checks numerical values and output dtype
before opcheck.
A separate 60-case MPS matrix checks real Hub calls and forced fallback across
FP4/NF4 and FP16/BF16/FP32. It includes all four supported Hub block sizes,
uint8/bfloat16 packed storage, zero/non-unit scales, odd partial tails, and both
allocating and
.outcalls with a non-contiguous destination. Blocksize 32 mustuse fallback even with Hub available. Loader state and the spied function are
restored after each case.
Optional Hub cases skip explicitly if unavailable.
--require-mps-hubrejectsmissing MPS, an incompatible device selection, or an unavailable Hub build, and
prints Torch/kernels versions and the resolved variant in the pytest header.
The dispatch matrix asserts actual calls, so silent fallback fails its Hub rows.
Required mode also needs at least one passing test that verified Hub execution:
the test records this only after its numerical and dispatch assertions pass,
and a session check rejects an otherwise successful run with none. Selecting
only fallback controls therefore cannot satisfy
--require-mps-hub.Only
tests/test_ops.pyandtests/conftest.pychange.Validation
Apple M5, macOS 26.0, Python 3.12.13, kernels 0.17.1; current main
a616886.Used the published Hub snapshot
c3cadfafa7f693bbabbe65479be68f23ffb1c880, withits respective Torch 2.12 and 2.15 Metal builds.
On each of PyTorch 2.12.1 and 2.15.0:
BNB_TEST_DEVICE=mps python -m pytest tests/test_ops.py -k dequantize_4bit --require-mps-hub: 120 passed.BNB_TEST_DEVICE=cpu python -m pytest tests/test_ops.py -k dequantize_4bit: 60 passed, 60 MPS-only cases skipped, using a freshly built native CPU library.the numerical assertions in both the existing test and the new Hub test.
Disabling Hub dispatch after successful setup fails the call assertion.
selection. With the kernels import disabled in optional mode, 30 fallback
cases pass and 30 Hub cases skip.
calls, session exits 1 with an explicit missing-execution error. Ten
mutation/availability/selection controls per Torch version behave as expected.
Applicable pre-commit hooks and
git diff --checkpass. Mutation scripts and rawvalidation logs are local evidence outside the proposed PR. The full suite and
CUDA/ROCm/XPU/HPU were not run. Automated upstream MPS execution still needs an
agreed runner; this patch supplies an explicit local/runner validation command.
AI assistance: implementation, local validation, and this description were
prepared with OpenAI Codex.