mirror of
https://github.com/deepseek-ai/DeepGEMM.git
synced 2026-11-05 00:47:26 +00:00
[PR #337] Fix ue8m0 packing: mask mantissa bits when extracting fp32 exponents #372
Labels
No labels
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
deepseek-ai/DeepGEMM#372
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/deepseek-ai/DeepGEMM/pull/337
Author: @yhyang201
Created: 5/19/2026
Status: 🔄 Open
Base:
main← Head:fix/ue8m0-packing-mantissa-leak📝 Commits (1)
16f167dFix ue8m0 packing: mask mantissa bits when extracting fp32 exponents📊 Changes
1 file changed (+12 additions, -9 deletions)
View changed files
📝
deep_gemm/include/deep_gemm/impls/smxx_layout.cuh(+12 -9)📄 Description
transpose_and_pack_fp32_into_ue8m0andpack_fp32_into_ue8m0pack 4 fp32 exponent bytes into one uint32 using shift-and-OR:When fp32 scale factors have non-zero mantissa (not exact powers of two), mantissa bits leak into adjacent exponent fields. For example, packing four copies of 0.006975 (exp=0x77) produces 0x77ffffff instead of 0x77777777.
This causes NaN in
fp8_einsumwhen callers pass plain float32 scales.The torch fallback
get_mn_major_tma_aligned_packed_ue8m0_tensor_torchis correct: it uses>> 23then.to(kUInt8), which naturally truncates, but the CUDA kernel path doesn't truncate.Fix: extract each exponent with
(val >> 23) & 0xFFand shift to the correct byte position, in a sharedpack_4_fp32_exponentshelper.Reproduction