Skip to content

When MxFp4Codec::QuantizeBlock encounters an all-zero input block, the early-out path zeroes kBlockSize (32) bytes instead of the encoded block size sizeof(MxFp4Stream) (17 bytes: 1 scale byte plus 16 nibble bytes). Writing 15 bytes past the end of the block corrupts the adjacent block when blocks are encoded out of order (such as across parallel batch boundaries in Compress or via packed_ofs sub-ranges) and writes past PackedEnd on the final block of a tensor. - #1045

Merged
copybara-service[bot] merged 1 commit into
devfrom
test_991744020
Oct 1, 2026

Conversation

@copybara-service

Copy link
Copy Markdown

When MxFp4Codec::QuantizeBlock encounters an all-zero input block, the early-out path zeroes kBlockSize (32) bytes instead of the encoded block size sizeof(MxFp4Stream) (17 bytes: 1 scale byte plus 16 nibble bytes). Writing 15 bytes past the end of the block corrupts the adjacent block when blocks are encoded out of order (such as across parallel batch boundaries in Compress or via packed_ofs sub-ranges) and writes past PackedEnd on the final block of a tensor.

Zero sizeof(MxFp4Stream) bytes in the all-zero early-out path so block quantization stays within the bounds of a single encoded MxFp4Stream block.

Based on
#1044

…the early-out path zeroes `kBlockSize` (32) bytes instead of the encoded block size `sizeof(MxFp4Stream)` (17 bytes: 1 scale byte plus 16 nibble bytes). Writing 15 bytes past the end of the block corrupts the adjacent block when blocks are encoded out of order (such as across parallel batch boundaries in `Compress` or via `packed_ofs` sub-ranges) and writes past `PackedEnd` on the final block of a tensor.

Zero `sizeof(MxFp4Stream)` bytes in the all-zero early-out path so block quantization stays within the bounds of a single encoded `MxFp4Stream` block.

Based on
#1044

PiperOrigin-RevId: 991799968
@copybara-service
copybara-service Bot merged commit 1c570b9 into dev Oct 1, 2026
11 checks passed
@copybara-service
copybara-service Bot deleted the test_991744020 branch October 1, 2026 18:32
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.

1 participant