feat(api): explicit distributed-backend selection (MDLABackend / IGGBackend), mirroring AbstractJVPBackend
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 静か
- 技術スタック
- julia
調査の方向性
Start with src/operators/linearize.jl to follow the existing explicit-backend pattern, then inspect the distributed entry point in ext/MatrixFreeOperatorsMDLAExt.jl and DESIGN.md §10.4. Review the relationship with #46 and the existing distributed tests. Done means the core tags and fallback, the MDLA implementation, unloaded-backend error test, documentation distinction from KernelAbstractions devices, and the IGG integration are all covered.
索引モデルが issue の本文から書いたものです。
説明
Problem
There is no way to choose a distributed backend. prepare_distributed is exported from the core, but its only method is defined inside ext/MatrixFreeOperatorsMDLAExt.jl:
function prepare_distributed(L0::AbstractOperator, nparts::Integer; devices=nothing)
So today the backend is whatever extension happens to be loaded, selected implicitly. Two consequences:
- Calling it without MDLA loaded gives a bare
MethodErroron an exported symbol, with no hint that the fix isusing MultiDeviceLinearAlgebra. - It does not survive a second backend. Once the IGG halo lands (#46), two extensions would define competing methods with the same
(operator, integer)signature. That is an ambiguity, and disambiguating it by keyword is worse.
Selection should be explicit and declarative, the way choosing an AD backend or a KernelAbstractions device is.
Proposal — mirror AbstractJVPBackend
We already have exactly this pattern in-repo, and it should be the model rather than inventing a second convention. src/operators/linearize.jl defines the abstract type and both concrete tags in the core, exports them, and lets the extension implement the behaviour:
abstract type AbstractJVPBackend end
struct FiniteDifferenceJVP <: AbstractJVPBackend end
struct EnzymeJVP <: AbstractJVPBackend end # core-defined; Enzyme ext implements
Its docstring already states the principle we want here — "Selecting the backend is deliberately explicit rather than ambient: the backends differ in ... which operations they support, so which one you get must not depend on load order." That reasoning applies verbatim to MDLA vs IGG.
This is also the ADTypes/DifferentiationInterface model the request pointed at: AutoEnzyme() lives in ADTypes, not in Enzyme, so you can name and dispatch on a backend you have not loaded.
Sketch:
# core
abstract type AbstractDistributedBackend end
struct MDLABackend <: AbstractDistributedBackend # single-node multi-GPU, slab decomposition
nparts::Int
devices::Union{Nothing,Vector{Int}}
end
struct IGGBackend <: AbstractDistributedBackend # multi-node MPI, 3D blocking
dims::NTuple{3,Int}
periodic::NTuple{3,Bool}
end
prepare_distributed(L, backend::AbstractDistributedBackend; kwargs...)
with a core fallback whose whole job is a good error:
prepare_distributed(::AbstractOperator, b::AbstractDistributedBackend; kwargs...) =
error("no distributed method for $(nameof(typeof(b))) — load the backing package (e.g. `using MultiDeviceLinearAlgebra`)")
Extensions then implement prepare_distributed(L, ::MDLABackend) / (L, ::IGGBackend) against the existing _dist_scatter! / _dist_reduce! seam. Nothing about the seam itself changes.
Constraints
- Tags must be config-only and free of backend types. An
MDLABackendholding aPartitionSpec, or anIGGBackendholding an MPI communicator, would drag the dependency into the core and defeat the point. Ints, tuples, symbols only. - This is orthogonal to the KernelAbstractions device, and the docs must say so explicitly — the analogy that motivates the API is also the easiest thing for a reader to conflate. The KA backend answers which device runs the kernel; this answers how partitions talk to each other. A real run picks both (
CUDABackend()device +IGGBackend()distribution), andCartesianGrid'sDevparameter is the former, not the latter. - Construction-time only. Like
EnzymeJVP, the tag selects behaviour when the prepared operator is built and must not leak into the operator tree or themul!hot path. - Does not change
prepare's contract — still stateful and single-threaded, one per concurrent solve.
Decisions to make while implementing
- Whether the existing
prepare_distributed(L, nparts::Integer; devices)stays as a deprecated shim forwarding toMDLABackend(nparts; devices), or goes away outright. It is unregistered and pre-v1, so removing it is defensible; a shim is cheap. - Whether
AbstractJVPBackendandAbstractDistributedBackendget documented together as one "explicit backend selection" concept in the docs, since they now share a rationale. Recommend yes — one section, two axes. - Whether a trivial
SerialBackend()is worth having so single-rank code paths are expressible withoutnothing.
Done when
-
AbstractDistributedBackend+MDLABackend+IGGBackenddefined and exported from core -
prepare_distributed(L, backend; …)is the documented entry point; core fallback errors with a "load X" message - MDLA extension implements its tag; existing tests pass through the new entry point
- Requesting an unloaded backend is tested for the error message, not just the throw
- Docs state the KA-device vs distributed-backend distinction explicitly
- #46's IGG extension implements
IGGBackendagainst this API rather than adding another entry point
Related: #46 (IGG halo backend), DESIGN.md §10.4.
🤖 Written by Claude — Kyle pointed at the shape, I filled in the paperwork.
- 主要言語
- Julia
- スター
- 3
- フォーク
- 1
- 平均マージ
- 1日 28分
- マージ済み PR(30日)
- 6
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
RallypointOne/MatrixFreeOperators.jl のほかの issue
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
enhancement
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
performance
難易度 5/5 1週間以上 初心者へのやさしさ 45/100
-
perf(forest): thread the reference BlockForest path — leaf sweeps and exchange descriptor loopsオープンperformance
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
-
enhancement
難易度 5/5 1週間以上 初心者へのやさしさ 25/100
RallypointOne/MatrixFreeOperators.jl の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 83/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
JuliaDecisionFocusedLearning/ImplicitDifferentiation.jl#231 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
bigfloat: invalid parse base crashes Julia対応中かも @MilesCranmerBot が今日担当しました。 オープンbignums bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
lanl-ansi/PowerModels.jl#1023 ·