Skip to content
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

Bug: Derivative of transposed-vector times matrix is incorrect. #235

Closed
Red-Portal opened this issue Jul 13, 2023 · 5 comments · Fixed by #237
Closed

Bug: Derivative of transposed-vector times matrix is incorrect. #235

Red-Portal opened this issue Jul 13, 2023 · 5 comments · Fixed by #237

Comments

@Red-Portal
Copy link

Hi,
Found a correctness bug that seems only to affect ReverseDiff.

julia> A = [1 2; 3 4]; x = [5, 6];

julia> [ReverseDiff.gradient(y -> sum(y'*A), x) ;; 
        ReverseDiff.gradient(y -> sum(A'*y), x) ;;
             Zygote.gradient(y -> sum(y'*A), x)[1] ;;
             Zygote.gradient(y -> sum(A'*y), x)[1] ]
2×4 Matrix{Float64}:
 4.0  3.0  3.0  3.0
 6.0  7.0  7.0  7.0
@mohamed82008
Copy link
Member

Thanks for reporting this. Do you have any time to dig deeper into this?

@zelong-yin
Copy link

Hi, I also found that the memory allocation benchmarks are no longer correct.

When I tried the example codes it now shows spurious memory allocations
reversediff

It seems that these allocations are associated with the use of transposes. When I delete the adjoint operators in the definition they goes away.

@Red-Portal
Copy link
Author

@mohamed82008 Hi Mohamed! Unfortunately, my AD knowledge is insufficient to debug the AD frameworks. I do feel that I need to learn this stuff though...

@Red-Portal
Copy link
Author

@zelongyin2000 I think it would be better to open a separate issue for that

@yebai yebai mentioned this issue Aug 14, 2023
willtebbutt added a commit that referenced this issue Aug 14, 2023
* Fix mul

* Bump patch
@Red-Portal
Copy link
Author

Thanks @willtebbutt !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants