Skip to content

cumsum(DA; dims) throws a ConcurrencyViolationError #770

Closed

Description

@aalquwayfili

MWE

julia> using Dagger

julia> DA = distribute(rand(4, 4), Blocks(2, 2));

julia> cumsum(DA, dims=1)
ERROR: ConcurrencyViolationError("Cannot resolve aliasing for object of type Any (element of Matrix{Any}), execution may become sequential")

julia> cumsum(distribute(rand(4), Blocks(2)))
4-element DVector{Any} with 2 partitions of size 2:
 0.0206831
 0.437184
 1.14558
 1.77878

cumprod and accumulate behave the same. The vector case returns the right values, but with an Any eltype.

Cause

There is no accumulate method for a DArray, so Base's generic _accumulate! runs element by element. Base allocates the output as a DMatrix{Any}. Reading A[i, I] with I::CartesianIndex reaches getindex(A::DArray, idx...), which returns a 0-dimensional DArray and not a scalar:

julia> DA[1, 2]
0.5772936968348066

julia> DA[1, CartesianIndex(2)]
0-dimensional DArray{Float64, 0} with 1 partitions of size 1:
0.577294

Writing that into the output is then a copyto! between two DArrays under spawn_datadeps, which cannot work out the aliasing of a Matrix{Any}.

I can write a partition wise cumsum/cumprod (accumulate inside each partition, then carry the last slice forward along dims) if that is something you want.

Dagger master (02381759, 0.22.6)
Julia 1.12.7, Linux x86_64

Activity

  1. jpsamaroo commented on Oct 12, 2026

    @jpsamaroo
    Member

    I'd love that, if you wouldn't mind!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions