Repository navigation
Fixed misaligned stores in RandomBits on the CPU - #4886
Merged
Merged
Conversation
zcbenz
marked this pull request as ready for review
November 20, 2026 04:11
Each key's output starts at a byte offset that need not be a multiple of 4. This patch stores the generated uint32_t with `memcpy` and adds a test.
zcbenz
force-pushed
the
random-bits-misaligned-store
branch
from
November 20, 2026 04:27
4305996 to
057007b
Compare
zcbenz
approved these changes
Nov 20, 2026
rcfa
pushed a commit
to cubiculum-ai/mlx
that referenced
this pull request
Nov 26, 2026
Ported: the fork already stores through a std::memcpy store lambda (osaurus-ai/mlx PR 44), so mlx/backend/cpu/primitives.cpp keeps the fork's code. Only Apple's test is taken, beside the fork's own. (cherry picked from commit 70d0d09)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Each key's output starts at a byte offset that need not be a multiple of
4. This patch stores the generated uint32_t with
memcpyand adds a test.Note: The new test only verifies the fix under UBSan with halting enabled. Without the patch, the test fails.