Conversation
Contributor
Author
Kernel benchmarks (M4, ZP_BF16_gs64, criterion median µs)(4096, 4096) — 8 MB, fits SLC
(14336, 4096) M=1 — 28 MB, 5-rep verification
LUT 2.7% faster, within noise. No regression at this shape/M. (Earlier sweep reported +275% for this case — turned out to be a E2E LFM2.5 4-bit (n=15, M4)
Decode regresses 1.8–3.5% across both formats — small but consistent. |
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.
Tested replacing QmvFast's pure-ALU int4→float dequant:
uint_to_fpmantissa trick (nibble extract via shift/mask + bit-OR + fsub) with
a threadgroup-memory LUT lookup. No win at any tested shape, mild
E2E regression on real models. Mantissa trick stays optimal.
Headline (Apple M4, ZP_BF16_gs64, 4-bit, kernel µs medians)
E2E LFM2.5 4-bit decode: −1.8% (RHT), −3.5% (MLX).
What was tried
bf << 16widen: eliminatesair.convertfrom AIR(verified) but no wallclock change. Convert wasn't the cost.
Verdict
The actual cost is L1 cache port contention: LUT reads compete
with weight loads at the same L1 read port. The mantissa trick has
zero memory ops in the dequant chain (pure ALU, extracts nibbles
and converts to float in one fused bit-twiddle), so it doesn't fight
for the port. No LUT variant can beat that on Apple GPU.