Use OCP-conformant shared exponent and unify the MXFP paths - #7
Open
Shreyas8612 wants to merge 1 commit into
Open
Use OCP-conformant shared exponent and unify the MXFP paths#7Shreyas8612 wants to merge 1 commit into
Shreyas8612 wants to merge 1 commit into
Conversation
The shared scale was floor(log2(block_max)) with no element-format term, so the block maximum sat above the element exponent range and small elements flushed to zero. OCP Microscaling specifies floor(log2(block_max)) - emax_element. The non-hardware _mx_fp_quantize duplicated the hardware path with different padding and blocking, so the two disagreed on the same tensor; it is now a thin wrapper over the canonical hardware quantiser. MXINT sign-magnitude encoding now emits sign 0 for negative zero, which is the canonical code.
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.
Fixes MXFP shared-exponent computation to follow OCP Microscaling spec
Fixes the MXFP shared-exponent computation to follow the OCP Microscaling specification, and removes a duplicate quantization path that disagreed with the hardware one.
What was wrong
floor(log2(block_max))with no element-format term, so the block maximum sat above the element format's exponent range and small elements normalised into the subnormal region and flushed to zero. OCP specifiesfloor(log2(block_max)) - emax_element._mx_fp_quantizeduplicated the hardware path with different padding and blocking, so the two produced different results for the same tensor. It is now a thin wrapper over the canonical hardware quantiser.Verification
Checked by idempotency — quantising an already-quantised tensor must be a no-op, since a cached value is re-read many times after one round trip. Every element format fails this before the change and passes after, with relative error roughly halving.
The same fix is being submitted to mase in
DeepWok/maseasfix/mx-block-quantization, so the two libraries agree on MX semantics.Related: #8 and #9 touch disjoint files and can merge in any order.