Skip to content

Fix mantissa underflow in block floating point quantization#21

Open
Shayanthn wants to merge 1 commit into
ma3mool:mainfrom
Shayanthn:fix/block-fp-mantissa-underflow
Open

Fix mantissa underflow in block floating point quantization#21
Shayanthn wants to merge 1 commit into
ma3mool:mainfrom
Shayanthn:fix/block-fp-mantissa-underflow

Conversation

@Shayanthn

Copy link
Copy Markdown

Summary

Fixes #15

Problem

In block floating point quantization, after dividing mantissa by power_exp_diff during shared exponent alignment, values can become less than 1.0. This causes incorrect exponent reconstruction when the tensor is later processed.

Solution

Added mantissa underflow handling by clamping values below 1.0 to zero, maintaining valid block floating point representation.

Changes

  • quant_bfloat_py: Added underflow check after mantissa shifting
  • quant_bfloat_meta_py: Applied same fix for consistency

Fixes ma3mool#15

After dividing mantissa by power_exp_diff during shared exponent alignment,
values can become less than 1.0 which leads to incorrect exponent
reconstruction. This fix clamps underflowed mantissa values to zero to
maintain valid block floating point representation.

Applied fix to both quant_bfloat_py and quant_bfloat_meta_py functions.
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.

possible bug in block fp implementation

1 participant