-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Generalized LU factorization #28608
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalized LU factorization #28608
Conversation
4b5bb4e to
f5d59f6
Compare
vishwakftw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've been lurking around this PR, waiting for it to be completed, and it finally is! Thank you!!
I just have some comments before this lands.
|
fbgemm submodule update doesn't look intentional |
4703bf3 to
b71a29d
Compare
|
@ezyang , the fbgemm submodule update issue is now fixed. |
|
What still needs to be done on this PR? It's titled WIP |
|
@ezyang , the PR is complete as it is, however, there is a magma bug issue, see |
|
@pearu, I think the PR can land as is, but raise an issue when the matrices are singular i.e., preserving older behavior. Perhaps when the magma bug is fixed, we can enable accepting singular matrices. Do you think this is reasonable? |
|
@vishwakftw, let me sum up the situation:
This PR changes the old behavior as follows: The MAGMA bug is effective only when the following conditions are satisfied all at the same time: To preserve the backward compatibility behavior, avoid the MAGMA bug, and support non-square LU factorizations in full, it would be sufficient to enable the following features from this PR:
In essence, the current NaN results will be replaced with an exception until the NaN results will be made impossible by a fix to the MAGMA bug. Notice that I tend to insist that singular inputs should be allowed as much as possible because for linear algebra algorithms such as truncated SVD or PCA, not allowing singular inputs to LU would be a big blocker. In my opinion, the MAGMA bug is effective only for a small subset of possible application and it would not be reasonable to hold back the development of new algorithms for which there is high demand. Btw, there exists also another approach: instead of using |
|
This approach SGTM! |
@ezyang Just to be sure, which approach are you referring to?
|
|
@pearu maybe there is another way to resolve it, and this won't affect runtime for non-singular matrices. I propose the following:
|
|
I like the proposal, @vishwakftw, as it will be a full solution. Re |
|
@pearu we could also do that: identify singular matrices using |
Need to fix the singular case on CUDA
|
yes, exactly, I am currently working on this approach. |
CircleCI build failures summaryAs of commit 4a72b8b:
Here are the reasons each build failed. This comment was automatically generated by Dr. CI. Please report bugs/suggestions on the GitHub issue tracker. This comment has been revised 5 time(s). |
vishwakftw
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the changes look good to me.
Would it be possible for you to check if there is a perf regression for non-singular matrices?
|
Theoretically, there should not be as the loop over |
|
For the cases where magma issue 13 is effective, there exists some regression in the performance that is related to the overhead of scanning the info tensor for positive values. For instance, consider an LU factorization of an identity matrix in batches: We have the following timing results (best of three runs):
So, the additional overhead is about 12-30 µs per lu call iff magma issue 13 is effective. Btw, the timings were identical when using |
|
I guess this fine, thank you for providing the benchmarks @pearu. |
|
@pytorchbot rebase this please |
|
@vishwakftw @ezyang , is rebasing this PR stuck somewhere? |
|
Semi-automatic rebase is not working, could you please try to rebase manually? |
e40ccca to
7c7bd66
Compare
|
@pytorchbot rebase this please |
7c7bd66 to
a277f54
Compare
|
@vishwakftw, rebase is done. |
|
Failures look spurious. @pytorchbot merge this please. |
facebook-github-bot
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ezyang is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
Summary: This PR implements support for generalized LU factorization that is required for various algorithms such as PCA (see issue pytorch/pytorch#8049). Pull Request resolved: pytorch/pytorch#28608 Differential Revision: D18326449 Pulled By: ezyang fbshipit-source-id: d4011d75710e06e87ddbf5ad9afae42ba3330548
This PR implements support for generalized LU factorization that is required for various algorithms such as PCA (see issue #8049).