Repository navigation
DArray: Do not pass Base._InitialValue to partition reductions - #769
Merged
Merged
Conversation
Member
|
Thanks, this looks great! I'm looking into why GPU CI is suddenly failing, once that's fixed we can merge this. |
When the caller gives no `init`, each partition was reduced with
`init=Base._InitialValue()`. `Base`'s own reductions read that as "no
`init`", but GPU arrays take it for the initial value, so the kernel
calls `add_sum(::Base._InitialValue, ::Float32)` and fails to compile:
InvalidIRError: compiling MethodInstance for
CUDACore.partial_mapreduce_grid(::typeof(identity), ::typeof(Base.add_sum), ::Base._InitialValue, ...)
Reason: unsupported call to an unknown function (call to jl_f_throw_methoderror)
`sum`, `prod`, `mapreduce`, `minimum`, `maximum` and `extrema` all
failed this way on a `DArray` of GPU arrays. Leave `init` out when
there is none.
jpsamaroo
force-pushed
the
mapreduce-gpu-init
branch
from
October 12, 2026 20:33
639f707 to
bbcb182
Compare
Member
|
Thanks so much! |
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 #768.
When the caller gives no
init, each partition was reduced withinit=Base._InitialValue(). GPU arrays take that for the initial value and the kernel fails to compile, so every reduction on a GPU backedDArraythrew. This leavesinitout when there is none (_reduce_kwargs), for the partition reductions and for_extrema_inner.Tested on a Quadro RTX 8000 with CUDA.jl 6.4.2. With the change
sum,prod,mapreduce,maximumandextremamatch the CPU result, andsum,maximumandextremaalso do withdims.test/runtests.jl --test gpuwithCI_USE_CUDA=1passes, 242 tests. With the source change reverted, 8 of the 9 new tests error. The one that passes issum(DA; init=0f0).One of my two runs with the change had 3 errors in the existing
Arrays (GPU all)testset (aMethodErrorfrom a deserializedgenerate_thunksclosure on a worker). It did not repeat and the run without the change did not have it, so it looks like a flake.#670 edits the same two
@spawnlines (it adds a task name), so one of the two will need a small rebase.mean/var/stdstill fail on GPU, for a different reason (mutable OnlineStats accumulators in aCuArray).