Skip to content

Use OCP-conformant shared exponent and unify the MXFP paths - #7

Open
Shreyas8612 wants to merge 1 commit into
mainfrom
fix/ocp-microscaling-scale
Open

Use OCP-conformant shared exponent and unify the MXFP paths#7
Shreyas8612 wants to merge 1 commit into
mainfrom
fix/ocp-microscaling-scale

Conversation

@Shreyas8612

@Shreyas8612 Shreyas8612 commented Aug 8, 2026

Copy link
Copy Markdown
Collaborator

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

  • The shared scale was 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 specifies floor(log2(block_max)) - emax_element.
  • _mx_fp_quantize duplicated 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.
  • MXINT sign-magnitude encoding emitted sign 1 for negative zero; the canonical code is sign 0.

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/mase as fix/mx-block-quantization, so the two libraries agree on MX semantics.

Related: #8 and #9 touch disjoint files and can merge in any order.

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.
Copilot AI lite review requested due to automatic review settings August 8, 2026 00:07

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants