*_solve methods: implements forward AD#65546
Conversation
CI Flow Status⚛️ CI FlowRuleset - Version:
You can add a comment to the PR and tag @pytorchbot with the following commands: # ciflow rerun, "ciflow/default" will always be added automatically
@pytorchbot ciflow rerun
# ciflow rerun with additional labels "-l <ciflow/label_name>", which is equivalent to adding these labels manually and trigger the rerun
@pytorchbot ciflow rerun -l ciflow/scheduled -l ciflow/slowFor more information, please take a look at the CI Flow Wiki. |
🔗 Helpful links
💊 CI failures summary and remediationsAs of commit 99f0767 (more details on the Dr. CI page): ✅ None of the CI failures appear to be your fault 💚
1 job timed out:
❄️ 1 failure tentatively classified as flakybut reruns have not yet been triggered to confirm:
|
lezcano
left a comment
There was a problem hiding this comment.
This is a great PR! I had thought about implementing something like that, but I never got around to do it.
The code is very clean, thanks!
| scalar_t* A_working_ptr = &A_data[i * A_mat_stride]; | ||
| scalar_t* b_working_ptr = &b_data[i * b_mat_stride]; | ||
| lapackCholeskySolve<scalar_t>(uplo, n, nrhs, A_working_ptr, n, b_working_ptr, n, &info); | ||
| lapackCholeskySolve<scalar_t>(uplo, n, nrhs, A_working_ptr, ldab, b_working_ptr, ldab, &info); |
| const bool unitriangular | ||
| ) { | ||
| return generic_solve_jvp( | ||
| [=](const Tensor& A, const Tensor& B) { |
There was a problem hiding this comment.
| [=](const Tensor& A, const Tensor& B) { | |
| [upper, transpose, unitriangular](const Tensor& A, const Tensor& B) { |
Otherwise it might need to copy all the tensors (I don't know if the compiler is allowed to ellide the copies).
Same below.
There was a problem hiding this comment.
Not sure it will happen either way since afaik Tensors are not being copied on operator=.
There was a problem hiding this comment.
It was more about the copies of tensors and the reference bumps. A very very minor thing really.
There was a problem hiding this comment.
You can also capture everything by reference because the lambda never outlives the current scope?
albanD
left a comment
There was a problem hiding this comment.
Very nice refactoring! Thanks!
| const bool unitriangular | ||
| ) { | ||
| return generic_solve_jvp( | ||
| [=](const Tensor& A, const Tensor& B) { |
There was a problem hiding this comment.
You can also capture everything by reference because the lambda never outlives the current scope?
…taved/solve_methods_forward_AD
albanD
left a comment
There was a problem hiding this comment.
Looks good.
Thanks for the updates.
|
@albanD has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
|
Unlanding as this may have broken periodic_pytorch_xenial_cuda10_2_cudnn7_gcc7_old_gradcheck_test1. Relevant snippet: We had better run the periodic gradcheck job on this before relanding. |
…taved/solve_methods_forward_AD
|
Here is a link to the failing CI: https://app.circleci.com/pipelines/github/pytorch/pytorch/386383/workflows/8e2b4619-efd2-44dd-bd5f-24a1289b65b5/jobs/16239595 |
|
Ah, good point, @IvanYashchuk ! That makes sense, thank you! |
|
That periodic job runs gradchecks with fast_mode=False. You could try testing it locally by adding |
|
with this label, we should have the |
…taved/solve_methods_forward_AD
…om/pytorch/pytorch into nikitaved/solve_methods_forward_AD
|
This one looks good now with the updated OpInfo. |
albanD
left a comment
There was a problem hiding this comment.
Thanks for the update!
Try 2!
|
@albanD has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator. |
Summary: This PR adds forward AD for `*_solve` methods. Additionally, `cholesky_solve` gets OpInfo + a bug fix when wrong leading dimensions could be passed to LAPACK, and `lu_solve` gets forward AD with 2x`lu_solve` instead of 1x`lu_solve` + 2x`triangular_solve`. cc ezyang albanD zou3519 gqchen pearu nikitaved soulitzer Lezcano Varal7 jianyuh mruberry walterddr IvanYashchuk xwang233 Pull Request resolved: pytorch#65546 Reviewed By: gchanan Differential Revision: D31206837 Pulled By: albanD fbshipit-source-id: 040beda97442e7a88a9df9abc7bb18313ce55bc3
Summary: This PR adds forward AD for `*_solve` methods. Additionally, `cholesky_solve` gets OpInfo + a bug fix when wrong leading dimensions could be passed to LAPACK, and `lu_solve` gets forward AD with 2x`lu_solve` instead of 1x`lu_solve` + 2x`triangular_solve`. cc ezyang albanD zou3519 gqchen pearu nikitaved soulitzer Lezcano Varal7 jianyuh mruberry walterddr IvanYashchuk xwang233 Pull Request resolved: pytorch#65546 Reviewed By: dagitses Differential Revision: D31431847 Pulled By: albanD fbshipit-source-id: 0e343e0d9da3c3d2051fca215fad289d77275251
This PR adds forward AD for
*_solvemethods.Additionally,
cholesky_solvegets OpInfo + a bug fix when wrong leading dimensions could be passed to LAPACK,and
lu_solvegets forward AD with 2xlu_solveinstead of 1xlu_solve+ 2xtriangular_solve.cc @ezyang @albanD @zou3519 @gqchen @pearu @nikitaved @soulitzer @lezcano @Varal7 @jianyuh @mruberry @walterddr @IvanYashchuk @xwang233