fix: cast x buffer offset to int64 to prevent int32 overflow - #980
Open
Chessing234 wants to merge 1 commit into
Open
fix: cast x buffer offset to int64 to prevent int32 overflow#980Chessing234 wants to merge 1 commit into
Chessing234 wants to merge 1 commit into
Conversation
Chessing234
force-pushed
the
fix/selective-scan-x-buffer-int32-overflow
branch
from
August 5, 2026 10:24
ff0b91b to
f617d69
Compare
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.
Summary
xbuffer pointer offset toint64_tin the forward and backward selective scan CUDA kernels before multiplying byn_chunks * dstate.batch * dim * n_chunks * dstateexceedsINT32_MAX, which previously wrapped to a negative offset and silently corrupted memory or caused illegal CUDA accesses.Fixes #884
Test plan
MAMBA_FORCE_BUILD=TRUE pip install --no-cache-dir --force-reinstall . --no-build-isolationbatch,dim,n_chunks, anddstatewhere the product exceeds 2^31-1Made with Cursor