fix: cast fp32 block scales to UE8M0 before packing on SM100#3
Conversation
Replace device asserts in the UE8M0 layout pack kernels with an explicit power-of-2 cast so disable_ue8m0_cast=false can safely transform arbitrary fp32 scale buffers (including padded masked-MoE rows) on Blackwell. Co-authored-by: Cursor <cursoragent@cursor.com>
|
Please check fireworks code for parity. Deepgemm or flash MLA was breaking in the past and leading to quality issue due to quantization logic difference between fireworks triton kernels and their helpers. Clamp and saturation go a long way to end quality. |
Drop the UE8M0 device asserts added in 353753e and the follow-up cast. Pack fp32 block scales by shifting exponent bits into the int32 layout, matching pre-353753e behavior while keeping PSUM layout support. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b95c96e. Configure here.
| const auto sf_k_idx = sf_k_pack_idx * 4 + j; | ||
| values[j] = valid_mn and sf_k_idx < SF_K ? ptx::ld_shared(sf_smem_buffer + mn_idx * SF_K + sf_k_idx) : 0; | ||
| // FP32 SFs must have a zero sign and mantissa (only the exponent is packed) | ||
| DG_DEVICE_ASSERT((values[j] & 0x807fffffu) == 0); |
There was a problem hiding this comment.
Missing UE8M0 cast before pack
High Severity
The UE8M0 packing asserts were removed, but fp32 block scales are still packed by shifting raw IEEE bits (>> 23) with no power-of-two rounding. Non-UE8M0 scales (nonzero mantissa) therefore encode a floored exponent instead of the rounded UE8M0 code used by ceil_to_ue8m0, tilelang get_sf_and_inv, and fast_log2_ceil/fast_pow2, which can skew SM100 GEMM dequantization and model quality.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b95c96e. Configure here.
There was a problem hiding this comment.
Risk: medium. Not approving: Cursor Bugbot finished with status skipping and reported 1 unresolved finding (missing UE8M0 cast before exponent packing in smxx_layout.cuh). Human review is required; vipulSharma18 is already requested and zheanxu was added as a second reviewer.
Sent by Cursor Approval Agent: Pull Request Approver




Summary
smxx_layout.cuh.Why
DeepGEMM 2.6.1 asserts when masked MoE scale buffers contain non-UE8M0 fp32 values (including padded rows). The SM100 transform path with
disable_ue8m0_cast=falseshould cast inputs to UE8M0, not require callers to pre-sanitize buffers.Test plan
TestDeepseek3.test_dsv2on fireworks PR after bumping to this commitMade with Cursor