Matrix-vector multiplication fails when DArray is unevenly distributed

未關閉
#237 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
35/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
julia

研究方向

使用 julia -p 2 重現 test.jl 中的範例,然後檢查 /src/linalg.jl:279 附近的輸出陣列建構,以及 /src/linalg.jl:209 附近失敗的驗證。追蹤不均勻的第一維區塊如何表示,並確認在 2x4 和 3x4 分割下 A*x 能夠成功完成。

由索引模型根據 Issue 內容生成。

描述

The following example creates DArrays A and x, then attempts A*x. The only unusual bit is that A is distributed unevenly.

# test.jl

using Distributed, DistributedArrays
@everywhere using Distributed, DistributedArrays

A2 = @spawnat 2 ones((2,4))           # 2x4 array
A3 = @spawnat 3 ones((3,4))           # 3x4 array
A = DArray(reshape([A2,A3], (2,1)))   # 5x4 array

x = dones((4,1))                      # 4x1 array

A*x

Launching the REPL with julia -p 2 including test.jl yields

julia> include("test.jl")
ERROR: LoadError: ArgumentError: cuts of the first dimension of the output matrix must match cuts of dimension 1 of the first input matrix
Stacktrace:
 [1] _matmatmul!(C::DArray{Float64, 2, Matrix{Float64}}, A::DArray{Float64, 2, Matrix{Float64}}, B::DArray{Float64, 2, Matrix{Float64}}, α::Int64, β::Int64, tA::Char)
   @ DistributedArrays ~/.julia/packages/DistributedArrays/fEM6l/src/linalg.jl:209
 [2] mul! (repeats 2 times)
   @ ~/.julia/packages/DistributedArrays/fEM6l/src/linalg.jl:262 [inlined]
 [3] *(A::DArray{Float64, 2, Matrix{Float64}}, B::DArray{Float64, 2, Matrix{Float64}})
   @ DistributedArrays ~/.julia/packages/DistributedArrays/fEM6l/src/linalg.jl:279

Looking at the source around /src/linalg.jl:279,

function Base.:*(A::DMatrix, B::AbstractMatrix)
    T = Base.promote_op(_matmul_op, eltype(A), eltype(B))
    C = DArray(I -> Array{T}(undef, map(length, I)),
            (size(A, 1), size(B, 2)),
            procs(A)[:,1:min(size(procs(A), 2), size(procs(B), 2))],
            (size(procs(A), 1), min(size(procs(A), 2), size(procs(B), 2))))
    return mul!(C, A, B)
end

I think the issue may be that creation of the output array C doesn't account for the (admittedly unusual) possibility that A is distributed in uneven chunks.

主要語言
Julia
星號
205
分支
34
PR 合併指標
30 天內沒有已合併 PR

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

JuliaParallel/DistributedArrays.jl 的其他 Issue

查看 JuliaParallel/DistributedArrays.jl 的全部 Issue

相似的 Issue

更多 Julia Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。