mamba-ssm: fix selective_state_update launch args when D or dt_bias is None - #1077
Draft
jiqing-feng wants to merge 1 commit into
Draft
mamba-ssm: fix selective_state_update launch args when D or dt_bias is None#1077jiqing-feng wants to merge 1 commit into
jiqing-feng wants to merge 1 commit into
Conversation
…s None `D` and `dt_bias` are documented as optional, but passing either as None raises before the kernel is reached: - `*(D.stride(0), D.stride(1)) if D is not None else 0` parses as `*((D.stride(0), D.stride(1)) if D is not None else 0)`, because a conditional expression binds looser than the unpacking, so the None case unpacks the int 0 and raises "Value after * must be an iterable, not int". Build the tuple first and pass a (0, 0) placeholder, matching how `z_strides` a few lines above already handles the same situation. - `tie_hdim` dereferences `dt_bias.stride(-1)` unconditionally, so it raises on None before the launch args are even evaluated. Both are plain Python bugs and reproduce on CUDA.
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
Danddt_biasare documented as optional, but passing either asNoneraises before the kernel is reached.
*(D.stride(0), D.stride(1)) if D is not None else 0parses as*((D.stride(0), D.stride(1)) if D is not None else 0)— a conditionalexpression binds looser than the unpacking — so the
Nonecase tries to unpackthe int
0:Build the tuple first and pass a
(0, 0)placeholder, which is howz_stridesa few lines above already handles the same situation.
tie_hdimseparately dereferencesdt_bias.stride(-1)unconditionally, so itraises on
Nonebefore the launch args are even evaluated.Both are plain Python bugs and reproduce on CUDA.