Repository navigation
Don't read complex adjoints from their parent's buffer in reductions - #221
Merged
Merged
Conversation
Reductions along dims read a source that has `strides` over a dense parent straight from that parent's buffer. LinearAlgebra defines `strides` for adjoints of real numbers only, since the adjoint of a complex number is its conjugate, but ArrayLayouts.jl defines it for all adjoints. With it loaded, reductions of complex adjoints summed the unconjugated values, e.g. GPUArrays' `mapreducedim!` from `A'`.
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.
Reductions along dims of a complex adjoint return unconjugated results when ArrayLayouts.jl is loaded (which LazyArrays.jl, BandedMatrices.jl and others depend on):
strided_layouttreats any source that hasstridesas a view of its parent's buffer, and reads its elements from there. LinearAlgebra only definesstridesfor adjoints of real numbers, since the elements of a complex adjoint are the conjugates of the values in memory, but ArrayLayouts.jl defines it for all adjoints. Complex adjoints now take the linear layout regardless ofstrides, as the comment onstrided_layoutalready intended. NamingAdjointmakes LinearAlgebra a dependency; it is a stdlib in the system image, and GPUArrays already depends on it.This showed up as order-dependent failures of GPUArrays'
mapreducedim!testsuite in CUDA.jl's CI (JuliaGPU/CUDA.jl#3639), where a test loading LazyArrays sometimes ran earlier in the same worker. The new test definesstridesfor a complex adjoint the way ArrayLayouts does, and fails without the fix (6 unconjugated results); it passes on CUDA with it. Includes a version bump for a patch release.