Fix DoRA extraction crash on 1-D weights (x_pad_token, norm weights)#16
Open
Booyaka101 wants to merge 1 commit into
Open
Fix DoRA extraction crash on 1-D weights (x_pad_token, norm weights)#16Booyaka101 wants to merge 1 commit into
Booyaka101 wants to merge 1 commit into
Conversation
The matched-shape branch computed torch.linalg.norm(tensor_a, dim=1) for every non-4-D tensor, including 1-D weights (e.g. x_pad_token, norm .weight). A 1-D tensor has no dim=1, so this raised 'Dimension out of range ... but got 1' and aborted the whole extraction. The code already skips 1-D tensors a few lines later, so bail out before the norm instead. Fixes silveroxides#15
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.
Fixes #15.
Extracting a DoRA from models that contain 1-D weights (e.g. z-image's
x_pad_token, or LayerNorm/RMSNorm.weight) crashes with:In the matched-shape branch,
is_conv_dim = tensor_a.ndim == 4sends every non-4-D tensor totorch.linalg.norm(..., dim=1). A 1-D tensor has nodim=1, so it raises and aborts the whole extraction. The function already discards 1-D tensors a few lines later (theweight_diff.ndim < 2skip), so this just bails out before the norm instead.Verified with a CPU repro of the exact branch: