Fix addmm with empty matrices and beta != 1.0#2715
Merged
angeloskath merged 3 commits intoml-explore:mainfrom Nov 3, 2025
Merged
Fix addmm with empty matrices and beta != 1.0#2715angeloskath merged 3 commits intoml-explore:mainfrom
angeloskath merged 3 commits intoml-explore:mainfrom
Conversation
angeloskath
requested changes
Oct 30, 2025
Member
angeloskath
left a comment
There was a problem hiding this comment.
I left a minor comment for the gpu implementation and a rather larger one for the cpu. Feel free to ask any questions if something doesn't make sense.
9d5577a to
ec39583
Compare
Contributor
Author
|
@angeloskath I’ve addressed your feedback, |
angeloskath
approved these changes
Nov 3, 2025
Member
angeloskath
left a comment
There was a problem hiding this comment.
Looks good I will merge after the tests pass.
- Fix CPU backend to apply beta scaling for empty matrices (K=0) - Fix Metal backend to apply beta scaling for empty matrices (K=0) - Add comprehensive tests for empty matrix addmm with various beta values - Tests cover different shapes and batched empty matrices The bug occurred when addmm was called with empty matrices (one dimension is 0) and beta != 1.0. The function would return C instead of beta * C because the early return for empty matrices didn't apply beta scaling. Fixes ml-explore#2698
ec39583 to
e4140bd
Compare
Contributor
Author
|
Temporary array Added The fix is now passing locally and ready for CI rerun. Could you please approve the workflow when you get a chance? |
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 #2698 [BUG] mx.addmm with empty a and b produces incorrect result
Proposed changes
The bug occurred when addmm was called with empty matrices (one dimension is 0) and beta != 1.0. The function would return C instead of beta * C because the early return for empty matrices didn't apply beta scaling.
Checklist
Put an
xin the boxes that apply.pre-commit run --all-filesto format my code / installed pre-commit prior to committing changes