MPI: tasks with acceleration=DistributedAcceleration() go missing when ranks spawn them independently
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 15/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
調査の方向性
Start with accel_matches_proc and compatible_processors for DistributedAcceleration, which the report says ignore MPIProcessor, and with the task ID counter that feeds the MPI tags. Run test/mpi/cpu.jl on 2 ranks with 2 threads to reproduce the missing tasks. Done means each rank finishes its local tasks and mixed local/SPMD work gives correct results. The reporter says they plan to open a PR, and the intended way to pass results between local and SPMD tasks is still open, so check with maintainers first.
索引モデルが issue の本文から書いたものです。
説明
We'd like to run some tasks only on the local rank inside an MPI program (a parallel loop over the rank's own threads), without every rank planning them. acceleration=Dagger.DistributedAcceleration() looked like the way to do that, and it works on one rank. With two ranks, some of the tasks never run:
# mpiexec -n 2 julia --project --threads=4 min.jl
using Dagger, MPI
Dagger.accelerate!(:mpi)
rank = MPI.Comm_rank(MPI.COMM_WORLD)
busy(i) = (sleep(0.1); i)
ts = [Dagger.@spawn(acceleration = Dagger.DistributedAcceleration(), busy(i)) for i in 1:12]
done = Threads.Atomic{Int}(0)
foreach(t -> Threads.@spawn((fetch(t); Threads.atomic_add!(done, 1))), ts)
t0 = time(); while done[] < 12 && time() - t0 < 20; sleep(0.1); end
println("rank $rank: $(done[])/12 tasks finished")
With -n 1 all 12 finish. With -n 2 only 8–10 per rank do, and we see Hit probable hang on bcast_meta delivery and sometimes AssertionError: MPIRef rank mismatch. Dagger 0.22.7, MPI.jl 0.20.28, Julia 1.13; same on macOS (MPICH_jll) and on a Linux cluster (Open MPI).
We think there are two things going on:
- Some of these tasks get placed on
MPIProcessors, sometimes on the other rank, and then follow the SPMD execution path.accel_matches_proc(::DistributedAcceleration, proc)is alwaystrue, andcompatible_processors(::DistributedAcceleration, ...)skips the filter completely. The missing tasks are exactly the ones placed on MPI processors. - Local tasks take IDs from the same counter as SPMD tasks, and the MPI tags are derived from those IDs. If the ranks spawn different numbers of local tasks, later SPMD tasks get different IDs on each rank and hang (
Hit hang on bcast_meta deliverywith different tags on the two ranks).
I'll open a PR with a small fix for both: MPI processors are excluded for DistributedAcceleration, and local tasks under MPI get IDs from a separate range. With it, the reproducer runs fine (12/12 per rank, about 4× faster than spawning the tasks SPMD-style), local tasks with different counts per rank followed by normal SPMD work give correct results, and test/mpi/cpu.jl passes on 2 ranks × 2 threads.
We're not sure whether this is the intended way to use acceleration= under MPI, though. With the patch, a local task can use an SPMD result owned by its own rank; using one owned by another rank fails with an error, which seems reasonable. We don't know what the intended way is to pass a local task's result back into SPMD work.
Thanks a lot!
The analysis, the fix and this text were written with help from Claude (Anthropic); I checked the results.
- 主要言語
- Julia
- スター
- 734
- フォーク
- 94
- 平均マージ
- 4日 18時間
- マージ済み PR(30日)
- 2
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
JuliaParallel/Dagger.jl のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
JuliaParallel/Dagger.jl#786 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
JuliaParallel/Dagger.jl#759 · コメント 3 件 ·
-
bug datadeps
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
JuliaParallel/Dagger.jl#665 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 30/100
JuliaParallel/Dagger.jl#661 · コメント 1 件 ·
-
memory usage
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
JuliaParallel/Dagger.jl#649 · コメント 6 件 ·
JuliaParallel/Dagger.jl の issue をすべて見る
似ている issue
-
path: splitext treats directory references and leading dots as extensions対応中かも @Hiten0305l が今日担当しました。 オープン
難易度 2/5 半日 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
JuliaParallel/Hwloc.jl#93 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
SciML/SciMLBenchmarks.jl#1996 ·
メンテナーはふだん 1 日以内に返信
-
Affine transformations of `JohnsonSU` could return a `JohnsonSU`対応中かも @devmotion が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
JuliaStats/Distributions.jl#2117 ·
メンテナーはふだん 2 日以内に返信