Hacktoberfest 2026:メンテナが10月に向けて印を付けた、オープンで初心者向けの issue。 Hacktoberfest の issue を見る

feat(api): explicit distributed-backend selection (MDLABackend / IGGBackend), mirroring AbstractJVPBackend

オープン
#47 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
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 の本文から書いたものです。

説明

enhancement

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:

  1. Calling it without MDLA loaded gives a bare MethodError on an exported symbol, with no hint that the fix is using MultiDeviceLinearAlgebra.
  2. 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 MDLABackend holding a PartitionSpec, or an IGGBackend holding 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), and CartesianGrid's Dev parameter 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 the mul! 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 to MDLABackend(nparts; devices), or goes away outright. It is unregistered and pre-v1, so removing it is defensible; a shim is cheap.
  • Whether AbstractJVPBackend and AbstractDistributedBackend get 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 without nothing.

Done when

  • AbstractDistributedBackend + MDLABackend + IGGBackend defined 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 IGGBackend against 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 を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

RallypointOne/MatrixFreeOperators.jl のほかの issue

RallypointOne/MatrixFreeOperators.jl の issue をすべて見る

似ている issue

Julia の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。